Skip to main content
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

1

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
2

Get your API key from mtaapi.dev

Get an API key from mtaapi.dev — our hosted MTA API. One key, all endpoints, no setup.
  1. Sign up at mtaapi.dev.
  2. Copy your API key from the dashboard.
  3. 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.
3

Initialize the client

Import MTA and create a client instance by passing your apiKey.
With an apiKey set, requests are routed to https://www.mtaapi.dev/api/v1 automatically. You only configure it once.
4

Fetch real-time data

Call mta.subway.arrivals() with a stop ID and route to get real-time arrival predictions.
A successful response is an array of Arrival objects:

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.