Skip to content

yosoyfantastico/flight-api

Repository files navigation

TO RUN LOCALLY

1. install dependencies

npm install

2. create database and table

Database Schema

CREATE DATABASE flightapi;
CREATE TABLE api_keys (  id SERIAL PRIMARY KEY,  api_key VARCHAR(255) NOT NULL, created_at TIMESTAMP DEFAULT NOW())
INSERT INTO api_keys (api_key) VALUES  ('abc123'),  ('def456'),  ('ghi789'),  ('jkl012'),  ('mno345')
CREATE TABLE airport_data ( icao VARCHAR(4), iata VARCHAR(3), name VARCHAR(255), city VARCHAR(255), state VARCHAR(255), country VARCHAR(255), elevation INTEGER, lat FLOAT, lon FLOAT, tz VARCHAR(255))

3. set the environment variables in .env file

4 insert data in database

node utils/batchInsert.js

5. run the server

npm start


SAMPLE REQUEST

if httpS doesn't work, please use HTTP

https://flight.thenewabacus.com/api/flights/originICAO/destinationICAO

Sample http request(POWERSHELL)

Invoke-WebRequest -Uri 'https://flight.thenewabacus.com/api/flights/RPLL/KJFK' -Headers @{'api-key' = 'mno345'}

Sample http request(cURL)[linux]

curl --location --request GET 'https://flight.thenewabacus.com/api/flights/RPLL/KJFK'--header 'api-key: mno345'

API KEYS

abc123, def456, ghi789, jkl012, mno345

Response: JSON

{
    "INR": {
        "fareAIrIndia": "54782.27",
        "fareIndigo": "82173.41",
        "fareSpiceJet": "95868.98",
        "fareVistara": "109564.55"
    }
}

REFERENCES:

Airports Data

calculating distance between two coordinates

haversine formula

express documentation

node postgres documentation

ssl certificate guide

another ssl certificate guide

About

calculate fare between two airports or Lat and Lon

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published