This API is a wrapper around the MTA's GTFS specification. You can use it to:
- Find the next trains coming to your station
- Get a JSON object mapping train lines to their corresponding MTA feed id's.
- Get a JSON object with relevant information for all MTA stops.
This is a project built by Mari and Patrick.
- Clone the repo
git clone https://github.com/mgalicer/train-times.git
cd train-times/
npm install
-
Register for an API key on the MTA's website
-
Add your API key to the script
touch .env
echo "MTA_KEY=MY_MTA_KEY" >> .env
-
If you also want bus data, register for an MTA BusTime Developer API Key on the MTA's Google form
-
After 5, add your API key to the script
touch .env
echo "MTA_BUS_KEY=MY_MTA_BUS_KEY" >> .env
- Add the port you want to use to develop locally
echo "PORT=3000" >> .env
- Run the API
npm start
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:
localhost:3000/next-train-times
localhost:3000/next-bus-times