New API is in preview! Subject to change. Send feedback to contact@mtd.dev

Shapes

Shapes are geographical lines. Shapes are used by trips to represent the physical path a bus takes.

There are two different formats for shapes:

  1. GTFS Shape Object

    The GTFS definition of a shape. This shape contains an array of shape points. Each shape point has a sequence, a latitude and longitude point, distance traveled, and stopId.

  2. Encoded Polyline

    A method of encoding a series of coordinates into a string via a lossy compression algorithm created by Google. An encoded polyline looks like this:

    ezsFv{qyO@fDbK?CfI

    See Google's Encoded Polyline Algorithm documentation for more information on how to encode and decode these strings, as well as the Interactive Polyline Utility.

API Definitions

Get a shape

Path Parameters

shapeId

string

required

The id of a shape.

Query Parameters

No query parameters.

Response Object

id

string

Stable identifier for this shape.
shapePoints

Array of shapePoints

The ordered collection of points that define this shape.

sequence

integer | string

The order of this point along the shape. 1-indexed.
coordinates

object

The geographic location of this shape point.

latitude

float

Latitude coordinate.
longitude

float

Longitude coordinate.
distanceTraveled

float

Cumulative distance traveled along the shape to this point, in meters.
stopId

string | null

Stop ID served by this shape point, if any. Null if this is just a point along the line.
GEThttps://api.mtd.dev/shapes/{shapeId}
curl -X GET "https://api.mtd.dev/shapes/{shapeId}" \
  -H "X-ApiKey: YOUR_API_KEY"
Sample Response Object
{
	"result": {
		"id": "130N SILVER EVENING 999",
		"shapePoints": [
			{
				"sequence": 1,
				"coordinates": {
					"latitude": 40.09949000000001,
					"longitude": -88.220416
				},
				"distanceTraveled": 0,
				"stopId": null
			},
			{
				"sequence": 2,
				"coordinates": {
					"latitude": 40.099466,
					"longitude": -88.220416
				},
				"distanceTraveled": 2.667,
				"stopId": "STOP:1"
			}
		]
	},
	"error": null
}

Get an encoded polyline shape

Path Parameters

shapeId

string

required

The id of a shape.

Query Parameters

No query parameters.

Response Object

polyline

string

The shape as an encoded polyline.
GEThttps://api.mtd.dev/shape/{shapeId}/polyline
curl -X GET "https://api.mtd.dev/shape/{shapeId}/polyline" \
  -H "X-ApiKey: YOUR_API_KEY"
Sample Response Object
{
	"result": {
		"polyline": "sczsF|pqyOBK~@VRFVTT~@KfAUjA|@VjC{PJ{BV@WIEmAAcID?EA?GCsVF?GA?GC{WhDC?NHO~IC"
	},
	"error": null
}
* * *