REST API - Routes

Routes

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

When visualizing many routes over a large region, consider using Transitland's 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" unless requesting a specific feed version.

Route API results are based on this GraphQL query.


Request parameters

GET/api/v2/rest/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 by ID or Onestop ID

GET/api/v2/rest/routes/{route_key}.format Request a route by ID or Onestop ID in specified format

ParameterTypeDescriptionExample
route_keystring

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

Agency lookup key; can be an integer ID, a '<feed onestop_id>:<gtfs agency_id>' key, or a Onestop ID
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
route_typesstring

Search for routes with these GTFS route (vehicle) types. Accepts comma separated values.route_types=1,2
operator_onestop_idstring

Search for records by operator OnestopIDoperator_onestop_id=...
include_alertsstring enum
truefalse
Include alerts from GTFS Realtime feeds
include_geometrystring enum
truefalse
Include route geometryinclude_geometry=true
include_stopsstring enum
truefalse
Include route stopsinclude_stops=true
idinteger

Search for a specific internal ID
afterinteger

Pagination cursor value. This should be treated as an opaque value created by the server and returned as the link to the next result page, which may be empty. For historical reasons, this is based on the integer record ID values, but that should not be assumed to be the case in the future.
limitinteger

Maximum number of records to returnlimit=1
formatstring enum
jsongeojsongeojsonlpng
Response formatformat=png
searchstring

Full text searchsearch=daly+city
onestop_idstring

Search for a specific Onestop IDonestop_id=r-9q9j-l1
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-sf~bay~area~rg
radiusnumber

Search radius (meters); requires lat and lonlon=-122&lat=37&radius=1000
latnumber

Latitude
lonnumber

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_allowedstring 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_optionalstring 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_productstring 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_allowedstring 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_attributionstring 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


routes
array: Route
Currently imported routes. If no feed version is specified, defaults to active feed versions.
id
integer
Internal integer ID
route_color
string
GTFS routes.route_color
route_desc
string
GTFS routes.route_desc
route_id
string
GTFS routes.route_id
route_long_name
string
GTFS routes.route_long_name
route_short_name
string
GTFS routes.route_short_name
route_sort_order
integer
GTFS routes.route_sort_order
route_text_color
string
GTFS routes.route_text_color
route_type
integer
GTFS routes.route_type
route_url
string
GTFS routes.route_url
continuous_pickup
integer
GTFS routes.continuous_pickup
continuous_drop_off
integer
GTFS routes.continuous_drop_off
onestop_id
string
OnestopID for this route
geometry
Representative geometry for this route
alerts
array: Alert
GTFS-RT alerts for this route
cause
string
GTFS-RT Alert cause
effect
string
GTFS-RT Alert effect
severity_level
string
GTFS-RT Alert severity level
url
array: RTTranslation
GTFS-RT Alert uRL for more information
header_text
array: RTTranslation
GTFS-RT Alert header text
description_text
array: RTTranslation
GTFS-RT Alert description text
tts_header_text
array: RTTranslation
GTFS-RT Alert TTS header text
tts_description_text
array: RTTranslation
GTFS-RT Alert TTS description text
active_period
array: RTTimeRange
GTFS-RT Alert active alert period. See https://gtfs.org/realtime/reference/#message-timerange
agency
object: Agency
Agency associated with this route
id
integer
Internal integer ID
agency_id
string
GTFS agency.agency_id
agency_name
string
GTFS agency.agency_name
onestop_id
string
OnestopID for this agency (or its associated operator)
alerts
array: Alert
GTFS-RT alerts for this agency
feed_version
object: FeedVersion
Source feed version for this entity
id
integer
Internal integer ID
sha1
string
SHA1 hash of the zip file

Exampleab5bdc8b6cedd06792d42186a9b542504c5eef9a

fetched_at
string
Time when the file was fetched from the url

Example2019-11-15T00:45:55.409906

feed
object: Feed
Feed associated with this feed version
route_stops
array: RouteStop
Stops associated with this route
stop
object: Stop
Associated stop