API CityDate — Localité de naissance par code postal

Support DQE
Support DQE
  • Mise à jour
API CityDate - CPFRA

L'endpoint CPFRA valide si une ville ou une localité existait et était valide pour une date de naissance donnée.

Documentation CityDate associée - L'endpoint CPFRA vérifie la validité d'un couple ville/date de naissance. Vous cherchez plutôt une recherche de localité par nom, code postal ou code INSEE ?
API - Description - CityDate - BirthLocality →
CityDate introduction →

CPFRA

Requête

GET et POST sont toutes deux prises en charge.

{SERVER_ADDRESS} et {LICENCE_CODE} sont fournis par DQE à la création du compte. Contactez votre chargé de compte DQE pour obtenir ces identifiants.
GEThttps://{SERVER_ADDRESS}/CPFRA/?DDN={BIRTHDATE}&INSEE={INSEE_CODE}&CP={POSTAL_CODE}&Localite={CITY_NAME}&Licence={LICENCE_CODE}

Exemples de code

Recherche par nom de ville

curl "https://{SERVER_ADDRESS}/CPFRA/?DDN=1980-05-15&Localite=EVRY&Licence={LICENCE_CODE}"
fetch("https://{SERVER_ADDRESS}/CPFRA/?" + new URLSearchParams({ DDN: "1980-05-15", Localite: "EVRY", Licence: "{LICENCE_CODE}" })) .then(r => r.json()) .then(data => console.log(data));
import requests response = requests.get( "https://{SERVER_ADDRESS}/CPFRA/", params={ "DDN": "1980-05-15", "Localite": "EVRY", "Licence": "{LICENCE_CODE}", }, ) print(response.json())
<?php $params = http_build_query([ 'DDN' => '1980-05-15', 'Localite' => 'EVRY', 'Licence' => '{LICENCE_CODE}', ]); $ch = curl_init("https://{SERVER_ADDRESS}/CPFRA/?{$params}"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); $data = json_decode($response, true);
const axios = require('axios'); axios.get('https://{SERVER_ADDRESS}/CPFRA/', { params: { DDN: '1980-05-15', Localite: 'EVRY', Licence: '{LICENCE_CODE}' } }) .then(response => console.log(response.data));
HttpClient client = HttpClient.newHttpClient(); String url = "https://{SERVER_ADDRESS}/CPFRA/" + "?DDN=1980-05-15&Localite=EVRY&Licence={LICENCE_CODE}"; HttpRequest request = HttpRequest.newBuilder() .uri(URI.create(url)) .GET() .build(); HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body());
using var client = new HttpClient(); var url = "https://{SERVER_ADDRESS}/CPFRA/" + "?DDN=1980-05-15&Localite=EVRY&Licence={LICENCE_CODE}"; var response = await client.GetAsync(url); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body);
package main import ( "fmt" "io" "net/http" ) func main() { url := "https://{SERVER_ADDRESS}/CPFRA/" + "?DDN=1980-05-15&Localite=EVRY&Licence={LICENCE_CODE}" resp, err := http.Get(url) if err != nil { panic(err) } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println(string(body)) }
POSThttps://{SERVER_ADDRESS}/CPFRA/

Ajoutez les paramètres suivants dans le corps de la requête au format x-www-form-urlencoded. L'adresse du serveur reste dans l'URL.

Exemples de code

Recherche par nom de ville

