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
| Nome | Onde | Tipo | Descrição |
|---|---|---|---|
fields | consulta | string | Lista separada por vírgulas dos campos a manter em cada resultado (a.b entra em objetos; id é sempre mantido; * = todos). |
Corpo do pedido
| Campo | Tipo | Descrição |
|---|---|---|
address | string | Obrigatório. Até 300 caracteres. |
country | string | Um de: NG, GH, BJ, TG, GA, CI, LR, GN, SL, GW, SN, CM, BF, CV, GM. |
near | LatLng | |
near.lat | number | Obrigatório. ≥ -90, ≤ 90. |
near.lng | number | Obrigatório. ≥ -180, ≤ 180. |
lang | string | Um 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
| Campo | Tipo | Descrição |
|---|---|---|
verdict | object | Obrigatório. |
verdict.status | string | Obrigatório. Um de: VALID, VALID_WITH_CORRECTIONS, PARTIAL, UNRESOLVED, INVALID. |
verdict.granularity | string | Obrigatório. Um de: PREMISE, POINT, ROUTE, NEIGHBOURHOOD, LOCALITY, REGION, NONE. |
verdict.confidence | number | Obrigatório. ≥ 0, ≤ 1. |
verdict.codesAgree | boolean | null | Obrigatório. |
verdict.inferredPostcode | boolean | |
formattedAddress | string | Obrigatório. |
components | object[] | Obrigatório. |
components[].type | string | Obrigatório. Um de: postcode, ghanapost, pluscode, premise, street, neighbourhood, locality, lga, region, country. |
components[].text | string | Obrigatório. |
components[].code | string | |
components[].source | string | Obrigatório. Um de: input, corrected, inferred, unconfirmed. |
location | Point | null | Obrigatório. |
accuracyM | number | |
postcode | Postcode | null | Obrigatório. |
plusCode | string | |
issues | object[] | Obrigatório. |
issues[].code | string | Obrigatório. POSTCODE_INVALID, POSTCODE_UNKNOWN, GHANAPOST_UNKNOWN, PLUSCODE_UNRESOLVED, LEGACY_POSTCODE, CODE_ADDRESS_MISMATCH, COUNTRY_MISMATCH, WORDS_NOT_FOUND, NOT_FOUND |
issues[].message | string | Obrigatório. |
attribution | string | Obrigató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
defaultErro