Address autocomplete

Suggestions for partial input, tuned for latency and typo tolerance. Every suggestion carries coordinates, so most integrations never need a second call.

GEThttps://api.mygeocode.com/v1/autocomplete

Parameters

ParameterTypeDescription
qrequiredstringWhat the user has typed so far. At least 2 characters, up to 128.
limitoptionalinteger1 to 10. Default 5.
countriesoptionalstringComma-separated ISO 3166-1 alpha-2 codes to restrict suggestions to, at most 10.
proximityoptionalstringlat,lon. Nearby suggestions rank first. Strongly recommended for map search boxes.
boundsoptionalstringsouth,west,north,east in decimal degrees. Results inside the box rank first. Add strict=1 to exclude results outside it.
typesoptionalstringComma-separated subset of address, street, postcode, city, region, country, poi. Default all.
langoptionalstringISO 639-1 code. Default en.
keyoptionalstringAPI key, if not sent as a header.

Example

$ curl -H "X-API-Key: YOUR_KEY" "https://api.mygeocode.com/v1/autocomplete?q=oxford+st&proximity=51.515,-0.141&limit=3"
const url = new URL("https://api.mygeocode.com/v1/autocomplete");
url.searchParams.set("q", "oxford st");
url.searchParams.set("proximity", "51.515,-0.141");
url.searchParams.set("limit", "3");

const { suggestions } = await (await fetch(url, { headers: { "X-API-Key": "YOUR_KEY" } })).json();
suggestions.forEach((s) => console.log(s.text, s.lat, s.lon));
import requests

r = requests.get("https://api.mygeocode.com/v1/autocomplete",
                 params={"q": "oxford st", "proximity": "51.515,-0.141", "limit": 3}, headers={"X-API-Key": "YOUR_KEY"}, timeout=5)
for s in r.json()["suggestions"]:
    print(s["text"], s["lat"], s["lon"])
Response
{
  "status": "ok",
  "query": "oxford st",
  "suggestions": [
    {
      "text": "Oxford Street, Greater London, England, United Kingdom",
      "lat": 51.514752,
      "lon": -0.146082,
      "type": "street",
      "precision": "street",
      "place_id": "DHrpomBSMl4-2uI"
    },
    {
      "text": "Oxford Street, Deanend SP5, United Kingdom",
      "lat": 50.956579,
      "lon": -2.037279,
      "type": "street",
      "precision": "street",
      "place_id": "Ls1uaEPX0ASnW4GV8D2W12zd1OQzDdc"
    },
    {
      "text": "Oxford Street, Earl Shilton LE9, United Kingdom",
      "lat": 52.576381,
      "lon": -1.309249,
      "type": "street",
      "precision": "street",
      "place_id": "js3Iw8GnWcYoYUfXZdhMqqVfaaRmZTg"
    }
  ]
}

Response fields

FieldTypeDescription
suggestions[].textstringDisplay text, one line, in lang.
suggestions[].lat, lonnumberCoordinates. Always present.
suggestions[].type, precisionstringAs in forward geocoding.
suggestions[].place_idstringPass to /v1/forward?place_id=... for full components and bounds. That call counts as one request.

Notes

The same lookup in other providers' formats

If you already have code written against one of these providers, keep it: the drop-in host accepts the same path and parameters and answers in that provider's response shape, with this endpoint behind it. See how the drop-ins work.

ProviderHostPath
Google Maps Platformgapi.mygeocode.com/maps/api/place/autocomplete/json?input=...
Bing Maps REST Servicesbing.mygeocode.com/REST/v1/Autosuggest?query=...
HERE Geocoding and Searchhere.mygeocode.com/v1/autosuggest?q=...&at=lat,lng
/v1/autocomplete?q=...
Mapbox Geocodingmapbox.mygeocode.com/search/searchbox/v1/suggest?q=...
LocationIQlocationiq.mygeocode.com/v1/autocomplete?q=...
Geoapifygeoapify.mygeocode.com/v1/geocode/autocomplete?text=...
TomTom Searchtomtom.mygeocode.com/search/2/search/{query}.json?typeahead=true

Errors

400 invalid_request when q is shorter than 2 characters or longer than 128, or when limit is outside 1 to 10. Unknown types values are ignored.