Validation d’adresse
Vérifier et compléter une adresse : un verdict, ses éléments, son point et son code postal.
Remarque :
Envoyez votre clé avec key=VOTRE_CLE_API dans l’adresse, ou dans l’en-tête X-NWays-Api-Key. Clés d’API
Adresse de base : https://nways.ng/maps/v1
Cette adresse existe-t-elle, où se trouve-t-elle, quelle est sa forme correcte ?
POST https://nways.ng/maps/v1/addresses/validate
Un code postal NIPOST, une adresse GhanaPost GPS ou un Plus Code présent dans l’adresse est résolu en premier ; les mots sont géocodés et comparés au code ; les composants viennent de ce qui se trouve au point, et un code postal NIPOST manquant est complété à partir du bâtiment qui s’y trouve (verdict.inferredPostcode). Raisons : ADDRESS_REQUIRED, COUNTRY_INVALID, NEAR_INVALID, LANG_INVALID.
Paramètres
| Nom | Où | Type | Description |
|---|---|---|---|
fields | requête | string | Liste séparée par des virgules des champs à garder dans chaque résultat (a.b descend dans les objets ; id est toujours gardé ; * = tous). |
Corps de la requête
| Champ | Type | Description |
|---|---|---|
address | string | Obligatoire. 300 caractères au plus. |
country | string | Au choix: NG, GH, BJ, TG, GA, CI, LR, GN, SL, GW, SN, CM, BF, CV, GM. |
near | LatLng | |
near.lat | number | Obligatoire. ≥ -90, ≤ 90. |
near.lng | number | Obligatoire. ≥ -180, ≤ 180. |
lang | string | Au choix: en, fr, pt. |
cURL
curl -X POST "https://nways.ng/maps/v1/addresses/validate" \
-H "X-NWays-Api-Key: VOTRE_CLE_API" \
-H "Content-Type: application/json" \
-d '{"address":"12 Admiralty Way, Lekki, LA 08 A09 DB 09","country":"NG"}'JavaScript
const res = await fetch('https://nways.ng/maps/v1/addresses/validate', {
method: 'POST',
headers: { 'X-NWays-Api-Key': process.env.NWAYS_API_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"address": "12 Admiralty Way, Lekki, LA 08 A09 DB 09",
"country": "NG"
}),
})
const data = await res.json()Python
import os
import requests
res = requests.post(
"https://nways.ng/maps/v1/addresses/validate",
headers={"X-NWays-Api-Key": os.environ["NWAYS_API_KEY"]},
json={"address": "12 Admiralty Way, Lekki, LA 08 A09 DB 09", "country": "NG"},
timeout=10,
)
data = res.json()Réponse
Le verdict
| Champ | Type | Description |
|---|---|---|
verdict | object | Obligatoire. |
verdict.status | string | Obligatoire. Au choix: VALID, VALID_WITH_CORRECTIONS, PARTIAL, UNRESOLVED, INVALID. |
verdict.granularity | string | Obligatoire. Au choix: PREMISE, POINT, ROUTE, NEIGHBOURHOOD, LOCALITY, REGION, NONE. |
verdict.confidence | number | Obligatoire. ≥ 0, ≤ 1. |
verdict.codesAgree | boolean | null | Obligatoire. |
verdict.inferredPostcode | boolean | |
formattedAddress | string | Obligatoire. |
components | object[] | Obligatoire. |
components[].type | string | Obligatoire. Au choix: postcode, ghanapost, pluscode, premise, street, neighbourhood, locality, lga, region, country. |
components[].text | string | Obligatoire. |
components[].code | string | |
components[].source | string | Obligatoire. Au choix: input, corrected, inferred, unconfirmed. |
location | Point | null | Obligatoire. |
accuracyM | number | |
postcode | Postcode | null | Obligatoire. |
plusCode | string | |
issues | object[] | Obligatoire. |
issues[].code | string | Obligatoire. POSTCODE_INVALID, POSTCODE_UNKNOWN, GHANAPOST_UNKNOWN, PLUSCODE_UNRESOLVED, LEGACY_POSTCODE, CODE_ADDRESS_MISMATCH, COUNTRY_MISMATCH, WORDS_NOT_FOUND, NOT_FOUND |
issues[].message | string | Obligatoire. |
attribution | string | Obligatoire. |
200 OK
{
"verdict": {
"status": "VALID",
"granularity": "PREMISE",
"confidence": 0,
"codesAgree": true,
"inferredPostcode": true
},
"formattedAddress": "string",
"components": [
{
"type": "postcode",
"text": "string",
"code": "string",
"source": "input"
}
],
"location": {
"type": "string",
"coordinates": [
0
]
},
"accuracyM": 0,
"postcode": {
"code": "LA08A09DB09",
"display": "LA 08 A09 DB 09",
"components": {
"state": "LA",
"stateName": "Lagos",
"lga": "08",
"lgaName": "Eti-Osa",
"district": "A09",
"area": "DB",
"building": "09"
},
"location": {
"type": "string",
"coordinates": [
0
]
},
"name": "string",
"address": "string",
"buildingType": "string",
"entrances": [
{
"location": {
"type": "string",
"coordinates": []
},
"kind": "main",
"verified": true
}
],
"plusCode": "string",
"country": "string",
"source": "nipost",
"estimated": true,
"accuracyM": 0,
"distanceM": 0,
"attribution": "string"
},
"plusCode": "string",
"issues": [
{
"code": "CODE_ADDRESS_MISMATCH",
"message": "string"
}
],
"attribution": "string"
}Erreurs
defaultErreur