REST API - Routes

Routes are routes.txt entities imported from GTFS, and include the same basic structure and fields, plus some additional metadata and derived information. A route is a collection of trips, where each trip represents scheduled service to stops on a given day and time.

Route geometries

Route geometries are based on the most common trips for each route, and are not meant to be an exhaustive list of every possible journey pattern. Full shapes are available when accessing trips.

Route OnestopIDs

OnestopID values are automatically generated for every route using a geohash of the stop locations visited by this route and the name of the route. Two very similar routes may generate the same OnestopID value, in which more than one route entry will be returned when searching by OnestopID.

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 by ID or Onestop ID

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

Parameter Type Description Example
id integer
0 ... unlimited
Search for a specific internal ID
route_key string

Equivalent to id (if an integer) or onestop_id (if string)
after integer

Return records past this record ID
limit integer
0 ... 100
Maximum number of records to return limit=1
format enum
jsongeojsonpng
Response format format=png
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 records with this GTFS route_type route_type=1
operator_onestop_id string

Search for records by operator OnestopID operator_onestop_id=...
include_geometry string enum
truefalse
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 radius (meters); requires lat and lon lat=-122&lon=37&radius=1000
lat number
-90 ... 90
Latitude
lon number
-180 ... 180
Longitude

Response format

Array of objects
Description: Route entity
id
(int64)
Unique integer ID

Example:123

onestop_id
(string)
OnestopID for this route, if available

Example:r-dr72-1

route_id
(string)
GTFS route_id

Example:orange

route_type
(integer)
GTFS route_type

Example:3

route_short_name
(string)
GTFS route_short_name

Example:Orange

route_long_name
(string)
GTFS route_long_name

Example:Richmond - 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
agency
(object)
A subset of fields for this route's agency
feed_version
(object)
A subset of fields for this route's feed version
geometry
(object)
Geometry in GeoJSON format
type
(string)
GeoJSON geometry type

Example:LineString

coordinates
(number array)
An array of GeoJSON coordinates

Example:[ [ -122.496, 37.778 ], [ -122.425, 37.786 ] ]

route_stops
(object array)
An array of all stops visited by this route
stop
(object)
A subset of fields for this stop visited by this route