Skip to main content
Use the Routing API to calculate travel distances and ETAs, compare many origins and destinations at once, get turn-by-turn directions, snap recorded points to roads, and order a list of stops. The base URL is https://api.radar.io. Send your API key in the Authorization header. All five operations accept a publishable key, so you can call them from a client. Route match and Optimize route are available on the Enterprise plan. For key types, the error format, and rate limits, see Authentication, errors, and rate limits.

Units, modes, and geometry

These conventions apply to every routing operation.

Coordinates

Coordinates in requests are strings in the format latitude,longitude. Lists of coordinates are pipe-delimited: latitude0,longitude0|latitude1,longitude1. URL-encode the pipe as %7C if your HTTP client doesn’t do it for you.

Distance and duration values

Distances and durations are returned as objects with a numeric value and a display text. duration.value is always in minutes, as a decimal number. units defaults to imperial, so send units=metric if your application works in meters.

Travel modes

Geometry formats

The geometry parameter controls the shape of the route in the response. Encoded polylines contain backslash characters. Decode the JSON response before you decode the polyline, so that escaped backslashes are handled correctly.

Straight-line distance and route distance

Distance returns both. routes.geodesic is the straight-line distance between the two points and has no duration. The entries keyed by travel mode are route distances and ETAs along the road network. Label them differently in your interface, for example “2.1 mi away” and “8 min drive”.

Distance

Calculates the travel distance and duration between an origin and a destination.

Query parameters

Response

A 200 response contains meta and these fields:

Example

This request calculates the walking and driving distance between two points.
Radar returns this response:

Errors

A 400 response looks like this:

Matrix

Calculates the travel distances and durations between multiple origins and destinations, for up to 625 routes in one request. The number of routes is the number of origins multiplied by the number of destinations. Use Matrix to rank several candidate locations by ETA from one user location, or to assign several drivers to several stops.

Query parameters

Response

A 200 response contains meta and these fields:

Example

This request calculates driving distances from one origin to two destinations.
Radar returns this response:

Errors

Route match

Snaps points collected along a route to the roads that were most likely traveled. Returns the matched path and, optionally, road attributes such as names and speed limits.
Route matching is available on the Enterprise plan.
For best results, collect points less than 10 seconds apart.

Body parameters

Send a JSON body with Content-Type: application/json. The same operation is also available as GET https://api.radar.io/v1/route/match, with mode, roadAttributes, units, and geometry as query parameters and path as a pipe-delimited string of coordinates. The GET form can’t carry createdAt or accuracy, so prefer POST when you have them.

Response

A 200 response contains meta and these fields: roadClass is one of the following, in descending order of road size:

Example

This request snaps two points to the road network and returns road attributes.
This response is shortened to the first and last road segments and a simplified route shape.

Errors

A 400 response looks like this:

Directions

Calculates the most efficient route between two or more locations visited in the order you provide, with turn-by-turn steps. To let Radar choose the order of the stops, use Optimize route.

Query parameters

Response

A 200 response contains meta and routes. routes is an array. It has one route unless you sent alternatives=true and Radar found alternative routes. Each step has these fields. Step field names use snake case.

Example

This request gets driving directions between two locations, with the route shape as a polyline6 string.
Radar returns this response:

Errors

A 400 response looks like this:

Optimize route

Calculates the optimal ordering and route to visit a list of locations. The first location is the origin of the route and the last location is the final destination. Radar chooses the order of the locations in between.
Route optimization is available on the Enterprise plan.

Query parameters

Response

A 200 response contains meta and route: To read the optimized stop order, take startIndex of the first leg followed by endIndex of every leg. In the example below, the order is 0, 3, 2, 1, 4.

Example

This request orders three stops between a fixed origin and a fixed final destination.
Radar returns this response:

Errors

Limits

Rate limits apply per project. A request over the limit returns 429. For retry guidance and how to request a higher limit, see Rate limits.

Coverage

Routing coverage for distance, matrix, and route matching is rated great for consumer and logistics use cases in the US, Canada, the UK, and the EU, and good elsewhere. For map data coverage, see Maps coverage.