Search for content

Quick Start - Routing OSM API [EXPERIMENTAL]

With the Routing service you can calculate routes for bicycles from A to B.

Using the Routing OSM API is simple. Follow the steps on this page to get started with routing. For an easy integration you can also use the clients for Java, C# and TypeScript on GitHub.

API Endpoint

To get you started we will use the following endpoint, that will calculate a route by specifying a list of waypoints:

https://api.myptv.com/routing-osm/v1/routes

 

Request

To calculate a route near Luxemburg to Karlsruhe use the waypoints parameter in the request.

You can test this by entering the URL into your web browser (be sure to replace YOUR_API_KEY with your actual API key).

https://api.myptv.com/routing-osm/v1/routes?waypoints=49.62127,6.06479&waypoints=48.998014,8.367462&apiKey=YOUR_API_KEY

Alternatively you can choose one of the following options to send your request. You also have the option to send the API key in the request header.

cURL:

curl --location --request GET "https://api.myptv.com/routing-osm/v1/routes?waypoints=49.62127,6.06479&waypoints=48.998014,8.367462" --header "ApiKey: YOUR_API_KEY"

PowerShell:

$headers = @{"apiKey" = "YOUR_API_KEY"}
$Uri = "https://api.myptv.com/routing-osm/v1/routes?waypoints=49.62127,6.06479&waypoints=48.998014,8.367462"
$response = Invoke-RestMethod -Uri $uri -Method Get -Headers $headers
$response | ConvertTo-Json

 

Get your free API Access Key

Response

Below you will find a possible result list with the distance in meters, the travel time in seconds and whether a valid route was found.

{
	"distance":  241205,
	"travelTime":  12816.696,
	"violated":  false
}