N-Ways
Developer docsAddress validation

Address validation

Catch a wrong or incomplete address before a rider sets off: a verdict, the corrected address and postcode, and a point to deliver to.

On this page

A rider loses time and money on a wrong address. Address validation checks one before you accept the order: is it real, where exactly is it, and how should it be written? It understands NIPOST postcodes, GhanaPost GPS codes and Plus Codes in the text, and fills in the postcode when it’s missing.

Check an address

cURL
curl -X POST "https://nways.ng/maps/v1/addresses/validate?key=YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"address": "12 Allen Avenue, Ikeja, Lagos", "country": "NG"}'
JavaScript
import { createClient } from '@nways/maps'

const nways = createClient({ key: 'YOUR_API_KEY' })
const check = await nways.validateAddress('12 Allen Avenue, Ikeja, Lagos', { country: 'NG' })
if (check.verdict.status === 'UNRESOLVED') askTheCustomerAgain()
FieldDescription
addressRequired. The address as written, up to 300 characters.
countryNG, GH, BJ, TG, GA, CI, LR, GN, SL, GW, SN, CM, BF or CV: where to look.
near{ lat, lng }: where it should be (the customer’s last delivery, the shop’s area).
langen or fr.

The answer

FieldDescription
verdict.statusVALID (found, to the building), VALID_WITH_CORRECTIONS (found, with parts corrected or added), PARTIAL (only to the street or area), UNRESOLVED (not found), INVALID (a code that can’t exist).
verdict.granularityWhat it’s precise to: PREMISE, POINT, ROUTE (the street), NEIGHBOURHOOD, LOCALITY, REGION or NONE.
verdict.confidence0 to 1.
verdict.codesAgreeWhen the text has both a code and words: whether they point to the same place.
formattedAddressThe address as it should be written.
componentsIts parts (premise, street, neighbourhood, locality, lga, region, postcode…), each with its source: input (confirmed), corrected, inferred (added by us) or unconfirmed.
location, accuracyMWhere to deliver, as a GeoJSON point, and how close that is.
postcodeIn Nigeria, the building’s NIPOST postcode with its entrances, when N-Ways knows them.
issuesWhat’s wrong or worth checking, each with a code and a message.

What to do with it

VerdictSuggested action
VALIDAccept. Store location and the postcode with the order.
VALID_WITH_CORRECTIONSAccept, and show the customer the formattedAddress to confirm.
PARTIALAsk for a landmark, a house number or a phone number for the rider.
UNRESOLVED, INVALIDAsk the customer to drop a pin on the map instead.