This guide shows you how to fetch live bus vehicle positions for a specific route. You will callDocumentation 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.bus.vehicles() with a route ID, extract latitude and longitude from each vehicle, and display them in a list or on a map.
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.,
| Prefix | Borough |
|---|---|
B | Brooklyn |
M | Manhattan |
Q | Queens |
Bx | The Bronx |
S | Staten Island |
| Route ID | Route |
|---|---|
B63 | 5th Ave / Atlantic Ave, Brooklyn |
M15 | 1st / 2nd Ave, Manhattan |
Q58 | Myrtle Ave, Queens |
Bx12 | Fordham Road, The Bronx |
'Bx12', not 'BX12').Call mta.bus.vehicles()
Initialize the
MTA client and call mta.bus.vehicles() with the route you want to track.Process vehicle positions
The response contains a Example response:
vehicles array. Map over it to extract each bus’s position and relevant metadata.Display on a map or list
Use the For a simple text list, sort vehicles by proximity to a reference point using the Haversine formula or a geospatial library.
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.Complete example
Occupancy status
TheoccupancyStatus 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:
| Value | Meaning |
|---|---|
EMPTY | No passengers on board |
MANY_SEATS_AVAILABLE | Plenty of open seats |
FEW_SEATS_AVAILABLE | Seats limited |
STANDING_ROOM_ONLY | No seats, standing room available |
CRUSHED_STANDING_ROOM_ONLY | Very crowded |
FULL | Bus is not accepting passengers |
NOT_ACCEPTING_PASSENGERS | Out of service or not boarding |
null, omit it from your UI rather than showing a default value.