With the Routing service you can calculate routes from A to B taking into account vehicle-specific restrictions, traffic situations, toll, emissions, driver's working hours, service times and opening intervals.
Using the Routing 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.
Please note the individual rate and request limits for each API. You can find all limits in our FAQ.
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/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/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/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/v1/routes?waypoints=49.62127,6.06479&waypoints=48.998014,8.367462"
$response = Invoke-RestMethod -Uri $uri -Method Get -Headers $headers
$response | ConvertTo-Json
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
}