Transitland v2 Vector Tiles

Available on the following API tiers:

Transitland v2Free tier
Transitland v2Pro tier

Transitland publishes the current, active set of routes and stops as a set of tiles in Mapbox Vector Tile (MVT) format. These provide extremely fast access to basic information such as route names, geometries, stop locations, etc. Additional details for each entity can be obtained using other Transitland APIs.

Transitland Vector Tile Endpoints

The Transitland Vector Tiles base endpoint is:

https://transit.land/api/v2/tiles

Two services are currently provided: routes and stops.

https://transit.land/api/v2/tiles/routes/tiles/{z}/{x}/{y}.pbf
https://transit.land/api/v2/tiles/stops/tiles/{z}/{x}/{y}.pbf

Configuring access

You will need to send your API key as part of the request to this endpoint. It can be specified through either the apikey query parameter or apikey header value.

Don't have a Transitland v2 API key? Follow these instructions.

Access considerations

Transitland Vector Tiles are pre-generated and cached for performance. This is a necessity for rendering large scale maps quickly. As such, data in the tiles may lag up to a few hours behind other APIs. If your use case requires access to the most current data, finer-grained queries, or more structured results, then the [REST(/documentation/rest-api/) or GraphQL APIs may be more appropriate.

Route and stop tiles include both a stable, public Onestop ID values, as well as by internal ID values. These internal IDs are not stable and should not be used outside of the immediate context; they are provided only as a convenience for when a unique integer key is needed (e.g. GeoJSON display).

Route tiles

The following attributes are provided for each feature in the route tiles. Note that some fields may be empty or null, in particular, headway_secs cannot always be accurately estimated.

AttributeDescriptionExample
geometryRepresentative line geometry for this routeLineString(...)
generatedTrue if the line geometry was generated from stop locationsf
onestop_idGenerated OnestopIDr-9q9-yl~s
feed_onestop_idFeed OnestopIDf-9q9-bart
feed_version_sha1Feed Version8aafa62e...
route_idGTFS route_id1
route_short_nameGTFS route_short_nameYL-S
route_long_nameGTFS route_long_nameAntioch to SFIA/Millbrae
route_colorGTFS route_color#ffff33
route_typeGTFS route_type1
headway_secsApproximate headway (seconds) for weekday mornings960
agency_idThe agency_id from the associated GTFS agencyBART
agency_nameThe agency_name from the associated GTFS AgencyBay Area Rapid Transit
idInternal ID8472496

Stop metadata

The following attributes are provided for each feature in the stop tiles.

AttributeDescriptionExample
geometryGeometryPoint(...)
onestop_idStop OnestopIDs-9q9p19ut0x-12thstreet~oaklandcitycenter
feed_onestop_idFeed OnestopIDf-9q9-bart
feed_version_sha1Feed Version8aafa62e...
stop_idGTFS stop_id12TH
stop_nameGTFS stop_name12th Street / Oakland City Center
location_typeGTFS location_type0
parent_stationInternal ID for parent station32915959
idInternal ID32916008

Mapbox GL example

These tiles can be consumed by any program that understands Mapbox Vector Tile format. The full details on how to request and render these tiles varies by library, but following is a brief example to configure Mapbox GL JS and render routes in the Chicago area. A full working version can be found here. You will need to provide your own API key.

Example Mapbox GL JS Map
const apikey = <YOUR_API_KEY>
const map = new mapboxgl.Map({
    container: 'map',
    style: {
        version: 8,
        zoom: 12,
        center: [-87.628611, 41.860025],
        sources: {
            routes: {
                type: 'vector',
                tiles: [
                    `https://transit.land/api/v2/tiles/routes/tiles/{z}/{x}/{y}.pbf?apikey=${apikey}`
                ],
                maxzoom: 14
            }
        },
        layers: [{
            id: 'routes',
            type: 'line',
            source: 'routes',
            'source-layer': 'routes',
            layout: {
                'line-cap': 'round',
                'line-join': 'round'
            },
            paint: {
                'line-width': 3.0,
                'line-color': '#ff0000'
            }
        }]
    }
})

Sending the API key in the header is recommended; this can be accomplished using Mapbox GL's transformRequest option:

  transformRequest: (url, resourceType) => {
    if (resourceType === 'Tile' && url.startsWith('https://transit.land')) {
      return {
        url,
        headers: { apikey: <YOUR_API_KEY> }
      }
    }
  }