Giter Site home page Giter Site logo

train-times's Introduction

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. Add the port you want to use to develop locally
echo "PORT=3000" >> .env
  1. Run the API
npm start

Example endpoint:

Find the next train times for a given stop

Say we're looking for the next A train times going south at Jay St. MetroTech. You can either go to http://localhost:3000/stops and look for your stop, or check out the stops.csv. At Jay St., the stop id is A41.

Next, pass the train line, stop id, and direction into the API:
localhost:3000/next-train-times/A/A41/S

You should receive an array with the upcoming train arrival times.

[8,14,22,32,45,55,65,75]
Get a JSON object with select information for all stops

localhost:3000/stops

Get a JSON object with feed ids for all train lines

localhost:3000/line-to-feed-ids The returned object has keys that are train lines, ex C, and values that are an MTA feed ID, ex 26

train-times's People

Contributors

l8d avatar merklebros avatar mgalicer 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.