N-Ways
Documentation développeursValidation d’adresse

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

NomOùTypeDescription
fieldsrequêtestringListe 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

ChampTypeDescription
addressstringObligatoire. 300 caractères au plus.
countrystringAu choix: NG, GH, BJ, TG, GA, CI, LR, GN, SL, GW, SN, CM, BF, CV, GM.
nearLatLng
near.latnumberObligatoire. ≥ -90, ≤ 90.
near.lngnumberObligatoire. ≥ -180, ≤ 180.
langstringAu 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

ChampTypeDescription
verdictobjectObligatoire.
verdict.statusstringObligatoire. Au choix: VALID, VALID_WITH_CORRECTIONS, PARTIAL, UNRESOLVED, INVALID.
verdict.granularitystringObligatoire. Au choix: PREMISE, POINT, ROUTE, NEIGHBOURHOOD, LOCALITY, REGION, NONE.
verdict.confidencenumberObligatoire. ≥ 0, ≤ 1.
verdict.codesAgreeboolean | nullObligatoire.
verdict.inferredPostcodeboolean
formattedAddressstringObligatoire.
componentsobject[]Obligatoire.
components[].typestringObligatoire. Au choix: postcode, ghanapost, pluscode, premise, street, neighbourhood, locality, lga, region, country.
components[].textstringObligatoire.
components[].codestring
components[].sourcestringObligatoire. Au choix: input, corrected, inferred, unconfirmed.
locationPoint | nullObligatoire.
accuracyMnumber
postcodePostcode | nullObligatoire.
plusCodestring
issuesobject[]Obligatoire.
issues[].codestringObligatoire. POSTCODE_INVALID, POSTCODE_UNKNOWN, GHANAPOST_UNKNOWN, PLUSCODE_UNRESOLVED, LEGACY_POSTCODE, CODE_ADDRESS_MISMATCH, COUNTRY_MISMATCH, WORDS_NOT_FOUND, NOT_FOUND
issues[].messagestringObligatoire.
attributionstringObligatoire.
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

  • default Erreur