curl -X POST "https://{SERVER_ADDRESS}/CPFRA/" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "DDN=1980-05-15" \ -d "Localite=EVRY" \ -d "Licence={LICENCE_CODE}"
fetch("https://{SERVER_ADDRESS}/CPFRA/", { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded" }, body: new URLSearchParams({ DDN: "1980-05-15", Localite: "EVRY", Licence: "{LICENCE_CODE}" }) }) .then(r => r.json()) .then(data => console.log(data));
import requests response = requests.post( "https://{SERVER_ADDRESS}/CPFRA/", data={ "DDN": "1980-05-15", "Localite": "EVRY", "Licence": "{LICENCE_CODE}", }, ) print(response.json())
<?php $ch = curl_init("https://{SERVER_ADDRESS}/CPFRA/"); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([ 'DDN' => '1980-05-15', 'Localite' => 'EVRY', 'Licence' => '{LICENCE_CODE}', ])); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); $data = json_decode($response, true);
const axios = require('axios'); const qs = require('querystring'); axios.post('https://{SERVER_ADDRESS}/CPFRA/', qs.stringify({ DDN: '1980-05-15', Localite: 'EVRY', Licence: '{LICENCE_CODE}' })) .then(response => console.log(response.data));
HttpClient client = HttpClient.newHttpClient(); String form = "DDN=1980-05-15&Localite=EVRY&Licence={LICENCE_CODE}"; HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://{SERVER_ADDRESS}/CPFRA/")) .header("Content-Type", "application/x-www-form-urlencoded") .POST(HttpRequest.BodyPublishers.ofString(form)) .build(); HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body());
using var client = new HttpClient(); var form = new Dictionary<string, string> { ["DDN"] = "1980-05-15", ["Localite"] = "EVRY", ["Licence"] = "{LICENCE_CODE}" }; var response = await client.PostAsync( "https://{SERVER_ADDRESS}/CPFRA/", new FormUrlEncodedContent(form)); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body);
package main import ( "fmt" "io" "net/http" "net/url" ) func main() { form := url.Values{} form.Set("DDN", "1980-05-15") form.Set("Localite", "EVRY") form.Set("Licence", "{LICENCE_CODE}") resp, err := http.PostForm("https://{SERVER_ADDRESS}/CPFRA/", form) if err != nil { panic(err) } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println(string(body)) }

Paramètres

Paramètre Description Obl / Opt
Licence Code de licence. Obligatoire
DDN Date de naissance au format YYYY-MM-DD. Obligatoire
INSEE Code INSEE. Optionnel
CP Code postal. Optionnel
Localite Nom de la ville. Optionnel
Remarque - INSEE, CP et Localite sont chacun optionnels individuellement, mais l'un d'entre eux est obligatoire — la requête échoue si aucun n'est fourni.

Réponse

Forme de la réponse - La réponse est un objet JSON indexé par une clé numérique arbitraire (par ex. "1", "2"…) — une entrée par correspondance candidate — plutôt qu'un tableau JSON. Parcourez les valeurs de l'objet plutôt que de supposer un ensemble fixe de clés.
Clé Valeurs possibles Description Type
Insee 75113 Code INSEE de la ville. STRING(10)
Localite Paris Nom de la ville. STRING(50)
Pays FR Code pays ISO 2. STRING(2)
CodePostal 75013 Code postal de la ville. STRING(10)
Status OK / KO Indique si la ville est valide pour la date de naissance donnée. STRING(2)

Exemple de réponse

Correspondance ambiguë de nom de ville
{ "1": {"Localite": "EVRY", "Pays": "FR", "Insee": "89162", "CodePostal": "89140", "Status": "OK"}, "3": {"Localite": "EVRY", "Pays": "FR", "Insee": "91228", "CodePostal": "91080", "Status": "KO"}, "2": {"Localite": "EVRY", "Pays": "FR", "Insee": "91228", "CodePostal": "91000", "Status": "KO"} }

Erreurs

HTTP Description
400 Requête invalide ou paramètre obligatoire manquant — par exemple un DDN ou Licence manquant, ou aucun des champs INSEE, CP ou Localite fourni.

Tester l'API

Cliquez sur le bouton ci-dessous pour tester cet endpoint en direct dans votre navigateur.

Ouvrir la console

Voir aussi

Associé à

Cet article vous a-t-il été utile ?

Utilisateurs qui ont trouvé cela utile : 0 sur 0