Skip to main content
This guide shows you how to find MTA stops near a geographic coordinate using mta.stops.near(). You will obtain a latitude and longitude, query for nearby stops across one or more transit modes, and use the results to build features like “stops near me” or a stop picker for arrival lookups.
1

Obtain the user's coordinates

You need a latitude and longitude to query nearby stops. In a browser, use the Geolocation API to get the user’s current position.
For server-side code or testing, use hardcoded coordinates:
2

Call mta.stops.near()

Pass lat, lon, and a modes array to mta.stops.near(). The modes array accepts 'subway', 'bus', or both.
Example response:
3

Process and display results sorted by distance

The response is typically already sorted by distanceMeters. Map over the stops to build a display list.
4

Link a stop to arrivals

Once you have a stopId, you can pass it directly to mta.subway.arrivals() to fetch real-time arrivals for that stop. This lets you build a “tap a stop, see arrivals” flow.

Complete example

Route-aware lookups

When you already know which route the user cares about, pass a route to mta.stops.near() so the response only includes stops served by that route. Combine it with radiusMeters and limit to scope the search precisely.
This is useful for “where do I catch the L train from here?” flows: pass route: 'L' and modes: ['subway'] to skip every other line in the response.

Filtering by mode

Pass only the modes you need to keep the response focused. This reduces payload size and simplifies the results you render.
If your app shows a mode switcher (e.g., subway / bus tabs), call mta.stops.near() with the active mode rather than fetching all modes and filtering client-side.

Using results with arrivals

You can chain stops.near() directly into subway.arrivals() to create a fully location-aware arrivals lookup.
The MTA subway system covers the five boroughs, but stops are clustered in Manhattan and dense areas of Brooklyn and Queens. If you query for stops in a sparse area or far from a transit hub, the nearest stop could be over a kilometer away. Consider setting a maximum distance threshold in your UI and showing a message like “No stops within 800m” rather than silently returning a very distant result.