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
Framework integration
- Node.js
- Next.js
- Express