N-Ways
Documentação para programadoresValidação de endereços

Validação de endereços

Verificar e completar um endereço: um veredicto, as suas partes, o seu ponto e o seu código postal.

Nota:

Envie a sua chave com key=A_SUA_CHAVE_API no endereço, ou no cabeçalho X-NWays-Api-Key. Chaves de API

Endereço base: https://nways.ng/maps/v1

Este endereço existe, onde fica, qual é a forma correta?

POST https://nways.ng/maps/v1/addresses/validate

Um código postal NIPOST, endereço GhanaPost GPS ou Plus Code presente no endereço é resolvido primeiro; as palavras são geocodificadas e confrontadas com o código; os componentes vêm do que está no ponto, e um código postal NIPOST em falta é preenchido a partir do edifício lá existente (verdict.inferredPostcode). Motivos: ADDRESS_REQUIRED, COUNTRY_INVALID, NEAR_INVALID, LANG_INVALID.

Parâmetros

NomeOndeTipoDescrição
fieldsconsultastringLista separada por vírgulas dos campos a manter em cada resultado (a.b entra em objetos; id é sempre mantido; * = todos).

Corpo do pedido

CampoTipoDescrição
addressstringObrigatório. Até 300 caracteres.
countrystringUm de: NG, GH, BJ, TG, GA, CI, LR, GN, SL, GW, SN, CM, BF, CV, GM.
nearLatLng
near.latnumberObrigatório. ≥ -90, ≤ 90.
near.lngnumberObrigatório. ≥ -180, ≤ 180.
langstringUm de: en, fr, pt.
cURL
curl -X POST "https://nways.ng/maps/v1/addresses/validate" \
  -H "X-NWays-Api-Key: A_SUA_CHAVE_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()

Resposta

O veredicto

CampoTipoDescrição
verdictobjectObrigatório.
verdict.statusstringObrigatório. Um de: VALID, VALID_WITH_CORRECTIONS, PARTIAL, UNRESOLVED, INVALID.
verdict.granularitystringObrigatório. Um de: PREMISE, POINT, ROUTE, NEIGHBOURHOOD, LOCALITY, REGION, NONE.
verdict.confidencenumberObrigatório. ≥ 0, ≤ 1.
verdict.codesAgreeboolean | nullObrigatório.
verdict.inferredPostcodeboolean
formattedAddressstringObrigatório.
componentsobject[]Obrigatório.
components[].typestringObrigatório. Um de: postcode, ghanapost, pluscode, premise, street, neighbourhood, locality, lga, region, country.
components[].textstringObrigatório.
components[].codestring
components[].sourcestringObrigatório. Um de: input, corrected, inferred, unconfirmed.
locationPoint | nullObrigatório.
accuracyMnumber
postcodePostcode | nullObrigatório.
plusCodestring
issuesobject[]Obrigatório.
issues[].codestringObrigatório. POSTCODE_INVALID, POSTCODE_UNKNOWN, GHANAPOST_UNKNOWN, PLUSCODE_UNRESOLVED, LEGACY_POSTCODE, CODE_ADDRESS_MISMATCH, COUNTRY_MISMATCH, WORDS_NOT_FOUND, NOT_FOUND
issues[].messagestringObrigatório.
attributionstringObrigatório.
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"
}

Erros

  • default Erro