Contents
REST API - Routes
Routes
The REST API routes endpoint provides a fast and flexible way to browse routes and to visualize their representative geometries.
Request overview
The routes API provides optional flags for including or disincluding certain response sections; this may be useful for optimizing the speed and size of requests. The API also provides png
as a format option, which returns a PNG format image containing a simple static map of the route and stops.
Geographic queries require all three parameters of lat
, lon
, and radius
to be specified. The maximum radius is 10km.
The route API returns "active" feed versions unless requesting a specific feed version.
Route API results are based on this GraphQL query.
Request parameters
GET/api/v2/rest/routes Routes — Search for routes
GET/api/v2/rest/routes.{format} — Request routes in specified format
GET/api/v2/rest/routes/{route_key} — Request a route
GET/api/v2/rest/routes/{route_key}.{format} — Request a route in a specified format
Parameter | Type | Description | Example |
---|---|---|---|
id | integer 0 ... unlimited | Search for a specific internal ID | |
route_key | string | Route lookup key; can be an integer ID, a '<feed onestop_id>:<gtfs route_id>' key, or a Onestop ID | |
after | integer | Return records past this record ID | |
limit | integer 0 ... 100 | Maximum number of records to return | limit=1 |
format | enum | Response format | format=png |
include_alerts | string enum | Include alerts from GTFS Realtime feeds | |
search | string | Full text search | search=daly+city |
onestop_id | string | Search for a specific Onestop ID | onestop_id=r-9q9j-local |
route_id | string | Search for records with this GTFS route_id | route_id=Bu-130 |
route_type | integer | Search for routes with this GTFS route (vehicle) type | route_type=1 |
operator_onestop_id | string | Search for records by operator OnestopID | operator_onestop_id=... |
include_geometry | string enum | Include route geometry | include_geometry=true |
feed_version_sha1 | string | Search for records in this feed version | feed_version_sha1=041ffeec... |
feed_onestop_id | string | Search for records in this feed | feed_onestop_id=f-9q9-caltrain |
radius | number 0 ... 10000 | Search for routes geographically, based on stops at this location; radius is in meters, requires lon and lat | lon=-122&lat=37&radius=1000 |
lat | number -90 ... 90 | Latitude | |
lon | number -180 ... 180 | Longitude | |
bbox | string | Geographic search using a bounding box, with coordinates in (min_lon, min_lat, max_lon, max_lat) order as a comma separated string | bbox=-122.269,37.807,-122.267,37.808 |
license_commercial_use_allowed | enum | Filter entities by feed license 'commercial_use_allowed' value. Please see Source Feed concept for details on license values. 'exclude_no' is equivalent to 'yes' and 'unknown'. | |
license_share_alike_optional | enum | Filter entities by feed license 'share_alike_optional' value. Please see Source Feed concept for details on license values. 'exclude_no' is equivalent to 'yes' and 'unknown'. | |
license_create_derived_product | enum | Filter entities by feed license 'create_derived_product' value. Please see Source Feed concept for details on license values. 'exclude_no' is equivalent to 'yes' and 'unknown'. | |
license_redistribution_allowed | enum | Filter entities by feed license 'redistribution_allowed' value. Please see Source Feed concept for details on license values. 'exclude_no' is equivalent to 'yes' and 'unknown'. | |
license_use_without_attribution | enum | Filter entities by feed license 'use_without_attribution' value. Please see Source Feed concept for details on license values. 'exclude_no' is equivalent to 'yes' and 'unknown'. |
Response format
Array of objects
Description Route entity
Reference GTFS specification for routes.txt
id
(integer)
(integer)
Unique integer ID
onestop_id
(string)
(string)
Onestop ID for this route, if available
Exampler-dr72-1
route_id
(string)
(string)
GTFS route_id
Exampleorange
route_type
(integer)
(integer)
GTFS route_type
Example3
route_short_name
(string)
(string)
GTFS route_short_name
ExampleOrange
route_long_name
(string)
(string)
GTFS route_long_name
ExampleRichmond - Warm Springs
route_color
(color)
(color)
GTFS route_color
Example#ff00bb
route_text_color
(color)
(color)
GTFS route_text_color
Example#000000
route_sort_order
(integer)
(integer)
GTFS route_sort_order
continuous_pickup
(integer)
(integer)
GTFS continuous_pickup
continuous_drop_off
(integer)
(integer)
GTFS continuous_drop_off
agency
(object)
(object)
A subset of fields for this route's agency
feed_version
(object)
(object)
A subset of fields for this route's feed version
route_stops
(object array)
(object array)
An array of all stops visited by this route. This field is only populated when requesting a single route.
stop
()
()
A subset of fields for this stop visited by this route
geometry
(object)
(object)
Geometry in GeoJSON format
type
(string)
(string)
GeoJSON geometry type
ExampleLineString
coordinates
(number array)
(number array)
An array of coordinates; may be nested arrays if geometry is Polygon or MultiLineString
Example[ [ -122.496, 37.778 ], [ -122.425, 37.786 ] ]