REST API - Routes

Routes

The REST API routes endpoint provides a fast and flexible way to browse routes and to visualize their representative geometries.

When visualizing many routes over a large region, consider using Transitland's vector tiles instead of the REST API.

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

ParameterTypeDescriptionExample
idinteger
0 ... unlimited
Search for a specific internal ID
route_keystring

Route lookup key; can be an integer ID, a '<feed onestop_id>:<gtfs route_id>' key, or a Onestop ID
afterinteger

Return records past this record ID
limitinteger
0 ... 100
Maximum number of records to returnlimit=1
format enum
jsongeojsonpng
Response formatformat=png
include_alertsstring enum
truefalse
Include alerts from GTFS Realtime feeds
searchstring

Full text searchsearch=daly+city
onestop_idstring

Search for a specific Onestop IDonestop_id=r-9q9j-local
route_idstring

Search for records with this GTFS route_idroute_id=Bu-130
route_typeinteger

Search for routes with this GTFS route (vehicle) typeroute_type=1
operator_onestop_idstring

Search for records by operator OnestopIDoperator_onestop_id=...
include_geometrystring enum
truefalse
Include route geometryinclude_geometry=true
feed_version_sha1string

Search for records in this feed versionfeed_version_sha1=041ffeec...
feed_onestop_idstring

Search for records in this feedfeed_onestop_id=f-9q9-caltrain
radiusnumber
0 ... 10000
Search for routes geographically, based on stops at this location; radius is in meters, requires lon and latlon=-122&lat=37&radius=1000
latnumber
-90 ... 90
Latitude
lonnumber
-180 ... 180
Longitude
bboxstring

Geographic search using a bounding box, with coordinates in (min_lon, min_lat, max_lon, max_lat) order as a comma separated stringbbox=-122.269,37.807,-122.267,37.808
license_commercial_use_allowed enum
yesnounknownexclude_no
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
yesnounknownexclude_no
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
yesnounknownexclude_no
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
yesnounknownexclude_no
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
yesnounknownexclude_no
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
id
(integer)
Unique integer ID
onestop_id
(string)
Onestop ID for this route, if available

Exampler-dr72-1

route_id
(string)
GTFS route_id

Exampleorange

route_type
(integer)
GTFS route_type

Example3

route_short_name
(string)
GTFS route_short_name

ExampleOrange

route_long_name
(string)
GTFS route_long_name

ExampleRichmond - Warm Springs

route_color
(color)
GTFS route_color

Example#ff00bb

route_text_color
(color)
GTFS route_text_color

Example#000000

route_sort_order
(integer)
GTFS route_sort_order
continuous_pickup
(integer)
GTFS continuous_pickup
continuous_drop_off
(integer)
GTFS continuous_drop_off
agency
(object)
A subset of fields for this route's agency
feed_version
(object)
A subset of fields for this route's feed version
route_stops
(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)
Geometry in GeoJSON format
type
(string)
GeoJSON geometry type

ExampleLineString

coordinates
(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 ] ]