GithubHelp home page GithubHelp logo

adriennehl / flight-engine Goto Github PK

View Code? Open in Web Editor NEW

This project forked from americanairlines/flight-engine

0.0 1.0 0.0 1.2 MB

Mock flight data delivered simply and quickly without a database.

License: MIT License

JavaScript 1.29% TypeScript 98.71%

flight-engine's Introduction

Flight Engine

Mock flight data delivered simply and quickly without a database.

Let's Get Started


Deploy Flight Engine and Use Now

If you would like to just use Flight Engine as we have designed it, deploy a copy to Heroku using the button below.

NOTE: If you go with this approach, you will not be able to customize Flight Engine.

Deploy


Retrieving Data

Once your app is up and running (either locally or hosted somewhere like Heroku), make HTTP requests to retrieve the data documented below.

Airport Information

Each endpoint displays information related to the airport whose IATA (Airport Code) is provided with the request:

Examples

Get the details of a given airport by its IATA (Airport Code)

URL : /airports?code=<IATA-CODE>

Method: GET

Auth required: No

Permissions required: None

Success Response:

Code: 200 OK

Respones

{
  "code": "DFW",
  "city": "Dallas-Fort Worth",
  "timezone": "America/Chicago",
  "location": {
    "latitude": 32.8998,
    "longitude": 97.0403
  }
}

404 Response

Airport not found

Malformed Request Response

Please enter a valid flight code i.e. DFW, GSO, ATL...

Get the details of all supported airports

URL : /airports/all

Method: GET

Auth required: No

Permissions required: None

Success Response:

Code: 200 OK

Respones

[
  {
    "code": "DFW",
    "city": "Dallas-Fort Worth",
    "timezone": "America/Chicago",
    "location": {
      "latitude": 32.8998,
      "longitude": 97.0403
    }
  },
  {
    "code": "JFK",
    "city": "New York City",
    "timezone": "America/New_York",
    "location": {
      "latitude": 40.6413,
      "longitude": 73.7781
    }
  }
  //...
]

Flight Information

Examples

Get the details of a given airport by its IATA (Airport Code)

Default Request

URL : /flights?date=YYYY-MM-DD

Method: GET

Auth required: No

Permissions required: None

Success Response

Code: 200 OK

[
  {
    "flightNumber": "0978",
    "origin": {
      "code": "DFW",
      "city": "Dallas-Fort Worth",
      "timezone": "America/Chicago",
      "location": {
        "latitude": 32.8998,
        "longitude": 97.0403
      }
    },
    "destination": {
      "code": "PHL",
      "city": "Philadelphia",
      "timezone": "America/New_York",
      "location": {
        "latitude": 39.8729,
        "longitude": -75.2437
      }
    },
    "distance": 7393,
    "duration": {
      "locale": "18h 36m",
      "hours": 18,
      "minutes": 36
    },
    "departureTime": "2017-08-29T02:36:00.000-05:00",
    "arrivalTime": "2017-08-29T22:12:00.000-04:00",
    "aircraft": {
      "model": "321",
      "passengerCapacity": {
        "total": 181,
        "main": 165,
        "first": 16
      },
      "speed": 400
    }
  },
  "..."
]

Flight Record From Specified Airport Destination Request

Will display flights filtered by airport destination

URL : /flights?date=YYYY-MM-DD&destination=<IATA-CODE>

Method: GET

Auth required: No

Permissions required: None

Success Response

Code: 200 OK

Examples

Flights by Destination

Sample Endpoint : /flights?date=YYYY-MM-DD&destination=GSO

