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.
mta-js is a unified JavaScript/TypeScript SDK that wraps MTA’s real-time feeds into one consistent, easy-to-use interface. Whether you’re building a transit tracker, a commute planner, or a live arrival board, mta-js gives you subway arrivals, bus vehicle positions, service alerts, and geolocation-based stop lookups—all through a single MTA client.
Get up and running
Install the package
Add
mta-js to your project using your preferred package manager.Using Next.js with Turbopack? Add
mta-js to transpilePackages. The SDK publishes TypeScript source, and this tells Next to compile it instead of treating node_modules/mta-js/index.ts as an unknown module type.next.config.mjs
Get your API key from mtaapi.dev
Get an API key from mtaapi.dev — our hosted MTA API. One key, all endpoints, no setup.
- Sign up at mtaapi.dev.
- Copy your API key from the dashboard.
- Add it to your project as an environment variable:
.env
Never commit your API key to version control. Store it in an environment variable and load it at runtime. See Authentication for more detail.
Initialize the client
Import With an
MTA and create a client instance by passing your apiKey.apiKey set, requests are routed to https://www.mtaapi.dev/api/v1 automatically. You only configure it once.What you can build
Subway arrivals
Real-time arrival times for any subway stop and route.
Bus tracking
Live vehicle positions for any bus route.
Service alerts
Delays, planned work, and service changes in real time.
Nearby stops
Find subway and bus stops near any latitude/longitude.
Trip direction
Resolve a rider’s destination into the right north/south direction.
API Reference
Full SDK method reference with parameters and response types.
Prefer to call MTA feeds directly instead of using the hosted API? See Direct MTA feeds and self-hosting.