mta.subway.arrivalBoard() and mta.bus.arrivalBoard() return the closest stations to a coordinate with their upcoming arrivals already attached and grouped — perfect for a lobby screen, a “near me” tab, or a kiosk.
Arrival boards 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
Fetch the subway board for a location
Pass a
lat / lon and how big you want the board. limitStations caps how many stations come back (max 20); limitArrivals caps arrivals per direction (max 10).2
Render each station and its directions
Each entry has a
station, its distanceMeters, and a directions array. Each direction bundles a direction, an optional headsign, and that direction’s arrivals.3
Do the same for buses
mta.bus.arrivalBoard() is the bus counterpart. It uses limitStops instead of limitStations, and groups each stop’s arrivals by route (with an optional headsign) rather than by compass direction.Prefer the raw REST shape? See the Subway Arrival Board and Bus Arrival Board API reference pages.