All Projects → jonthornton → Mtapi

jonthornton / Mtapi

JSON proxy server for the MTA's realtime New York City subway feed

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Mtapi

Transit
This Python module polls transit agencies for real-time bus arrival predictions.
Stars: ✭ 6 (-97.09%)
Mutual labels:  transit
Wotan
Automagically remove trends from time-series data
Stars: ✭ 86 (-58.25%)
Mutual labels:  transit
Rrrr
RRRR rapid real-time routing
Stars: ✭ 134 (-34.95%)
Mutual labels:  transit
Fapanels
FAPanels - Swift
Stars: ✭ 850 (+312.62%)
Mutual labels:  transit
Tidytransit
R package for working with the General Transit Feed Specification (GTFS)
Stars: ✭ 84 (-59.22%)
Mutual labels:  transit
Peartree
peartree: A library for converting transit data into a directed graph for sketch network analysis.
Stars: ✭ 116 (-43.69%)
Mutual labels:  transit
Transit
Easy file uploading and downloading for Laravel 5.
Stars: ✭ 5 (-97.57%)
Mutual labels:  transit
Piknik
Copy/paste anything over the network.
Stars: ✭ 2,221 (+978.16%)
Mutual labels:  transit
Nextbussg
An app to show everything bus related in Singapore, including arrival times and a directory
Stars: ✭ 86 (-58.25%)
Mutual labels:  transit
Hafas Client
JavaScript client for HAFAS public transport APIs.
Stars: ✭ 125 (-39.32%)
Mutual labels:  transit
Mobility Explorer
Understand transportation networks around the world using Transitland open data and Valhalla routing engine APIs
Stars: ✭ 31 (-84.95%)
Mutual labels:  transit
Vbb Cli
A CLI for Berlin & Brandenburg public transport.
Stars: ✭ 70 (-66.02%)
Mutual labels:  transit
Gtfs To Html
Build human readable transit timetables as HTML or PDF from GTFS.
Stars: ✭ 119 (-42.23%)
Mutual labels:  transit
European Transport Modules
[DISCONTINUED in favour of public-transport-operators] Collection of european transport JavaScript modules.
Stars: ✭ 9 (-95.63%)
Mutual labels:  transit
R5
Routing engine for multimodal (transit/bike/walk/car) networks with a particular focus on public transit.
Stars: ✭ 153 (-25.73%)
Mutual labels:  transit
Loader
deploy
Stars: ✭ 6 (-97.09%)
Mutual labels:  transit
Transitland Datastore
Transitland's centralized web service API for both querying and editing aggregated transit data from around the world
Stars: ✭ 101 (-50.97%)
Mutual labels:  transit
Peering Manager
Peering sessions management tool
Stars: ✭ 189 (-8.25%)
Mutual labels:  transit
Onebusaway Application Modules
The core OneBusAway application suite.
Stars: ✭ 174 (-15.53%)
Mutual labels:  transit
Sente
Realtime web comms for Clojure/Script
Stars: ✭ 1,626 (+689.32%)
Mutual labels:  transit

MTA Realtime API JSON Proxy

MTAPI is a small HTTP server that converts the MTA's realtime subway feed from Protocol Buffers/GTFS to JSON. The app also adds caching and makes it possible to retrieve information by location and train line.

Active Development

This project is under active development and any part of the API may change. Feedback is very welcome.

Running the server

MTAPI is a Flask app designed to run under Python 3.3+.

  1. Create a settings.cfg file. A sample is provided as settings.cfg.sample.
  2. Set up your environment and install dependencies.
    $ python3 -m venv .venv
    $ source .venv/bin/activate
    $ python3 -m pip install -r requirements.txt
  3. Run the server
    $ python app.py

If your configuration is named something other than settings.cfg, set the MTAPI_SETTINGS env variable to your configuration path.

This app makes use of Python threads. If running under uWSGI include the --enable-threads flag.

Endpoints

Endpoints to retrieve train data and sample input and output are listed here.

Settings

  • MTA_KEY (required)
    The API key provided at hhttps://api.mta.info/#/signup default: None

  • STATIONS_FILE (required)
    Path to the JSON file containing station information. See Generating a Stations File for more info.
    default: None

  • CROSS_ORIGIN
    Add CORS headers to the HTTP output.
    default: "*" when in debug mode, None otherwise

  • MAX_TRAINS
    Limits the number of trains that will be listed for each station.
    default: 10

  • MAX_MINUTES
    Limits how far in advance train information will be listed.
    default: 30

  • CACHE_SECONDS
    How frequently the app will request fresh data from the MTA API.
    default: 60

  • THREADED
    Enable background data refresh. This will prevent requests from hanging while new data is retreived from the MTA API.
    default: True

  • DEBUG
    Standard Flask option. Will enabled enhanced logging and wildcard CORS headers.
    default: False

Generating a Stations File

The MTA provides several static data files about the subway system but none include canonical information about each station. MTAPI includes a script that will parse the stops.txt and transfers.txt datasets provided by the MTA and attempt to group the different train stops into subway stations. MTAPI will use this JSON file for station names and locations. The grouping is not perfect and editing the resulting files is encouraged.

Usage:

$ python make_stations_csv.py stops.txt transfers.txt > stations.csv
# edit groupings in stations.csv
$ python make_stations_json.py stations.csv > stations.json
# edit names in stations.json

Help

Submit a GitHub Issues request.

Projects

Here are some projects that use MTAPI.

License

The project is made available under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].