Git Product home page Git Product logo

mta-gtfs's Introduction

mta-gtfs

An NYC MTA API library

Install

npm install mta-gtfs --save

Usage

Library

var Mta = require('mta-gtfs');
var mta = new Mta({
  key: 'MY-MTA-API-KEY-HERE', // only needed for mta.schedule() method
  feed_id: 1                  // optional, default = 1
});
  • uses node-fetch to make http requests
  • returns Promise objects and makes use of native Promises (make sure you are using >= Node v0.12)

MTA

For feed information, see http://datamine.mta.info/list-of-feeds.

In order to use the MTA real-time APIs, you will need an MTA API key from here: http://datamine.mta.info/user/register.

Get subway stop info

Get ids, name, and lat/long for all subway stops.

mta.stop().then(function (result) {
  console.log(result);
}).catch(function (err) {
  console.log(err);
});

Get info for specific stop, given an id.

mta.stop(635).then(function (result) {
  console.log(result);
});

An array of ids may also be passed to this method.

The stop ids given here are used in mta.schedule().

Get MTA service status info

You can get ALL service types:

mta.status().then(function (result) {
  console.log(result);
});

Or, specify a specific service type (subway, bus, BT, LIRR, MetroNorth):

mta.status('subway').then(function (result) {
  console.log(result);
});

The API route this method hits is updated by the MTA every 60 seconds.

Get real-time subway schedule data

Only available for the routes found in this list.

Given a single subway stop id (or an array of stop ids) and an optional feedId, it gives schedule data for both northbound and southbound trains.

mta.schedule(635, 1).then(function (result) {
  console.log(result);
});

The API route this method hits is updated by the MTA every 30 seconds.

Tests

See test cases for more examples.

MTA_API_KEY='your-api-key-here' npm test

To do

mta-gtfs's People

Contributors

aamaliaa avatar chrismondok 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.