N-Ways
Developer docsAutocomplete

Autocomplete

Suggestions while someone types, billed per session.

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

Suggestions as someone types (billed per session)

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

Send the same session token (8–64 of A–Z a–z 0–9 - _, a UUID is fine) from the first letter until the user picks a result: the session's first request is billed (one autocomplete session); the rest are counted towards the rate limit but not charged, for up to 3 minutes between requests, 15 minutes and 100 requests in all. Start a new token after a pick. Without a token every request is a session. X-NWays-Session-Billed: 1|0 says which. Reasons: as /geocode, and SESSION_INVALID, TYPES_INVALID.

Parameters

NameInTypeDescription
qquerystringRequired.
sessionquerystring
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.
typesquerystringComma list of address, street, business, place, area, postcode, ghanapost.
limitqueryintegerDefault: 5. ≥ 1, ≤ 10.
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/autocomplete?q=lekki+ph" \
  -H "X-NWays-Api-Key: YOUR_API_KEY"
JavaScript
const res = await fetch('https://nways.ng/maps/v1/autocomplete?q=lekki+ph', {
  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/autocomplete?q=lekki+ph",
    headers={"X-NWays-Api-Key": os.environ["NWAYS_API_KEY"]},
    timeout=10,
)
data = res.json()

Response

Suggestions

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