N-Ways
Developer docsGeocoding

Geocoding

Search for places and addresses, what's at a point, and NIPOST, GhanaPost and Plus Code lookups.

On this page
Note:

Send your key as key=YOUR_API_KEY on the address, or in the X-NWays-Api-Key header. API keys

Base address: https://nways.ng/maps/v1

Search for places, addresses and codes

GET https://nways.ng/maps/v1/geocode

Places, streets, addresses, landmarks, businesses and areas in every covered country, with typos and local nicknames; a NIPOST postcode finds its building, a GhanaPost GPS address its point. Nearer results first when near is given. Reasons: QUERY_REQUIRED, QUERY_TOO_LONG, NEAR_INVALID, COUNTRY_INVALID, LIMIT_INVALID, LANG_INVALID.

Parameters

NameInTypeDescription
qquerystringRequired. Up to 200 characters.
nearquerystringlat,lng: rank and pick results near it.
countryquerystringComma list of NG, GH, BJ, TG, GA, CI, LR, GN, SL, GW, SN, CM, BF, CV, GM.
limitqueryintegerDefault: 8. ≥ 1, ≤ 20.
langquerystringOne of: en, fr, pt. Default: en.
fieldsquerystringComma list of the fields to keep in each result (a.b reaches into objects; id is always kept; * = all).
cURL
curl "https://nways.ng/maps/v1/geocode?q=Ikeja+City+Mall" \
  -H "X-NWays-Api-Key: YOUR_API_KEY"
JavaScript
const res = await fetch('https://nways.ng/maps/v1/geocode?q=Ikeja+City+Mall', {
  headers: { 'X-NWays-Api-Key': process.env.NWAYS_API_KEY },
})
const data = await res.json()
Python
import os
import requests

res = requests.get(
    "https://nways.ng/maps/v1/geocode?q=Ikeja+City+Mall",
    headers={"X-NWays-Api-Key": os.environ["NWAYS_API_KEY"]},
    timeout=10,
)
data = res.json()

Response

Results

FieldTypeDescription
resultsResult[]Required.
results[].idstringRequired.
results[].namestringRequired.
results[].typestringRequired. address, street, business, landmark, building, postcode, ghanapost, or an area: neighbourhood, suburb, village, town, city, state…
results[].categorystring
results[].locationPointRequired.
results[].location.typestringRequired.
results[].location.coordinatesnumber[]Required. [lng, lat] At least 2 items, at most 2 items.
results[].bboxnumber[]west, south, east, north (areas) At least 4 items, at most 4 items.
results[].formattedAddressstring
results[].postcodestringNIPOST postcode, compact
results[].ghanaPoststring
results[].plusCodestringRequired.
results[].countrystring
results[].distanceMnumberFrom near (or the point asked about).
results[].estimatedbooleanThe point is an estimate, within accuracyM.
results[].accuracyMnumber
results[].placeIdstringA business: its id for /places/{id}.
results[].attributionstring
didYouMeanstring
attributionstringRequired.
200 OK
{
  "results": [
    {
      "id": "osm:w568367632",
      "name": "Ikeja City Mall",
      "type": "landmark",
      "category": "shopping",
      "location": {
        "type": "string",
        "coordinates": [
          0
        ]
      },
      "bbox": [
        0
      ],
      "formattedAddress": "Ikeja, Lagos",
      "postcode": "LA08A09DB09",
      "ghanaPost": "GA-183-8164",
      "plusCode": "6FR5J975+P4W",
      "country": "NG",
      "distanceM": 0,
      "estimated": true,
      "accuracyM": 0,
      "placeId": "string",
      "attribution": "string"
    }
  ],
  "didYouMean": "string",
  "attribution": "string"
}

Errors

  • default Error

What's at a point

GET https://nways.ng/maps/v1/reverse

One shape in every covered country: the country and region, the Plus Code, Nigeria's NIPOST postcode (the building within reach), Ghana's nearest known GhanaPost GPS address, and the nearest named address, street or landmark (else the area), with a one-line address. Reasons: LAT_LNG_REQUIRED, RADIUS_INVALID, LANG_INVALID.

Parameters

NameInTypeDescription
latquerynumberRequired.
lngquerynumberRequired.
radiusquerynumberHow far to look for an address, street or landmark (metres). Default: 200. ≥ 10, ≤ 1000.
langquerystringOne of: en, fr, pt. Default: en.
fieldsquerystringComma list of the fields to keep in each result (a.b reaches into objects; id is always kept; * = all).
cURL
curl "https://nways.ng/maps/v1/reverse?lat=6.4474&lng=3.472" \
  -H "X-NWays-Api-Key: YOUR_API_KEY"
JavaScript
const res = await fetch('https://nways.ng/maps/v1/reverse?lat=6.4474&lng=3.472', {
  headers: { 'X-NWays-Api-Key': process.env.NWAYS_API_KEY },
})
const data = await res.json()
Python
import os
import requests

