API Téléphone — Valider un numéro de téléphone (REST)

Support DQE
Support DQE
  • Mise à jour
Validation Téléphone - API RESTful

L'endpoint phonelookup valide et formate les numéros de téléphone fixes ou mobiles, et renvoie les informations d'opérateur, de localisation et de type, avec un statut d'activité optionnel.

Dans quel cas utiliser cet endpoint - Appelez phonelookup pour valider un numéro de téléphone et récupérer son opérateur, son type et sa localisation en une seule réponse JSON. Vous cherchez l'intégration XML/formulaire historique ? Consultez API Téléphone Classic (/TEL/) →

phonelookup

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}/v1/phonelookup/?Number={NUMBER}&Country={COUNTRY_CODE}&Licence={LICENCE_CODE}&Format={FORMAT}&Activity={ACTIVITY}&TimeOut={TIMEOUT}&Separator={SEPARATOR}

Exemples de code

Numéro mobile valide

curl "https://{SERVER_ADDRESS}/v1/phonelookup/?Number=0606060606&Country=FRA&Licence={LICENCE_CODE}"
fetch("https://{SERVER_ADDRESS}/v1/phonelookup/?" + new URLSearchParams({ Number: "0606060606", Country: "FRA", Licence: "{LICENCE_CODE}" })) .then(r => r.json()) .then(data => console.log(data));
import requests response = requests.get( "https://{SERVER_ADDRESS}/v1/phonelookup/", params={ "Number": "0606060606", "Country": "FRA", "Licence": "{LICENCE_CODE}", }, ) print(response.json())
<?php $params = http_build_query([ 'Number' => '0606060606', 'Country' => 'FRA', 'Licence' => '{LICENCE_CODE}', ]); $ch = curl_init("https://{SERVER_ADDRESS}/v1/phonelookup/?{$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}/v1/phonelookup/', { params: { Number: '0606060606', Country: 'FRA', Licence: '{LICENCE_CODE}' } }) .then(response => console.log(response.data));
HttpClient client = HttpClient.newHttpClient(); String url = "https://{SERVER_ADDRESS}/v1/phonelookup/" + "?Number=0606060606&Country=FRA&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}/v1/phonelookup/" + "?Number=0606060606&Country=FRA&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}/v1/phonelookup/" + "?Number=0606060606&Country=FRA&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}/v1/phonelookup/

Envoyez tous les paramètres dans le corps de la requête au format Content-Type: application/x-www-form-urlencoded. L'adresse du serveur reste dans l'URL.

Exemples de code

Numéro mobile valide

curl -X POST "https://{SERVER_ADDRESS}/v1/phonelookup/" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "Number=0606060606" \ -d "Country=FRA" \ -d "Licence={LICENCE_CODE}"
fetch("https://{SERVER_ADDRESS}/v1/phonelookup/", { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded" }, body: new URLSearchParams({ Number: "0606060606", Country: "FRA", Licence: "{LICENCE_CODE}" }) }) .then(r => r.json()) .then(data => console.log(data));
import requests response = requests.post( "https://{SERVER_ADDRESS}/v1/phonelookup/", data={ "Number": "0606060606", "Country": "FRA", "Licence": "{LICENCE_CODE}", }, ) print(response.json())
<?php $ch = curl_init("https://{SERVER_ADDRESS}/v1/phonelookup/"); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([ 'Number' => '0606060606', 'Country' => 'FRA', '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}/v1/phonelookup/', qs.stringify({ Number: '0606060606', Country: 'FRA', Licence: '{LICENCE_CODE}' })) .then(response => console.log(response.data));
HttpClient client = HttpClient.newHttpClient(); String form = "Number=0606060606&Country=FRA&Licence={LICENCE_CODE}"; HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://{SERVER_ADDRESS}/v1/phonelookup/")) .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> { ["Number"] = "0606060606", ["Country"] = "FRA", ["Licence"] = "{LICENCE_CODE}" }; var response = await client.PostAsync( "https://{SERVER_ADDRESS}/v1/phonelookup/", 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("Number", "0606060606") form.Set("Country", "FRA") form.Set("Licence", "{LICENCE_CODE}") resp, err := http.PostForm("https://{SERVER_ADDRESS}/v1/phonelookup/", 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 / Fac
Number Numéro de téléphone à valider. Obligatoire
Country Code pays ISO à 3 lettres. Obligatoire
Licence Votre clé de licence DQE. Contactez le support si vous n'en avez pas encore une. Obligatoire
Format Format de sortie souhaité. Voir le tableau des valeurs de format ci-dessous. Optionnel
Activity Y si vous souhaitez obtenir l'activité du numéro de téléphone. Optionnel
TimeOut Temps de requête maximal pour la vérification, en secondes. Exemple : 0.5 pour 500 ms. Optionnel
Separator Caractère séparateur utilisé dans le numéro de téléphone formaté. Valeurs acceptées : - et .. Ne fonctionne que sur les formats qui utilisent des espaces (1, 2, 3, 4, 6) Optionnel

Valeurs de format

Les valeurs suivantes s'appliquent au paramètre Format dans les requêtes GET et POST.

Valeur Description Exemples (Allemagne / France / États-Unis)
0 Format national sans espaces 0301234567 / 0123456789 / (202)555-0123
1 Format national avec regroupement de chiffres propre au pays 030 1234567 / 01 23 45 67 89 / (202) 555-0123
2 Format international avec regroupement de chiffres propre au pays +49 30 1234567 / +33 1 23 45 67 89 / +1 202-555-0123
3 Format international avec espace entre l'indicatif pays et le numéro d'abonné +49 301234567 / +33 123456789 / +1 2025550123
4 Format international avec préfixe interurbain et numéro d'abonné compact +49 (0)301234567 / +33 (0)123456789 / +1 (0)2025550123
5 Format international sans espaces +49301234567 / +33123456789 / +12025550123
6 Format international avec préfixe interurbain et regroupement de chiffres propre au pays +49 (0) 30 1234567 / +33 (0) 1 23 45 67 89 / +1 (0) (202) 555-0123
7 Format national avec regroupement de chiffres propre au pays séparé par des points 030.1234567 / 01.23.45.67.89 / (202).555-0123
8 Format international avec regroupement de chiffres propre au pays séparé par des points +49.30.1234567 / +33.1.23.45.67.89 / +1.202-555-0123
9 Format international sans espaces et sans signe plus initial 49301234567 / 33123456789 / 1202-555-0123

Réponse

En cas de succès, l'API renvoie un objet JSON contenant le nombre de résultats et un tableau des numéros de téléphone validés.

Lecture métier : IdError porte le résultat détaillé de la validation (0 : invalide ou inexistant, 1 : valide et attribué, 2 : syntaxe valide uniquement, non attribué) — consultez la liste complète dans la référence API Response Codes.
Clé Description Type
Found Nombre de numéros de téléphone renvoyés. Integer
Phones Tableau des résultats de validation, une entrée par numéro de téléphone soumis. Array
IdError Code de retour de validation. Voir la référence API Response Codes. String
Ported Y si le numéro a été porté ; vide si non disponible. String
InputNumber Numéro de téléphone tel que soumis dans la requête. String
Carrier Opérateur actuel du numéro de téléphone. String
Location Localisation géographique associée au numéro de téléphone. String
OldCarrier Opérateur précédent du numéro de téléphone, lorsqu'il est connu. String
NumberFormatted Numéro de téléphone formaté selon le format sélectionné. String
Type MOBILE ou FIXED_LINE ou Vide. String

Exemple de réponse

Numéro mobile valide
{ "Found": 1, "Phones": [ { "IdError": "1", "Ported": "", "InputNumber": "0606060606", "Carrier": "E*MESSAGE WIRELESS INFORMATION SERVICES FRANCE", "Location": "METROPOLE", "OldCarrier": "E*MESSAGE WIRELESS INFORMATION SERVICES FRANCE", "NumberFormatted": "0606060606", "Type": "MOBILE" } ] }

Erreurs

HTTP Type d'erreur Corps de la réponse
400 Paramètre obligatoire manquant ou vide (ex. Number)
{"status": 400, "message": "Missing parameters", "details": "Number", "error": "bad request"}
401 Clé de licence invalide ou non autorisée
{"status": 401, "message": "Your licence is not allowed to cover this functionnality", "details": "deded", "error": "unauthorized_client"}

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