0

At the moment I'm struggling with how to implement a api from postcode.nl. A Dutch initiative that helps you to get the street and city when a zipcode and housenumber is entered. Because the api is free to use, they don't give any support besides the documentation, which is very limited.

Here the URL of the webpage with the documentation: https://api.postcode.nl/documentation/rest-json-endpoint

At the bottom they mention the following:

We do not support jsonp. We recommend to host a simple proxy script on your own server instead of making cross domain calls directly in the browser. This way, you also do not have to put your key and secret in publicly readible javascript.

I won't say I'm a noob, but I never used REST before or did something on my server via a proxy. So how I can implement this API?

halfer
  • 19,824
  • 17
  • 99
  • 186
Timo002
  • 3,138
  • 4
  • 40
  • 65

1 Answers1

1

I got the API working. And I think it would be nice if I share a howto.

What I'm doing is:

  1. I do a AJAX call to a php file.
  2. The php file will be executed and does a curl on the API URL. Because this is in php, the username and password will also not be available to be viewed.
  3. The result from the curl is put into a JSON format and returned to the AJAX call.
  4. Now I have in JavaScript the result of the API request.
halfer
  • 19,824
  • 17
  • 99
  • 186
Timo002
  • 3,138
  • 4
  • 40
  • 65