res = requests.get(
    "https://nways.ng/maps/v1/reverse?lat=6.4474&lng=3.472",
    headers={"X-NWays-Api-Key": os.environ["NWAYS_API_KEY"]},
    timeout=10,
)
data = res.json()

Response

What's there

FieldTypeDescription
locationPointRequired.
location.typestringRequired.
location.coordinatesnumber[]Required. [lng, lat] At least 2 items, at most 2 items.
plusCodestringRequired.
countryArea | nullRequired.
regionArea | nullRequired.
formattedAddressstring
postcodePostcode | nullRequired. Nigeria: the building's NIPOST postcode, when one is within reach.
ghanaPoststring | nullRequired. Ghana: the nearest known GhanaPost GPS address (within 100 m).
nearestResult | nullRequired.
attributionstringRequired.
200 OK
{
  "location": {
    "type": "string",
    "coordinates": [
      0
    ]
  },
  "plusCode": "string",
  "country": {
    "code": "NG-LA",
    "name": "Lagos State",
    "nameFr": "string",
    "namePt": "string"
  },
  "region": {
    "code": "NG-LA",
    "name": "Lagos State",
    "nameFr": "string",
    "namePt": "string"
  },
  "formattedAddress": "12 Admiralty Way, Lekki, Lagos State, Nigeria",
  "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"
  },
  "ghanaPost": "string",
  "nearest": {
    "id": "osm:w568367632",
    "name": "Ikeja City Mall",
    "type": "landmark",
    "category": "shopping",
    "location": {
      "type": "string",
      "coordinates": [
        0
      ]
    },
    "bbox": [
      0
    ],
    "formattedAddress": "Ikeja, Lagos",
    "postcode": "LA08A09DB09",
    "ghanaPost": "GA-183-8164",
    "plusCode": "6FR5J975+P4W",
    "country": "NG",
    "distanceM": 0,
    "estimated": true,
    "accuracyM": 0,
    "placeId": "string",
    "attribution": "string"
  },
  "attribution": "string"
}

Errors

  • default Error

A NIPOST postcode

GET https://nways.ng/maps/v1/postcodes/{code}

The building a NIPOST postcode names (any written form: LA 08 A09 DB 09, la-08-a09-db-09), its entrances (route to the first), its parts and their names; or, for a code we haven't placed yet, where it is estimated to be from the codes around it (estimated, accuracyM). Reasons: POSTCODE_INVALID, POSTCODE_NOT_FOUND_CHECK, POSTCODE_NOT_NIPOST.

Parameters

NameInTypeDescription
codepathstringRequired.
fieldsquerystringComma list of the fields to keep in each result (a.b reaches into objects; id is always kept; * = all).
cURL
curl "https://nways.ng/maps/v1/postcodes/LA08A09DB09" \
  -H "X-NWays-Api-Key: YOUR_API_KEY"
JavaScript
const res = await fetch('https://nways.ng/maps/v1/postcodes/LA08A09DB09', {
  headers: { 'X-NWays-Api-Key': process.env.NWAYS_API_KEY },
})
const data = await res.json()
Python
import os
import requests

res = requests.get(
    "https://nways.ng/maps/v1/postcodes/LA08A09DB09",
    headers={"X-NWays-Api-Key": os.environ["NWAYS_API_KEY"]},
    timeout=10,
)
data = res.json()

Response

The postcode

FieldTypeDescription
codestringRequired.
displaystringRequired.
componentsPostcodeComponentsRequired.
components.statestringRequired.
components.stateNamestring
components.lgastringRequired.
components.lgaNamestring
components.districtstringRequired.
components.areastringRequired.
components.buildingstringRequired.
locationPointRequired.
location.typestringRequired.
location.coordinatesnumber[]Required. [lng, lat] At least 2 items, at most 2 items.
namestring
addressstring
buildingTypestring
entrancesEntrance[]Required. Verified first, main first: route to the first.
entrances[].locationPointRequired.
entrances[].location.typestringRequired.
entrances[].location.coordinatesnumber[]Required. [lng, lat] At least 2 items, at most 2 items.
entrances[].kindstringRequired. One of: main, gate, pedestrian, service.
entrances[].verifiedbooleanRequired.
plusCodestringRequired.
countrystringRequired.
sourcestringRequired. One of: nipost, osm, user, estimate.
estimatedbooleanRequired.
accuracyMnumber
distanceMnumberReverse geocoding: from the point asked about.
attributionstringRequired.
200 OK
{
  "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": [
          0
        ]
      },
      "kind": "main",
      "verified": true
    }
  ],
  "plusCode": "string",
  "country": "string",
  "source": "nipost",
  "estimated": true,
  "accuracyM": 0,
  "distanceM": 0,
  "attribution": "string"
}

