-
Notifications
You must be signed in to change notification settings - Fork 3
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:
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"
},
...
]
Query:
http://server:port/api/nearby?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/nearby?lng=-77.10205078124999&lat=38.89938303308861&radius_m=804.5
Returns:
{
"services": [
{
"segments": [
3703,
2771,
2499,
...
],
"route": 320,
"destination": "East Falls Church Metro, Sycamore Street @ Bay A",
"stop: 11733,
"id": 149
},
...
],
"routes": [
{
"short_name": "53A",
"route_type": 3,
"agency": "Arlington Transit",
"long_name": "Ballston - Glebe - East Falls Church",
"id" 320,
"color": null
},
...
],
"segments": [
{
"id": 3703,
"line_encoded": "kullFtksuM{@XwCDuB[u@y@",
},
...
],
"stops": [
{
"has_predictions": true,
"location": {
"lat": 38.89753,
"lng": -77.108656,
},
"id": 11733,
"name": "Military Road, NB @ Old Dominion Drive, FS"
},
...
],
"coverage": true
}
Notes:
- Line segments are returned in encoded polyline format.
- The value of
"coverage"
is determined by distance to the closest transit stop, and can be configured in the application settings.
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"
}