This API call calculates the travelling distance and time between two postcodes.
Provide a combination of either Dutch 4PP:
or a combination of Dutch 6PP:
Note: Because the DTM table of every 6PP postcode to every other 6PP postcode would be very big, only the postcodes with a maximum distance of 5km are included in the dataset. In order to find out the travel time or distance between postcodes further apart, revert to just the 4PP postcodes.
or Belgian postcodes:
Any subscription allows access to the straight line distance, however the road algorithm uses the drive time matrix (shortest route) that requires a ’development agency’ or higher subscription level when used through the API.
For trial purposes, a range of postcodes is allowed with any subscription level: 1000..1098, 1100..1108 (Amsterdam), 3000..3089 (Rotterdam), 5600..5658 (Eindhoven).
In this example, the travelling distance and time over the road between two Dutch postcodes are obtained.
GET https://api.pro6pp.nl/v1/distance?auth_key=YOUR_AUTH_KEY&from_nl_fourpp=5408&to_nl_fourpp=5652&algorithm=road HTTP/1.1
Content-Type: application/json; charset=utf-8
{
"status": "ok",
"results": {
"distance": 36800,
"duration": 24
}
}
In this example, the straight line distance between two Belgian postcodes is obtained. The chosen output format is XML.
GET https://api.pro6pp.nl/v1/distance?auth_key=YOUR_AUTH_KEY&from_be_fourpp=2000&to_be_fourpp=4000&algorithm=straight&format=xml HTTP/1.1
Content-Type: application/xml; charset=utf-8
<?xml version="1.0" encoding="UTF-8"?>
<response>
<status>ok</status>
<results>
<distance>105674</distance>
</results>
</response>
The distance method is demonstrated in these ready-to-use examples:
We encourage you to request example code in the language you prefer. In the meantime, you might want to look at the autocomplete method, which is already demonstrated in many languages.
We start by creating an empty HTML page, containing a minimal web page structure.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Distance tutorial</title>
</head>
<body></body>
</html>
Download our JavaScript library distance.js that allows us to integrate the Pro6PP webservice into this web page. Copy it in the same directory as you saved the above web page.
Add the following code between the <body> and <body> tags.
It adds the input fields for entering the coordinates.
<form class="distance">
From postcode: <input type="number" data-binding="from-nl-fourpp" /><br />
To postcode: <input type="number" data-binding="to-nl-fourpp" /><br />
<span data-binding="message"></span><br />
Distance (meters): <input type="number" data-binding="distance" /> Duration (minutes):
<input type="number" data-binding="duration" />
</form>
Add the following code between the <head> and </head> tags. It suggests possible city names while the user is typing.
<script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css" />
<script src="https://code.jquery.com/ui/1.11.2/jquery-ui.min.js"></script>
<script src="distance.js"></script>
<script>
var pro6ppAuthKey = 'YOUR AUTH_KEY';
var algorithm = 'road'; // or 'straight'
$(document).ready(function() {
$('.distance').applyDistance({
algorithm: algorithm,
pro6ppAuthKey: pro6ppAuthKey,
});
});
</script>
To access the Pro6PP webservice, you need to request your personal authorization key. This key is emailed to you right after signing up.
Replace the above placeholder YOUR AUTH_KEY with your personal authorization key.
Open distance.html in your browser. It’s ready to use!
It doesn’t work? Try downloading the ready-to-use example code at the example code page.