Skip to content

L8D/train-times

 
 

Repository files navigation

Train Times API

This API is a wrapper around the MTA's GTFS specification. You can use it to:

  1. Find the next trains coming to your station
  2. Get a JSON object mapping train lines to their corresponding MTA feed id's.
  3. Get a JSON object with relevant information for all MTA stops.

This is a project built by Mari and Patrick.

Set up the project

  1. Clone the repo
git clone https://github.com/mgalicer/train-times.git
  1. Install dependencies npm NodeJS
cd train-times/
npm install
  1. Register for an API key on the MTA's website

  2. Add your API key to the script

touch .env
echo "MTA_KEY=MY_MTA_KEY" >> .env
  1. If you also want bus data, register for an MTA BusTime Developer API Key on the MTA's Google form

  2. After 5, add your API key to the script

touch .env
echo "MTA_BUS_KEY=MY_MTA_BUS_KEY" >> .env
  1. Add the port you want to use to develop locally
echo "PORT=3000" >> .env
  1. Run the API
npm start

Endpoints

Both train and bus JSON objects are formatted as below:

[{
	time: 8,
	line: "B25",
	station: "FULTON ST/JAY ST",
	direction: "W"
 },
...]

We made it easy for you so it returns all train/bus data relevant to RC. You can access them through the following endpoints:

Get an array of JSON objects with 🚋 data

localhost:3000/next-train-times

Get an array of JSON objects with 🚌 data

localhost:3000/next-bus-times

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 71.1%
  • C++ 16.0%
  • CSS 6.1%
  • HTML 4.3%
  • Python 2.5%