Forward geocoding

Turn text into coordinates. Accepts full addresses, partial addresses, postcodes, place names and points of interest, in any language.

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

Parameters

ParameterTypeDescription
qrequired*stringFree-form text to geocode. Up to 256 characters.
street, city, state, postcode, countrystring*Structured alternative to q. Use when you already have the address in fields. At least one is required if q is absent. country here is an ISO 3166-1 alpha-2 code.
place_idstring*A place_id from autocomplete. Returns that one place with full components and bounds. Overrides q.
limitoptionalintegerMaximum results, 1 to 10. Default 5.
countriesoptionalstringComma-separated ISO 3166-1 alpha-2 codes. Only results in these countries are returned. Example: gb,ie.
boundsoptionalstringsouth,west,north,east in decimal degrees. Results inside the box rank first. Add strict=1 to exclude results outside it.
proximityoptionalstringlat,lon. Results near this point rank first.
langoptionalstringISO 639-1 code for names in the response. Default en.
keyoptionalstringAPI key, if not sent as the X-API-Key header.

Example

$ curl "https://api.mygeocode.com/v1/forward?q=Dam+1,+Amsterdam&countries=nl&limit=1"
const url = new URL("https://api.mygeocode.com/v1/forward");
url.searchParams.set("q", "Dam 1, Amsterdam");
url.searchParams.set("countries", "nl");
url.searchParams.set("limit", "1");

const data = await (await fetch(url)).json();
console.log(data.results[0]);
import requests

r = requests.get("https://api.mygeocode.com/v1/forward",
                 params={"q": "Dam 1, Amsterdam", "countries": "nl", "limit": 1}, timeout=10)
print(r.json()["results"][0])
Response
{
  "status": "ok",
  "query": "Dam 1, Amsterdam",
  "results": [
    {
      "formatted": "Dam 1, 1012 JS Amsterdam, Netherlands",
      "lat": 52.373119,
      "lon": 4.893604,
      "type": "address",
      "precision": "house",
      "confidence": 0.98,
      "place_id": "nl.addr.c21d40e8",
      "components": {
        "house_number": "1",
        "road": "Dam",
        "neighbourhood": "Centrum",
        "city": "Amsterdam",
        "state": "North Holland",
        "state_code": "NH",
        "postcode": "1012 JS",
        "country": "Netherlands",
        "country_code": "nl"
      },
      "bounds": { "north": 52.373519, "south": 52.372719, "east": 4.894204, "west": 4.893004 }
    }
  ]
}

Response fields

FieldTypeDescription
querystringThe text we interpreted, after trimming.
resultsarrayMatches, best first. Empty when nothing matched.
results[].formattedstringFull address in the country's conventional format.
results[].lat, lonnumberWGS 84 decimal degrees.
results[].typestringaddress, street, postcode, city, region, country, poi.
results[].precisionstringhouse, street, postcode, admin. What the point represents. See coverage.
results[].confidencenumber0 to 1. How well the result matches the query. Below 0.5 means we guessed.
results[].place_idstringStable identifier for this place.
results[].componentsobjectAddress parts. See below.
results[].boundsobjectnorth, south, east, west of the matched feature.

Component keys

Only keys that apply are present. The same keys are used in every country.

KeyMeaning
nameName of a point of interest or building, when the match is one.
house_numberIncluding letters and ranges: 221B, 12-14.
roadStreet name with its type: Baker Street, Avenue Anatole France.
neighbourhood, suburbSub-city areas, where the country uses them.
cityCity, town or village.
countyCounty or district.
state, state_codeState, province or region, and its ISO 3166-2 suffix where one exists.
postcodePostal code, formatted as the postal authority formats it.
country, country_codeCountry name and lower-case ISO 3166-1 alpha-2 code.

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/geocode/json?address=...
Bing Maps REST Servicesbing.mygeocode.com/REST/v1/Locations?q=...
/REST/v1/Locations?countryRegion=...&locality=...&addressLine=...
HERE Geocoding and Searchhere.mygeocode.com/v1/geocode?q=...
/v1/geocode?qq=street=...;city=...
Mapbox Geocodingmapbox.mygeocode.com/geocoding/v5/mapbox.places/{query}.json
/search/geocode/v6/forward?q=...
Geocode.Farmfarm.mygeocode.com/forward/?addr=...
/v3/json/forward/?addr=...
OpenStreetMap Nominatimosm.mygeocode.com/search?q=...&format=json
/search?street=...&city=...&country=...&format=json
OpenCageopencage.mygeocode.com/geocode/v1/json?q=...
/geocode/v1/geojson?q=...
LocationIQlocationiq.mygeocode.com/v1/search?q=...&format=json
Geoapifygeoapify.mygeocode.com/v1/geocode/search?text=...
TomTom Searchtomtom.mygeocode.com/search/2/geocode/{query}.json
/search/2/structuredGeocode.json?countryCode=...&streetName=...
MapQuest Geocodingmapquest.mygeocode.com/geocoding/v1/address?location=...
/geocoding/v1/batch?location=...&location=...
Geocodiogeocodio.mygeocode.com/v1.7/geocode?q=...
/v1.7/geocode (POST, JSON array)
PositionStackpositionstack.mygeocode.com/v1/forward?query=...

Errors

400 invalid_request when neither q, a structured field nor place_id is present, when limit is outside 1 to 10, or when bounds or proximity is malformed. See errors for the rest.