Errors

  • default Error

Up to 100 NIPOST postcodes at once

POST https://nways.ng/maps/v1/postcodes/batch

Each code counts as one geocode call. An answer per code, in order, with its own error when it has one. Reasons (whole call) CODES_INVALID.

Parameters

NameInTypeDescription
fieldsquerystringComma list of the fields to keep in each result (a.b reaches into objects; id is always kept; * = all).

Request body

FieldTypeDescription
codesstring[]Required. At least 1 items, at most 100 items.
cURL
curl -X POST "https://nways.ng/maps/v1/postcodes/batch" \
  -H "X-NWays-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"codes":["LA08A09DB09","FC 02 A09 DB 09"]}'
JavaScript
const res = await fetch('https://nways.ng/maps/v1/postcodes/batch', {
  method: 'POST',
  headers: { 'X-NWays-Api-Key': process.env.NWAYS_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "codes": [
      "LA08A09DB09",
      "FC 02 A09 DB 09"
    ]
  }),
})
const data = await res.json()
Python
import os
import requests

res = requests.post(
    "https://nways.ng/maps/v1/postcodes/batch",
    headers={"X-NWays-Api-Key": os.environ["NWAYS_API_KEY"]},
    json={"codes": ["LA08A09DB09", "FC 02 A09 DB 09"]},
    timeout=10,
)
data = res.json()

Response

One result per code

FieldTypeDescription
resultsobject[]Required.
results[].querystringRequired.
results[].postcodePostcode
results[].postcode.codestringRequired.
results[].postcode.displaystringRequired.
results[].postcode.componentsPostcodeComponentsRequired.
results[].postcode.components.statestringRequired.
results[].postcode.components.stateNamestring
results[].postcode.components.lgastringRequired.
results[].postcode.components.lgaNamestring
results[].postcode.components.districtstringRequired.
results[].postcode.components.areastringRequired.
results[].postcode.components.buildingstringRequired.
results[].postcode.locationPointRequired.
results[].postcode.location.typestringRequired.
results[].postcode.location.coordinatesnumber[]Required. [lng, lat] At least 2 items, at most 2 items.
results[].postcode.namestring
results[].postcode.addressstring
results[].postcode.buildingTypestring
results[].postcode.entrancesEntrance[]Required. Verified first, main first: route to the first.
results[].postcode.entrances[].locationPointRequired.
results[].postcode.entrances[].kindstringRequired. One of: main, gate, pedestrian, service.
results[].postcode.entrances[].verifiedbooleanRequired.
results[].postcode.plusCodestringRequired.
results[].postcode.countrystringRequired.
results[].postcode.sourcestringRequired. One of: nipost, osm, user, estimate.
results[].postcode.estimatedbooleanRequired.
results[].postcode.accuracyMnumber
results[].postcode.distanceMnumberReverse geocoding: from the point asked about.
results[].postcode.attributionstringRequired.
results[].errorItemError
results[].error.codeintegerRequired.
results[].error.reasonstringRequired.
results[].error.messagestringRequired.
attributionstringRequired.
200 OK
{
  "results": [
    {
      "query": "string",
      "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": []
        },
        "name": "string",
        "address": "string",
        "buildingType": "string",
        "entrances": [
          {}
        ],
        "plusCode": "string",
        "country": "string",
        "source": "nipost",
        "estimated": true,
        "accuracyM": 0,
        "distanceM": 0,
        "attribution": "string"
      },
      "error": {
        "code": 0,
        "reason": "string",
        "message": "string"
      }
    }
  ],
  "attribution": "string"
}

Errors

  • default Error

A GhanaPost GPS address

GET https://nways.ng/maps/v1/ghanapost/{code}

Where a GhanaPost GPS digital address is: mapped in OpenStreetMap or published by its owner, else (in districts where the method has been checked) estimated from the codes mapped around it (estimated, accuracyM). Never calls Ghana Post. Reasons: GHANAPOST_INVALID, GHANAPOST_UNKNOWN.

Parameters

NameInTypeDescription
codepathstringRequired.
fieldsquerystringComma list of the fields to keep in each result (a.b reaches into objects; id is always kept; * = all).
cURL
curl "https://nways.ng/maps/v1/ghanapost/GA-183-8164" \
  -H "X-NWays-Api-Key: YOUR_API_KEY"
JavaScript
const res = await fetch('https://nways.ng/maps/v1/ghanapost/GA-183-8164', {
  headers: { 'X-NWays-Api-Key': process.env.NWAYS_API_KEY },
})
const data = await res.json()
Python
import os
import requests

res = requests.get(
    "https://nways.ng/maps/v1/ghanapost/GA-183-8164",
    headers={"X-NWays-Api-Key": os.environ["NWAYS_API_KEY"]},
    timeout=10,
)
data = res.json()

