API-dokumentation

API'et modtager CPR-numre via JSON, form-data eller query string. Svar kan returneres som JSON, XML eller tekst.

Resultatet er alene teknisk formatkontrol og er ikke dokumentation for identitet eller registeropslag.

Endpoint

http://ntra.dk/valid/api/secure-validate.php

Send API-nøglen i headeren X-API-Key eller som parameteren api_key.

Krypteret forbindelse

API-kald skal sendes via HTTPS. Ukrypterede HTTP-kald afvises, så CPR-data og API-nøgle ikke overføres åbent.

Parametre

  • cpr – CPR-nummer
  • format – json, xml eller text
  • api_key – alternativ til header

Eksempler

curl -X POST "http://ntra.dk/valid/api/secure-validate.php" \
  -H "X-API-Key: DIN_API_NØGLE" \
  -H "Content-Type: application/json" \
  -d '{"cpr":"0102031234"}'
curl -X POST "http://ntra.dk/valid/api/secure-validate.php" \
  -H "X-API-Key: DIN_API_NØGLE" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "cpr=0102031234&format=json"
curl "http://ntra.dk/valid/api/secure-validate.php?api_key=DIN_API_NØGLE&cpr=0102031234&format=xml"
<?php
$ch = curl_init('http://ntra.dk/valid/api/secure-validate.php');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'X-API-Key: DIN_API_NØGLE',
        'Content-Type: application/json'
    ],
    CURLOPT_POSTFIELDS => json_encode(['cpr' => '0102031234'])
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
fetch('http://ntra.dk/valid/api/secure-validate.php', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'DIN_API_NØGLE'
  },
  body: JSON.stringify({ cpr: '0102031234' })
}).then(r => r.json()).then(console.log);