Documentation Index
Fetch the complete documentation index at: https://mtaapi.dev/docs/llms.txt
Use this file to discover all available pages before exploring further.
The fastest way to use mta-js is the hosted API at mtaapi.dev. Pass
apiKey and you’re done — no BusTime key, no GTFS imports, no stop search setup.Self-host only when you need full control over the data path, want to deploy in an air-gapped environment, or have already invested in MTA developer credentials. Everything below is for that case.mta.subway.arrivals, mta.bus.arrivals, mta.bus.vehicles, mta.alerts.current, mta.stops.near) stay the same — only the constructor changes.
Direct-feed client
Pass abusTimeKey instead of an apiKey:
busTimeKey is only required for bus realtime endpoints (mta.bus.arrivals, mta.bus.vehicles) — request one from the MTA BusTime developer portal.
Adding stop and route metadata
Without the hosted API, mta-js has no built-in GTFS database, so stop and route names won’t resolve automatically. Pass a small in-memorystaticData seed to get richer local metadata for the stops you care about:
Constructor options
| Option | Type | Description | |
|---|---|---|---|
apiKey | string | Hosted mtaapi.dev API key. When set, requests go to https://www.mtaapi.dev and other realtime options are ignored. | |
apiBaseUrl | string | Override the hosted API base URL. Useful for tests, staging, or private deployments. Only applies with apiKey. | |
busTimeKey | string | MTA BusTime API key. Required only for bus realtime endpoints in direct-feed mode. | |
staticData | object | Optional in-memory seed of stops and routes for direct-feed mode. | |
staticDataMode | `‘subway' | 'bus’` | Which transit mode the staticData seed applies to. |
Framework integration
- Node.js
- Next.js
- Express