Skip to content

Latest commit

 

History

History
440 lines (364 loc) · 10.8 KB

README.md

File metadata and controls

440 lines (364 loc) · 10.8 KB

brampton-transit-api Build Status

An unofficial API for retrieving live Brampton Transit bus times.

Live at http://transit.kshvmdn.com (might take a few seconds to spin up, it's running on Heroku's free tier).

Data source: Brampton Transit Next Ride (desktop, mobile).


Usage

Endpoints

  • /routes

    • Retrieve a list of routes. Optionally filter by route code or name.

    • Optional query parameters:

      • code - Route code
      • name - Route name (case insensitive)
    • Examples:

      • /routes

        {
          "data": [
            {
              "route": "1",
              "route_name": "Queen, West"
            },
            {
              "route": "1",
              "route_name": "Queen, East"
            },
            ...
          ],
          "status": {
            "code": 200,
            "message": "OK"
          }
        }
      • /routes?code=2

        {
          "data": [
            {
              "route": "2",
              "route_name": "Main, South"
            },
            {
              "route": "2",
              "route_name": "Main, North"
            }
          ],
          "status": {
            "code": 200,
            "message": "OK"
          }
        }
      • /routes?name=bramalea

        {
          "data": [
            {
              "route": "15",
              "route_name": "Bramalea, South"
            },
            {
              "route": "15",
              "route_name": "Bramalea, North"
            },
            {
              "route": "92",
              "route_name": "Bramalea GO Shuttle, South"
            },
            {
              "route": "92",
              "route_name": "Bramalea GO Shuttle, North"
            }
          ],
          "status": {
            "code": 200,
            "message": "OK"
          }
        }
  • /stops

    • Retrieve a list of all stops separated by route.

    • Examples:

      • /stops

        {
          "data": [
            {
              "route_id": "1004",
              "route": "1",
              "route_name": "Queen, West",
              "stops": [
                {
                  "stop": "4035",
                  "stop_name": "Highway 50 - Zum Queen Station Stop"
                },
                {
                  "stop": "2543",
                  "stop_name": "The Gore Rd n/of Queen St E"
                },
                ...
              ]
            },
            {
              "route_id": "1001",
              "route": "1",
              "route_name": "Queen, East",
              "stops": [
                {
                  "stop": "2315",
                  "stop_name": "Mount Pleasant GO Station - Route 1"
                },
                {
                  "stop": "2807",
                  "stop_name": "Bovaird - Zum Queen West Station St"
                },
                ...
              ]
            },
            ...
          ],
          "status": {
            "code": 200,
            "message": "OK"
          }
        }
  • /stops/route

    • Retrieve a list of stops filtered by route. If you wish to retrieve all stops, use /stops instead.

    • Query parameters:

      • code - Route code
      • name - Route name (case insensitive)
    • Examples:

      • /stops/route

        {
          "error": {
            "code": 400,
            "message": "Expected at least one parameter."
          }
        }
      • /stops/route?name=torbram

        {
          "data": [
            {
              "route_id": "14003",
              "route": "14",
              "route_name": "Torbram, South",
              "stops": [
                {
                  "stop": "3498",
                  "stop_name": "Torbram Rd s/of Father Tobin Rd"
                },
                {
                  "stop": "3499",
                  "stop_name": "Torbram Rd at Australia Dr"
                },
                ...
              ]
            },
            {
              "route_id": "14002",
              "route": "14",
              "route_name": "Torbram, North",
              "stops": [
                {
                  "stop": "6157",
                  "stop_name": "Westwood Mall Terminal Route 14 Sto"
                },
                {
                  "stop": "6004",
                  "stop_name": "Goreway Rd s/of Morning Star Dr"
                },
                ...
              ]
            }
          ],
          "status": {
            "code": 200,
            "message": "OK"
          }
        }
  • /stops/stop

    • Retrieve a list of stops filtered by stop. If you wish to retrieve all stops, use /stops instead.

    • Query parameters:

      • code - Stop code
      • name - Stop name (case insensitive)
    • Examples:

      • /stops/stop

        {
          "error": {
            "code": 400,
            "message": "Expected at least one parameter."
          }
        }
      • /stops/stop?code=4035

        {
          "data": [
            {
              "route_id": "1004",
              "route": "1",
              "route_name": "Queen, West",
              "stops": [
                {
                  "stop": "4035",
                  "stop_name": "Highway 50 - Zum Queen Station Stop"
                }
              ]
            },
            {
              "route_id": "1001",
              "route": "1",
              "route_name": "Queen, East",
              "stops": [
                {
                  "stop": "4035",
                  "stop_name": "Highway 50 - Zum Queen Station Stop"
                }
              ]
            },
            ...
          ],
          "status": {
            "code": 200,
            "message": "OK"
          }
        }
  • /search/stops/:query

    • Retrieve a list of stops matching the provided query.

    • Examples:

      • /search/stops/bramalea

        {
          "data": [
            {
              "stop": "1113",
              "stop_name": "Bramalea - Zum Steeles Station Stop"
            },
            {
              "stop": "1114",
              "stop_name": "Steeles Ave E at Bramalea GO Statio"
            },
            {
              "stop": "1150",
              "stop_name": "Kensington Rd opp Bramalea Medical"
            },
            ...
          ],
          "status": {
            "code": 200,
            "message": "OK"
          }
        }
  • /stop/:stop

    • Retrieve a list of upcoming busses at the given stop.

    • Examples:

      • /stop/1113

        {
          "data": {
            "stop": "1113",
            "stop_name": "Bramalea - Zum Steeles Station Stop",
            "routes": [
              {
                "route": "511",
                "direction": "Zum Steeles WB",
                "eta": "07:26 PM"
              },
              {
                "route": "11",
                "direction": "Steeles WB-11A",
                "eta": "07:33 PM"
              },
              ...
            ]
          },
          "status": {
            "code": 200,
            "message": "OK"
          }
        }
      • /stop/2000

        {
          "data": {
            "stop": "2000",
            "stop_name": "Trinity Common Terminal Route 33/23",
            "routes": [
              {
                "route": "23",
                "direction": "Sandalwood EB",
                "eta": "Due"
              },
              {
                "route": "23",
                "direction": "Sandalwood EB",
                "eta": "07:42 PM"
              },
              ...
            ]
          },
          "status": {
            "code": 200,
            "message": "OK"
          }
        }

Hosting / running

Requirements

Installation

  • Clone repository.

    $ git clone https://github.com/kshvmdn/brampton-transit-api.git brampton-transit-api && cd $_
  • Install npm dependencies.

    $ npm install
  • Start Redis. Use --daemonize yes to run server in background.

    $ redis-server
  • Start the application server.

    $ PORT=<port> HOST=<host> REDIS_URL=<redis_url> NODE_ENV=<node_env> npm start # use start:dev to watch for changes

Running with Docker Compose

  • Requirements:

  • Clone repository.

    $ cd docker
  • Build containers.

    $ docker-compose build
  • Start containers. Add -d to run in detached mode (i.e. in the background).

    $ docker-compose up

Contribute

This project is completely open source, feel free to open an issue or submit a PR. Refer to the self-hosting guide to get started.

Before submitting a PR, please ensure your changes comply with the Standard style guide for JavaScript code.

$ npm run test:lint

License

MIT © Kashav Madan.