- Notifications
You must be signed in to change notification settings - Fork96
jonthornton/MTAPI
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
MTAPI is a small HTTP server that converts theMTA's realtime subway feed fromProtocol Buffers/GTFS to JSON. The app also adds caching and makes it possible to retrieve information by location and train line.
This project is under active development and any part of the API may change. Feedback is very welcome.
MTAPI is a Flask app designed to run under Python 3.3+.
- Create a
settings.cfg
file. A sample is provided assettings.cfg.sample
. - Set up your environment and install dependencies.
$ python3 -m venv .venv
$ source .venv/bin/activate
$ python3 -m pip install -r requirements.txt
- Run the server
$ python app.py
If your configuration is named something other thansettings.cfg
, set theMTAPI_SETTINGS
env variable to your configuration path.
This app makes use of Python threads. If running under uWSGI include the --enable-threads flag.
Endpoints to retrieve train data and sample input and output are listed here.
MTA_KEY (required)
The API key provided at hhttps://api.mta.info/#/signupdefault: NoneSTATIONS_FILE (required)
Path to the JSON file containing station information. SeeGenerating a Stations File for more info.
default: NoneCROSS_ORIGIN
AddCORS headers to the HTTP output.
default: "*" when in debug mode, None otherwiseMAX_TRAINS
Limits the number of trains that will be listed for each station.
default: 10MAX_MINUTES
Limits how far in advance train information will be listed.
default: 30CACHE_SECONDS
How frequently the app will request fresh data from the MTA API.
default: 60THREADED
Enable background data refresh. This will prevent requests from hanging while new data is retreived from the MTA API.
default: TrueDEBUG
Standard Flask option. Will enabled enhanced logging and wildcard CORS headers.
default: False
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 thestops.txt
andtransfers.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
Submit aGitHub Issues request.
Here are some projects that use MTAPI.
The project is made available under the MIT license.
About
JSON proxy server for the MTA's realtime New York City subway feed
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors6
Uh oh!
There was an error while loading.Please reload this page.