Range Holland
BetaReturner hollandske postnumre inden for rækkevidde af et givet postnummer.
https://api.pro6pp.nl/v2/range/nlOversigt
Returns the postal codes within a range of a postal code or settlement.
postalCodeorsettlementis required. When both are supplied,postalCodeis used.- An ambiguous settlement returns HTTP 400.
ParametreQuerystreng
Either the fourpp (e.g: 1000) or the sixpp (e.g: 1000AA) notation.
- Eksempel
1012- Mønster
^"?([0-9]{4})"?$|^"?([0-9]{4} ?[a-zA-Z]{2})"?$
The address's settlement (city, town, village, or hamlet).
- Eksempel
Amsterdam
The address's municipality (only needed when there are multiple settlements by the same name to differentiate).
- Eksempel
Amsterdam
The address's province (only needed when there are multiple settlements having the same municipality name, so there's a province needed to differentiate).
- Eksempel
Noord-Holland
The range to search, in meters. Maximum 100000.
- Eksempel
10000- Standard
5000- Min.
1- Maks.
100000
The precision for the returned results. Either sixpp or fourpp.
- Standard
"fourpp"- En af
fourppsixpp
The amount of results returned, a number between 1 and 999. Default value is 10.
- Standard
10- Min.
1- Maks.
999
Option whether to include the initial postal code in /v2/range calls. If the value is True, then the initial postal code is included in the search.
- Standard
false
Svar
| Felt | Type | Eksempelværdi | Beskrivelse |
|---|---|---|---|
| postalCode | string | "1000" | The 4-digit postal code, or with precision sixpp the six-position postal code without a space, such as "1012AB". |
| distance | integer | 223 | Straight-line distance in metres from the requested postal code or settlement, rounded to whole metres. |
| lat | number | 52.375 | Representative latitude of the postal code. For a 4-digit (fourpp) postal code that spans several settlements, this is the representative point of the dominant settlement (the one with the most addresses). |
| lng | number | 4.899 | Representative longitude of the postal code. For a 4-digit (fourpp) postal code that spans several settlements, this is the representative point of the dominant settlement (the one with the most addresses). |
[
{
"postalCode": "1000",
"distance": 223,
"lat": 52.375,
"lng": 4.899
},
{
"postalCode": "1001",
"distance": 223,
"lat": 52.375,
"lng": 4.899
},
{
"postalCode": "1002",
"distance": 223,
"lat": 52.375,
"lng": 4.899
},
{
"postalCode": "1003",
"distance": 223,
"lat": 52.375,
"lng": 4.899
},
{
"postalCode": "1005",
"distance": 223,
"lat": 52.375,
"lng": 4.899
},
{
"postalCode": "1006",
"distance": 223,
"lat": 52.375,
"lng": 4.899
},
{
"postalCode": "1007",
"distance": 223,
"lat": 52.375,
"lng": 4.899
},
{
"postalCode": "1008",
"distance": 223,
"lat": 52.375,
"lng": 4.899
},
{
"postalCode": "1009",
"distance": 223,
"lat": 52.375,
"lng": 4.899
},
{
"postalCode": "1014",
"distance": 223,
"lat": 52.375,
"lng": 4.899
}
]Fejl
Felter i et fejlsvar
| Felt | Type | Beskrivelse |
|---|---|---|
| error_id | string | The reason the request failed, such as |
| errors | array of object | One entry per problem found in the request. |
| errors[].message | string | A readable explanation of the problem, in English. |
| errors[].help | string | A link to the documentation section that covers the problem. |
| errors[].parameter | any | The parameter the problem is about. Usually its name; a list when several parameters are involved, or a name with the values to choose from when the request must select one. |
| errors[].value | any | The value the request sent for |
MISSING_PARAMETERNeither postalCode nor settlement is supplied.
Neither postalCode nor settlement is supplied.
{
"error_id": "MISSING_PARAMETER",
"errors": [
{
"message": "Required parameter postalCode is missing",
"help": "https://pro6pp.nl/docs/v2/redoc#operation/public_api.v2_generic.range.router.nl",
"parameter": "postalCode"
},
{
"message": "Required parameter settlement is missing",
"help": "https://pro6pp.nl/docs/v2/redoc#operation/public_api.v2_generic.range.router.nl",
"parameter": "settlement"
}
]
}INVALID_PARAMETER_TYPEA value has the wrong type, such as a non-integer searchRange.
A value has the wrong type, such as a non-integer searchRange.
{
"error_id": "INVALID_PARAMETER_TYPE",
"errors": [
{
"message": "parameter: searchRange has invalid 5km, should be integer",
"help": "https://pro6pp.nl/docs/v2/redoc#operation/public_api.v2_generic.range.router.nl",
"parameter": "searchRange"
}
]
}INVALID_VALUEA value is malformed or out of bounds, or the postalCode or settlement origin cannot be found.
A value is malformed or out of bounds, or the postalCode or settlement origin cannot be found.
{
"error_id": "INVALID_VALUE",
"errors": [
{
"message": "value is invalid",
"help": "https://pro6pp.nl/docs/v2/redoc#operation/public_api.v2_generic.range.router.nl",
"parameter": "postalCode",
"value": "invalid"
}
]
}MULTIPLE_RESULTS_FOUNDThe settlement is ambiguous; narrow it with municipality or province.
The settlement is ambiguous; narrow it with municipality or province.
{
"error_id": "MULTIPLE_RESULTS_FOUND",
"errors": [
{
"message": "Multiple results found",
"help": "https://pro6pp.nl/docs/v2/redoc#operation/public_api.v2_generic.range.router.nl"
}
]
}UNAUTHORIZEDThe API key is missing, unknown, revoked or expired, its subscription is not active, the request does not match the key's allowlist, or the subscription does not include this call.
The API key is missing, unknown, revoked or expired, its subscription is not active, the request does not match the key's allowlist, or the subscription does not include this call.
{
"error_id": "UNAUTHORIZED",
"errors": [
{
"message": "No authorization token provided",
"help": "https://pro6pp.nl/docs/v2/redoc#section/Authentication"
}
]
}Kodeeksempler
curl "https://api.pro6pp.nl/v2/range/nl?postalCode=1012&settlement=Amsterdam&municipality=Amsterdam&province=Noord-Holland&searchRange=10000&authKey=YOUR_API_KEY"Vi opfordrer dig til at anmode om eksempelkode på det sprog, du foretrækker.
Trin for trin
Opret en hurtig formular for at afprøve Holland Range -funktionaliteten ved at følge nedenstående trin.
Opbyg HTML-siden
Vi starter med at oprette en tom HTML-side, der indeholder en minimal websidestruktur. Opret en ny
.htmlfil med navnetpro6pp_holland_range.html. Tilføj følgende kode mellem<body>og</body>tags. Den tilføjer inputfelter til indtastning af adressen.<form class="form" id="form"> <div>Call</div> <div> <label for="postalCode">postalCode:</label> <input id="postalCode" class="postalCode" placeholder="1012"/> <label for="settlement">settlement:</label> <input id="settlement" class="settlement" placeholder="Amsterdam"/> <label for="municipality">municipality:</label> <input id="municipality" class="municipality" placeholder="Amsterdam"/> <label for="province">province:</label> <input id="province" class="province" placeholder="Noord-Holland"/> <label for="searchRange">searchRange:</label> <input id="searchRange" class="searchRange" placeholder="10000"/> <label for="precision">precision:</label> <input id="precision" class="precision" placeholder=""/> <label for="maxResults">maxResults:</label> <input id="maxResults" class="maxResults" placeholder=""/> <label for="includeInitialPostalCode">includeInitialPostalCode:</label> <input id="includeInitialPostalCode" class="includeInitialPostalCode" placeholder=""/> </div> <div> <span style="color: red" class="message"></span> </div> <div> <button type="submit">Submit</button> </div> <br /> <div>Response</div> <br /> <div>Full Response</div> <pre class="jsonResponse"></pre> </form>Tilføj interaktion
Tilføj følgende JavaScript-kode i en separat
pro6pp_holland_range.js-fil. HTML-elementernes ID'er og klassenavne skal stemme overens med dem, der er angivet i denne JavaScript-fil, for at få de korrekte resultater.document.addEventListener("DOMContentLoaded", function() { const pro6ppAuthKey = "AUTH_KEY"; // Replace with your actual authorization key let messageSpan = document.querySelector(".message"); let jsonResponseSpan = document.querySelector(".jsonResponse"); const BASE_URL = "https://api.pro6pp.nl/v2"; function fetchAddress(authKey) { const queryParams = { authKey: authKey }; const optionalQueryParams = [ "postalCode", "settlement", "municipality", "province", "searchRange", "precision", "maxResults", "includeInitialPostalCode", ]; for (const name of optionalQueryParams) { const value = document.getElementById(name).value; if (value !== "") { queryParams[name] = value; } } let encodedUrl = new URL(`${BASE_URL}/range/nl`); encodedUrl.search = new URLSearchParams(queryParams); fetch(encodedUrl) .then(async (response) => { const data = await response.json(); if (data) { messageSpan.textContent = ""; jsonResponseSpan.textContent = JSON.stringify(data, null, 2); } }) .catch((error) => { console.error("Error fetching: ", error); messageSpan.textContent = error.message; }); } const form = document.getElementById("form"); form.onsubmit = function (event) { event.preventDefault(); fetchAddress(pro6ppAuthKey); } });Få det til at fungere
Link JavaScript-filen inde i
pro6pp_holland_range.htmllige før du lukker</body>-tagget.... <script src="pro6pp_holland_range.js"></script> </body> </html>For at få adgang til Pro6PP-webservicen skal du anmode om din personlige autorisationsnøgle. Denne nøgle sendes til dig via e-mail lige efter tilmelding. Erstat ovenstående pladsholder
AUTH_KEYmed din personlige autorisationsnøgle.Hvis du ikke har en konto endnu, kan du tilmelde dig en gratis prøveperiode på 2 måneder. Når du har oprettet din konto, skal du gå til dine abonnementsoplysninger og kopiere din
AUTH_KEY. Du skal bruge denne nøgle til at godkende dine anmodninger.Se det i aktion
Når du har gennemført de foregående trin, er det tid til at køre formularen lokalt i din browser. Du bør nu have to filer i den samme mappe på din computer:
pro6pp_holland_range.html- HTML-sidenpro6pp_holland_range.js- den JavaScript-fil, der håndterer interaktionen.
Du kan nu åbne HTML-filen i din browser ved blot at dobbeltklikke på den i din filudforsker (f.eks. Finder på macOS eller File Explorer på Windows). Alternativt kan du åbne den manuelt i browseren ved at bruge den fulde
file:///-sti. For eksempel:file:///C:/Users/YourName/Documents/pro6pp_holland_range.html file:///Users/yourname/Desktop/pro6pp_holland_range.htmlNår siden åbnes, skal du begynde at skrive i formularfelterne og trykke på Submit for at se API-svaret blive vist i afsnittet »Full Response«.