API v1 documentation

Distance

This API call calculates the travelling distance and time between two postcodes.


Required parameters

Provide a combination of either Dutch 4PP:

  • from_nl_fourpp: Provide a Dutch 4 position starting postcode.
  • to_nl_fourpp: Provide a Dutch 4 position destination postcode.

or a combination of Dutch 6PP:

  • from_nl_sixpp: Provide a Dutch 6 position starting postcode.
  • to_nl_sixpp: Provide a Dutch 6 position destination postcode.

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:

  • from_be_fourpp: Provide a Belgian starting postcode.
  • to_be_fourpp: Provide a Belgian destination postcode.

Optional pararameters

  • algorithm: Choose an algorithm. road to calculate the actual travelling distance and time over actual roads, or straight to obtain the distance in a straight line.

    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).

Examples

Over the road

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 a straight line

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>

Example code


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.

Step by step example in JavaScript


Step 1: build the HTML page

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>

Step 2: add interaction

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>

Step 3: make it work

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.

Step 4: see it in action

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.