These endpoints require a hosted
apiKey. See Authentication to get one.Prerequisites
mta-jsinstalled (npm install mta-js)- An MTA API key set as
MTA_API_KEYin your environment
1
List routes for a picker
mta.routes.list() returns the route catalog. Pass the modes you care about, or omit for everything.2
Get the ordered stations on a subway route
mta.subway.routeStations() returns the route’s stop patterns. Pass a direction to order them in the rider’s direction of travel.3
Get the ordered stops on a bus route
mta.bus.routeStops() is the bus equivalent, returning ordered stops grouped by direction.4
Hydrate stop IDs you already have
When you have stored stop IDs (favorites, a saved trip), resolve them in one call with
mta.stops.byIds(). Each result keeps its requestedId and a found flag; set includeRoutes to attach the routes serving each stop.These guides use the SDK. For the raw REST endpoints, see Routes, Subway Route Stations, Bus Route Stops, and Stops by ID.