REST API - Agencies and Operators

Agencies and Operators

Operators and agencies are two means of grouping together stops, routes, trips, and other data for a single organization that offers transit service. For more information on the distinction, see agencies and operators.

Request overview

The REST API provides access to both agencies and operators, with results based on agency and operator GraphQL queries.


Agency request parameters

GET/api/v2/rest/agencies Search for agencies

GET/api/v2/rest/agencies.{format} Request agencies in specified format

GET/api/v2/rest/agencies/{agency_key} Request an agency

GET/api/v2/rest/agencies/{agency_key}.format Request an agency in a specified format

ParameterTypeDescriptionExample
agency_keystring

Agency lookup key; can be an integer ID, a '<feed onestop_id>:<gtfs agency_id>' key, or a Onestop ID
agency_idstring

Search for records with this GTFS agency_id (string)agency_id=BART
agency_namestring

Search for records with this GTFS agency_nameagency_name=Caltrain
idinteger

Search for a specific internal ID
include_alertsstring enum
truefalse
Include alerts from GTFS Realtime feeds
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=geojson
searchstring

Full text searchsearch=bart
onestop_idstring

Search for a specific Onestop IDonestop_id=o-9q9-caltrain
feed_version_sha1string

Search for records in this feed versionfeed_version_sha1=1c4721d4...
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.3&lat=37.8&radius=1000
lonnumber

Longitude
latnumber

Latitude
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
adm0_namestring

Search by country nameadm0_name=Mexico
adm0_isostring

Search by country 2 letter ISO 3166 codeadm0_iso=US
adm1_namestring

Search by state/province/division nameadm1_name=California
adm1_isostring

Search by state/province/division ISO 3166-2 codeadm1_iso=US-CA
city_namestring

Search by city namecity_name=Oakland
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'.

Agency response format


agencies
array: Agency
Currently imported agencies. If no feed version is specified, defaults to active feed versions.
id
integer
Internal integer ID
agency_name
string
GTFS agency.agency_name
agency_id
string
GTFS agency.agency_id
onestop_id
string
OnestopID for this agency (or its associated operator)
agency_url
string
GTFS agency.agency_url
agency_timezone
string
GTFS agency.agency_timezone
agency_lang
string
GTFS agency.agency_lang
agency_phone
string
GTFS agency.agency_phone
agency_fare_url
string
GTFS agency.agency_fare_url
agency_email
string
GTFS agency.agency_email
geometry
Geometry for this agency, generated as the convex hull of all stops
operator
object: Operator
Operator associated with this agency
onestop_id
string
OnestopID for this operator
name
string
Operator name
short_name
string
Operator short name, if available
tags
object
Source DMFR tag data
feeds
array: Feed
Feeds associated with this operator
alerts
array: Alert
GTFS-RT alerts for this agency
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
places
array: AgencyPlace
Places associated with this agency through a matching process
city_name
string
Best-matched city name
adm0_name
string
Best-matched country name
adm1_name
string
Best-matched state or province name
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
routes
array: Route
Routes associated with this agency
id
integer
Internal integer ID
route_id
string
GTFS routes.route_id
route_short_name
string
GTFS routes.route_short_name
route_long_name
string
GTFS routes.route_long_name
alerts
array: Alert
GTFS-RT alerts for this route

Operator request parameters

GET/api/v2/rest/operators Search for operators

GET/api/v2/rest/operators.{format} Request operators in specified format

GET/api/v2/rest/operators/{onestop_id} Request an operator by Onestop ID

GET/api/v2/rest/operators/{onestop_id}.format Request an operator by Onestop ID in specified format

ParameterTypeDescriptionExample
tag_keystring

Search for operators with a tag. Combine with tag_value also query for the value of the tag.tag_key=us_ntd_id
tag_valuestring

Search for feeds tagged with a given value. Must be combined with tag_key.tag_key=us_ntd_id&tag_value=40029
onestop_idstring

Search for a specific Onestop IDonestop_id=o-9q9-caltrain
feed_onestop_idstring

Search for records in this feedfeed_onestop_id=f-sf~bay~area~rg
searchstring

Full text searchsearch=bart
include_alertsstring enum
truefalse
Include alerts from GTFS Realtime feeds
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 return
adm0_namestring

Search by country nameadm0_name=Mexico
adm0_isostring

Search by country 2 letter ISO 3166 codeadm0_iso=US
adm1_namestring

Search by state/province/division nameadm1_name=California
adm1_isostring

Search by state/province/division ISO 3166-2 codeadm1_iso=US-CA
city_namestring

Search by city namecity_name=Oakland
radiusnumber

Search radius (meters); requires lat and lonlon=-122.3&lat=37.8&radius=1000
lonnumber

Longitude
latnumber

Latitude
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'.

Operator response format


operators
array: Operator
Operators
id
integer
Internal integer ID
onestop_id
string
OnestopID for this operator
name
string
Operator name
short_name
string
Operator short name, if available
website
string
Operator website, if available
tags
object
Source DMFR tag data
feeds
array: Feed
Feeds associated with this operator
id
integer
Internal integer ID
onestop_id
string
OnestopID for this feed
name
string
A common name for this feed. Optional. Alternatively use associated_operators[].name
spec
object: FeedSpecTypes
Type of feed
EnumGTFSGTFS_RTGBFSMDS
agencies
array: Agency
Currently imported and active agencies associated with this operator
id
integer
Internal integer ID
agency_id
string
GTFS agency.agency_id
agency_name
string
GTFS agency.agency_name
geometry
Geometry for this agency, generated as the convex hull of all stops
alerts
array: Alert
GTFS-RT alerts for this agency
places
array: AgencyPlace
Places associated with this agency through a matching process