Skip to main content
This guide shows you how to fetch live bus vehicle positions for a specific route. You will call mta.bus.vehicles() with a route ID, extract latitude and longitude from each vehicle, and display them in a list or on a map.
1

Find your route ID

MTA bus route IDs combine a borough prefix with the route number. The prefix identifies which borough the route primarily serves.Some common examples:Pass the route ID as a string, using the exact casing shown above (e.g., 'Bx12', not 'BX12').
2

Call mta.bus.vehicles()

Initialize the MTA client and call mta.bus.vehicles() with the route you want to track.
3

Process vehicle positions

The response contains a vehicles array. Map over it to extract each bus’s position and relevant metadata.
Example response:
4

Display on a map or list

Use the lat and lon values to place markers on a mapping library of your choice. The bearing field gives the vehicle’s heading in degrees (0 = north, 90 = east), which you can use to rotate a bus icon.
For a simple text list, sort vehicles by proximity to a reference point using the Haversine formula or a geospatial library.

Complete example

Occupancy status

The occupancyStatus field reflects how full a bus is, based on passenger load data reported by the vehicle. The possible values follow the GTFS-RT occupancy standard: Not all vehicles report occupancy data. When the field is absent or null, omit it from your UI rather than showing a default value.
Combine mta.bus.vehicles() with mta.stops.near() to show the upcoming stops along a vehicle’s path. Fetch nearby stops using the bus’s current lat and lon, then pass the closest stopId into mta.subway.arrivals() or render the stop list alongside the bus position.