Calculate car travel-time/distance matrix

GET /v1/car/matrix/{coordinates}
Coordinates format: lon,lat;lon,lat (semicolon-separated waypoints)
Base URL: https://capi.busmaps.com:8443

Calculate driving distance and duration matrices through the full-planet OSRM car service. This shared service is independent of the selected BusMaps or WikiRoutes transit data host and is available with either capi-host value. Query parameters are forwarded to the OSRM table service without changing the response contract.

Response fields and units

FieldFormat / unitMeaning
durations[][] seconds or null Driving-time matrix; rows are sources and columns are destinations
distances[][] meters or null Driving-distance matrix; rows are sources and columns are destinations
sources[].distance, destinations[].distance meters Distance from each input coordinate to its snapped road waypoint
sources[].location, destinations[].location [longitude, latitude] in decimal degrees Snapped waypoint coordinates

Parameters

ParameterTypeRequiredDescriptionExample
sources string No Semicolon-separated indices of source coordinates 0;1
destinations string No Semicolon-separated indices of destination coordinates 1;2
annotations string No Matrix values to return (Values: duration, distance, duration,distance) duration,distance
skip_waypoints boolean No Omit source and destination waypoint objects true

Try It Out

Common usage with optional parameters

curl -H "capi-key: Bearer YOUR_API_KEY" \
     -H "capi-host: busmaps.com" \
     "https://capi.busmaps.com:8443/v1/car/matrix/7.42056,43.731142;7.42462,43.73848;7.41468,43.73398?skip_waypoints=true"

Popular parameters

curl -H "capi-key: Bearer YOUR_API_KEY" \
     -H "capi-host: busmaps.com" \
     "https://capi.busmaps.com:8443/v1/car/matrix/7.42056,43.731142;7.42462,43.73848;7.41468,43.73398?sources=0;1&destinations=1;2&annotations=duration,distance&skip_waypoints=true"

Response Example

{
    "code": "Ok",
    "durations": [
        [
            0,
            156.6,
            256
        ],
        [
            233.3,
            0,
            152.6
        ],
        [
            268.6,
            135.9,
            0
        ]
    ]
}

Response Schema

View JSON Schema
{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "Car Matrix Response",
    "type": "object",
    "properties": {
        "durations": {
            "type": "array",
            "items": {
                "type": "array",
                "items": {
                    "type": [
                        "integer",
                        "null",
                        "number"
                    ]
                }
            },
            "description": "Driving durations in seconds"
        },
        "code": {
            "type": "string",
            "description": "OSRM response code"
        },
        "sources": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "location": {
                        "type": "array",
                        "items": {
                            "type": "number"
                        },
                        "description": "Snapped [longitude, latitude] coordinate"
                    },
                    "hint": {
                        "type": "string",
                        "description": "Opaque OSRM hint for re-snapping the waypoint"
                    },
                    "distance": {
                        "type": "number",
                        "description": "Distance to the snapped road waypoint in meters"
                    },
                    "name": {
                        "type": "string",
                        "description": "Display name"
                    }
                },
                "required": [
                    "location",
                    "hint",
                    "name",
                    "distance"
                ]
            },
            "description": "Source waypoints"
        },
        "distances": {
            "type": "array",
            "items": {
                "type": "array",
                "items": {
                    "type": [
                        "integer",
                        "null",
                        "number"
                    ]
                }
            },
            "description": "Driving distances in meters"
        },
        "destinations": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "location": {
                        "type": "array",
                        "items": {
                            "type": "number"
                        },
                        "description": "Snapped [longitude, latitude] coordinate"
                    },
                    "hint": {
                        "type": "string",
                        "description": "Opaque OSRM hint for re-snapping the waypoint"
                    },
                    "distance": {
                        "type": "number",
                        "description": "Distance to the snapped road waypoint in meters"
                    },
                    "name": {
                        "type": "string",
                        "description": "Display name"
                    }
                },
                "required": [
                    "location",
                    "hint",
                    "name",
                    "distance"
                ]
            },
            "description": "Destination waypoints"
        },
        "message": {
            "type": "string",
            "description": "Error detail when the matrix cannot be calculated"
        }
    },
    "required": [
        "durations",
        "code"
    ]
}

Response Codes

200 OSRM matrix response returned successfully
400 Invalid coordinates, indices, request parameters, or no routable segment
500 Car routing service is unavailable