Response

The address

FieldTypeDescription
idstringRequired.
namestringRequired.
typestringRequired. address, street, business, landmark, building, postcode, ghanapost, or an area: neighbourhood, suburb, village, town, city, state…
categorystring
locationPointRequired.
location.typestringRequired.
location.coordinatesnumber[]Required. [lng, lat] At least 2 items, at most 2 items.
bboxnumber[]west, south, east, north (areas) At least 4 items, at most 4 items.
formattedAddressstring
postcodestringNIPOST postcode, compact
ghanaPoststring
plusCodestringRequired.
countrystring
distanceMnumberFrom near (or the point asked about).
estimatedbooleanThe point is an estimate, within accuracyM.
accuracyMnumber
placeIdstringA business: its id for /places/{id}.
attributionstring
200 OK
{
  "id": "osm:w568367632",
  "name": "Ikeja City Mall",
  "type": "landmark",
  "category": "shopping",
  "location": {
    "type": "string",
    "coordinates": [
      0
    ]
  },
  "bbox": [
    0
  ],
  "formattedAddress": "Ikeja, Lagos",
  "postcode": "LA08A09DB09",
  "ghanaPost": "GA-183-8164",
  "plusCode": "6FR5J975+P4W",
  "country": "NG",
  "distanceM": 0,
  "estimated": true,
  "accuracyM": 0,
  "placeId": "string",
  "attribution": "string"
}

Errors

  • default Error

A Plus Code's area and what's there

GET https://nways.ng/maps/v1/pluscodes/{code}

A full Plus Code (6FR5J975+P4W), or a short one with a reference: near=lat,lng, or a town after it (J975+P4 Ikeja, URL-encoded). The answer is the reverse geocoding of the code's centre, with the full code and its bounds. Reasons: PLUSCODE_INVALID, PLUSCODE_SHORT, LOCALITY_NOT_FOUND, NEAR_INVALID.

Parameters

NameInTypeDescription
codepathstringRequired.
nearquerystringlat,lng: rank and pick results near it.
langquerystringOne of: en, fr, pt. Default: en.
fieldsquerystringComma list of the fields to keep in each result (a.b reaches into objects; id is always kept; * = all).
cURL
curl "https://nways.ng/maps/v1/pluscodes/6FR5J975%2BP4W" \
  -H "X-NWays-Api-Key: YOUR_API_KEY"
JavaScript
const res = await fetch('https://nways.ng/maps/v1/pluscodes/6FR5J975%2BP4W', {
  headers: { 'X-NWays-Api-Key': process.env.NWAYS_API_KEY },
})
const data = await res.json()
Python
import os
import requests

res = requests.get(
    "https://nways.ng/maps/v1/pluscodes/6FR5J975%2BP4W",
    headers={"X-NWays-Api-Key": os.environ["NWAYS_API_KEY"]},
    timeout=10,
)
data = res.json()

Response

The code's area

FieldTypeDescription
locationPointRequired.
location.typestringRequired.
location.coordinatesnumber[]Required. [lng, lat] At least 2 items, at most 2 items.
plusCodestringRequired.
countryArea | nullRequired.
regionArea | nullRequired.
formattedAddressstring
postcodePostcode | nullRequired. Nigeria: the building's NIPOST postcode, when one is within reach.
ghanaPoststring | nullRequired. Ghana: the nearest known GhanaPost GPS address (within 100 m).
nearestResult | nullRequired.
attributionstringRequired.
boundsnumber[]Required. west, south, east, north At least 4 items, at most 4 items.
200 OK
{
  "location": {
    "type": "string",
    "coordinates": [
      0
    ]
  },
  "plusCode": "string",
  "country": {
    "code": "NG-LA",
    "name": "Lagos State",
    "nameFr": "string",
    "namePt": "string"
  },
  "region": {
    "code": "NG-LA",
    "name": "Lagos State",
    "nameFr": "string",
    "namePt": "string"
  },
  "formattedAddress": "12 Admiralty Way, Lekki, Lagos State, Nigeria",
  "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"
  },
  "ghanaPost": "string",
  "nearest": {
    "id": "osm:w568367632",
    "name": "Ikeja City Mall",
    "type": "landmark",
    "category": "shopping",
    "location": {
      "type": "string",
      "coordinates": [
        0
      ]
    },
    "bbox": [
      0
    ],
    "formattedAddress": "Ikeja, Lagos",
    "postcode": "LA08A09DB09",
    "ghanaPost": "GA-183-8164",
    "plusCode": "6FR5J975+P4W",
    "country": "NG",
    "distanceM": 0,
    "estimated": true,
    "accuracyM": 0,
    "placeId": "string",
    "attribution": "string"
  },
  "attribution": "string",
  "bounds": [
    0
  ]
}

Errors

  • default Error