iamtomhewitt / home-dashboard-train-manager

πŸš‚ A piggy back api of Huxley to get train timetables for my home dashboard.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Home Dashboard Train Manager

A Node Express app for piggy backing the api of Huxley to get train timetables for my home dashboard. This project basically just reformats the JSON response from Huxley into a more basic model for my dashboard.

πŸ™Œ Big thanks to James Singleton for making Huxley!

Pipeline

  • Travis tests the repo using npm test, which runs mocha 'tests/**/*.js' --exit
  • Once the tests pass, Heroku deploys the app.
  • When the app is deployed, you can make requests to it here.
  • You will need an API key to make requests. You can get one here.

Endpoints

/ (GET)

The root endpoint, returning information about the app.

Responses

  • 200 success
{
    "status": "πŸš‚ SERVER OK",
    "version": "1.0.0",
    "endpoints": [
        {
            "path": "/",
            "methods": [
                "GET"
            ]
        },
        {
            "path": "/departures",
            "methods": [
                "GET"
            ]
        },
        {
            "path": "/arrivals",
            "methods": [
                "GET"
            ]
        }
    ]
}

/departures (GET)

  • Returns all the departures for a given station. You can find the station codes here.
  • Query parameters:
    • stationCode=<code>
    • numberOfResults=<number>
    • apiKey=<your api key>

Responses

  • 200 success
{
    "status": 200,
    "station": "Leeds",
    "stationCode": "LDS",
    "timetable": [
        {
            "destination": "Doncaster",
            "scheduledDepartTime": "2020-01-14T12:21:00.000Z",
            "actualDepartTime": "2020-01-14T12:21:00.000Z",
            "platform": "2C",
            "cancelled": false,
            "busReplacement": false
        },
        {
            "destination": "Bradford Forster Square",
            "scheduledDepartTime": "2020-01-14T12:42:00.000Z",
            "actualDepartTime": "2020-01-14T12:42:00.000Z",
            "platform": "3B",
            "cancelled": false,
            "busReplacement": false
        },
        {
            "destination": "London Kings Cross",
            "scheduledDepartTime": "2020-01-14T12:45:00.000Z",
            "actualDepartTime": "2020-01-14T12:45:00.000Z",
            "platform": "9",
            "cancelled": false,
            "busReplacement": false
        },
        {
            "destination": "Manchester Airport",
            "scheduledDepartTime": "2020-01-14T12:45:00.000Z",
            "actualDepartTime": "2020-01-14T12:45:00.000Z",
            "platform": "16A",
            "cancelled": false,
            "busReplacement": false
        },
        {
            "destination": "Leeds Bradford Airport (Bus)",
            "scheduledDepartTime": "2020-01-14T13:09:00.000Z",
            "actualDepartTime": "2020-01-14T13:09:00.000Z",
            "platform": null,
            "cancelled": false,
            "busReplacement": true
        }
    ]
}
  • 400 if there was a problem with query parameters
{
    "status": 400,
    "message": "There are missing query parameters"
}
  • 500 error
{
    "status": 500,
    "message": "<error message>"
}

/arrivals (GET)

  • Returns all the arrivals for a given station. You can find the station codes here.
  • Query parameters:
    • stationCode=<code>
    • numberOfResults=<number>
    • apiKey=<your api key>

Responses

  • 200 success
{
    "status": 200,
    "station": "Leeds",
    "stationCode": "LDS",
    "timetable": [
        {
            "origin": "London Kings Cross",
            "scheduledArrivalTime": "2020-01-14T12:48:00.000Z",
            "actualArrivalTime": "2020-01-14T12:48:00.000Z",
            "platform": "6",
            "cancelled": false,
            "busReplacement": false
        },
        {
            "origin": "Liverpool Lime Street",
            "scheduledArrivalTime": "2020-01-14T12:49:00.000Z",
            "actualArrivalTime": "2020-01-14T12:49:00.000Z",
            "platform": "11D",
            "cancelled": false,
            "busReplacement": false
        },
        {
            "origin": "Halifax",
            "scheduledArrivalTime": "2020-01-14T12:52:00.000Z",
            "actualArrivalTime": "2020-01-14T12:52:00.000Z",
            "platform": "8B",
            "cancelled": false,
            "busReplacement": false
        },
        {
            "origin": "Knaresborough",
            "scheduledArrivalTime": "2020-01-14T12:53:00.000Z",
            "actualArrivalTime": "2020-01-14T12:53:00.000Z",
            "platform": null,
            "cancelled": false,
            "busReplacement": false
        },
        {
            "destination": "Leeds",
            "scheduledArrivalTime": "2020-01-14T13:05:00.000Z",
            "actualArrivalTime": "2020-01-14T13:05:00.000Z",
            "platform": null,
            "cancelled": false,
            "busReplacement": true
        }
    ]
}
  • 400 if there was a problem with query parameters
{
    "status": 400,
    "message": "There are missing query parameters"
}
  • 500 error
{
    "status": 500,
    "message": "<error message>"
}

About

πŸš‚ A piggy back api of Huxley to get train timetables for my home dashboard.


Languages

Language:JavaScript 100.0%