[
  {
    "flightNumber": "8124",
    "origin": {
      "code": "DFW",
      "city": "Dallas-Fort Worth",
      "timezone": "America/Chicago",
      "location": {
        "latitude": 32.8998,
        "longitude": 97.0403
      }
    },
    "destination": {
      "code": "GSO",
      "city": "Greensboro",
      "timezone": "America/New_York",
      "location": {
        "latitude": 36.0726,
        "longitude": -79.792
      }
    },
    "distance": 7675,
    "duration": {
      "locale": "21h 46m",
      "hours": 21,
      "minutes": 46
    },
    "departureTime": "2021-08-29T05:10:00.000-05:00",
    "arrivalTime": "2021-08-30T03:56:00.000-04:00",
    "aircraft": {
      "model": "757",
      "passengerCapacity": {
        "total": 176,
        "main": 160,
        "first": 16
      },
      "speed": 380
    }
  },
  {
    "flightNumber": "1643",
    "origin": {
      "code": "DFW",
      "city": "Dallas-Fort Worth",
      "timezone": "America/Chicago",
      "location": {
        "latitude": 32.8998,
        "longitude": 97.0403
      }
    },
    "destination": {
      "code": "GSO",
      "city": "Greensboro",
      "timezone": "America/New_York",
      "location": {
        "latitude": 36.0726,
        "longitude": -79.792
      }
    },
    "distance": 7675,
    "duration": {
      "locale": "20h 50m",
      "hours": 20,
      "minutes": 50
    },
    "departureTime": "2021-08-29T09:25:00.000-05:00",
    "arrivalTime": "2021-08-30T07:15:00.000-04:00",
    "aircraft": {
      "model": "321",
      "passengerCapacity": {
        "total": 181,
        "main": 165,
        "first": 16
      },
      "speed": 400
    }
  },
  "..."
]

Flight Record From Specified Airport Origin Request

Will display flights filtered by airport destination

URL : /flights?date=YYYY-MM-DD&origin=IATA-CODE

Method: GET

Auth required: No

Permissions required: None

Success Response

Code: 200 OK

Examples

Flights by Origin

Sample Endpoint : /flights?date=YYYY-MM-DD&origin=PHL

[
  {
    "flightNumber": "0216",
    "origin": {
      "code": "PHL",
      "city": "Philadelphia",
      "timezone": "America/New_York",
      "location": {
        "latitude": 39.8729,
        "longitude": -75.2437
      }
    },
    "destination": {
      "code": "SAN",
      "city": "San Diego",
      "timezone": "America/Los_Angeles",
      "location": {
        "latitude": 32.7338,
        "longitude": -117.1933
      }
    },
    "distance": 2368,
    "duration": {
      "locale": "6h 38m",
      "hours": 6,
      "minutes": 38
    },
    "departureTime": "2021-08-29T02:18:00.000-04:00",
    "arrivalTime": "2021-08-29T05:56:00.000-07:00",
    "aircraft": {
      "model": "757",
      "passengerCapacity": {
        "total": 176,
        "main": 160,
        "first": 16
      },
      "speed": 380
    }
  },
  {
    "flightNumber": "3815",
    "origin": {
      "code": "PHL",
      "city": "Philadelphia",
      "timezone": "America/New_York",
      "location": {
        "latitude": 39.8729,
        "longitude": -75.2437
      }
    },
    "destination": {
      "code": "SAN",
      "city": "San Diego",
      "timezone": "America/Los_Angeles",
      "location": {
        "latitude": 32.7338,
        "longitude": -117.1933
      }
    },
    "distance": 2368,
    "duration": {
      "locale": "6h 1m",
      "hours": 6,
      "minutes": 1
    },
    "departureTime": "2021-08-29T03:48:00.000-04:00",
    "arrivalTime": "2021-08-29T06:49:00.000-07:00",
    "aircraft": {
      "model": "738",
      "passengerCapacity": {
        "total": 160,
        "main": 144,
        "first": 16
      },
      "speed": 400
    }
  },
  "..."
]


Malformed Request Response

'date' value (2017-08-299) is malformed; 'date' must use the following format: YYYY-MM-DD

Missing Date Response

'date' is a required parameter and must use the following format: YYYY-MM-DD

Testing

This project utilizes framework uses Facebook's Jest framework for testing.

Writing a test is as simple as creating a *.test.ts file in the ./src directory along with an associated describe() and it() function.

Simply run npm run test to run the existing test suite or use it to execute your own tests once you've created new ones.

Additional testing scripts:

  • test: runs all tests
  • test:changed: runs tests related to uncommited git changes only

Contributing

Interested in contributing to the project? Check out our Contributing Guidelines.

flight-engine's People

Contributors

spencerkaiser avatar adriennehl avatar dependabot[bot] avatar dre8597 avatar johnkahn avatar charliealbright avatar henryn098 avatar jasonveitch avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.