Skip to content
chosak edited this page Jan 27, 2012 · 5 revisions

Transit Near Me exposes a JSON-based API that allows for querying of transit options near a location along with real-time predictions when available. API calls include:

Stops near a location

Query:

http://server:port/api/stops?lng=lng&lat=lat&radius_m=radius_m

Parameters:

  • lng: longitude, in degrees, of query location
  • lat: latitude, in degrees, of query location
  • radius_m: radius, in meters of search area

Example:

http://transitnearme.com/api/stops?lng=-77.06377029418945&lat=38.911964939741424&radius_m=804.5

Returns:

[
    {
        "has_predictions": false,
        "location": {
            "lat": 38.909406,
            "lng": -77.057999
        },
        "id": 6405,
        "name": "29TH ST & PENNSYLVANIA AVE NW"
    },
    ...
]

Predictions for a stop

Query:

http://server:port/api/stop/id

Parameters:

  • id: Stop id, as returned from one of above queries

Example:

http://transitnearme.com/api/stop/8827

Returns:

{
    "has_predictions": true,
    "location": {
        "lat": 38.911579,
        "lng": -77.069292
    },
    "predictions": [
        {
            "route": "D2",
            "destination": "East to Dupont Circle",
            "waits": [
                15,
                38,
                59,
                80
            ]
        },
        ...
    ]
    "id": 8827,
    "name": "35TH ST NW & WINFIELD LA NW"
}
Clone this wiki locally