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. A plus code works too: a full one (8GJ3J342+PH), a short one with a place (J342+PH Vragoli), or a short one alone, read near proximity or else near your own location. Send the plus sign as %2B; a plain space instead of it works as well.
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, at most 10. 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.
typesoptionalstringComma-separated subset of address, street, postcode, city, region, country, poi. Default all.
langoptionalstringISO 639-1 code for names in the response. Default en.
timezone, elevation, wikidata, country_info, codes, sun, regions, districts, census, demographics, road, siteoptionalflagExtra blocks, each added when its flag is 1, for example timezone=1&sun=1. All are off by default, so a plain lookup stays small and fast. See annotations.
annotationsoptionalinteger1 switches on every flag above at once. Default 0.
keyoptionalstringAPI key, if not sent as the X-API-Key header.

Example

$ curl -H "X-API-Key: YOUR_KEY" "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, { headers: { "X-API-Key": "YOUR_KEY" } })).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}, headers={"X-API-Key": "YOUR_KEY"}, timeout=10)
print(r.json()["results"][0])
Response
{
  "status": "ok",
  "query": "Dam 1, Amsterdam",
  "results": [
    {
      "formatted": "Dam 1, 1012 JS Amsterdam, The Netherlands",
      "lat": 52.373294,
      "lon": 4.893716,
      "type": "address",
      "precision": "house",
      "confidence": 0.89,
      "place_id": "-nUP3dP029QLr7V2yERn_v3RUl_wLSclXQ",
      "components": {
        "house_number": "1",
        "road": "Dam",
        "city": "Amsterdam",
        "postcode": "1012 JS",
        "country": "The Netherlands",
        "country_code": "nl"
      },
      "bounds": { "north": 52.373791, "south": 52.372791, "east": 4.894215, "west": 4.893215 },
      "codes": {
        "plus_code": "9F469VFV+8F",
        "geohash": "u173zq72xce5",
        "mgrs": "31UFU2891404245",
        "maidenhead": "JO22ki79",
        "dms": {
          "lat": "52° 22' 23.9\" N",
          "lon": "4° 53' 37.4\" E"
        },
        "mapcode": "NLD 2T.NG",
        "mapcode_international": "VHXG9.RLZZ"
      }
    }
  ]
}

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[].distance_mintegerOnly when q is a lat,lon pair: metres from that point to the place returned.
results[].typestringaddress, street, postcode, city, suburb (a part of a town, such as a US Census-designated place, shown with its postal town), region, country, poi.
results[].precisionstringhouse, street, postcode, city, region, country. 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.
results[].parcelobjectUnited States addresses from a state's official parcel data: the property's parcel id as the state writes it, its area_m2 and its bounds. A reverse lookup anywhere on the property answers its address. Absent elsewhere.
results[].placeobjectWhen a business or other named place is at the address: its name, category, brand, website and its own place_id, each place shown once however many sources list it. Where several share one address, the best known comes first, and a plus code query returns one result for each of them. Absent otherwise.
results[].formatted_placestringWith place: its name before the address, ready to show. formatted stays the address alone.
results[].codesobjectThe point as a plus code, geohash, MGRS reference and other location codes. Present for houses, streets and points of interest; for other results only with codes=1. See annotations.
results[].populationintegerFor a city, region or country from our worldwide gazetteer: its population.
results[].un_locodeobjectFor a UN/LOCODE query such as LOCODE:DEHAM: what the code stands for. See annotations.
results[].timezone, elevation_m, wikidata, country_info, sun, regions, districts, census, demographics, road, intersection, siteobjectOnly when their flag is set, or with annotations=1. See annotations.

Component keys

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

KeyMeaning
poi, buildingName of a point of interest or building, when the match is one.
unit, levelFlat or unit, and floor, where the address names them.
house_numberIncluding letters and ranges: 221B, 12-14.
roadStreet name with its type: Baker Street, Avenue Anatole France.
lotAustralia: the lot number of an address that has no house number.
suburbSub-city areas, where the country uses them. In the US, the Census-designated place an address lies in when its mail goes to another town (Paradise, in Las Vegas).
municipalityUS only: the incorporated city, town or village (or New England town) an address lies in when its mail goes to another town (Centennial, with the city Englewood).
cityCity, town or village. In the US, the town USPS uses for the address (its postal town). A Census-designated place or municipality written in a query finds the address too.
countyCounty or district.
state, state_codeState, province or region, and its ISO 3166-2 suffix where one exists. With a lang in another script the code is written in that script too (НВ for NV with lang=ru), and a query may use it.
postcodePostal code, formatted as the postal authority formats it.
country, country_codeCountry name and lower-case ISO 3166-1 alpha-2 code.
official_nameFor a country known only from our boundary data: its official name.

Annotations

Each block is added when the flag in its row is 1, or all of them with annotations=1. They cost nothing extra, but each one runs lookups of its own, so ask for the ones you use. A field we cannot fill is null or left out; it never fails the lookup. The blocks drawn from area, census and road data appear where that data is loaded for the country.

FieldFlagMeaning
timezonetimezone=1IANA id, long name, abbreviation, utc_offset and utc_offset_seconds right now, whether daylight saving time is in force (dst) and the local_time. For other instants use the timezone endpoint.
elevation_melevation=1Ground height in metres above sea level, from the same model as the elevation endpoint. null if the elevation service does not answer in time.
populationNoneFor a city, region or country from our worldwide gazetteer: its population. Absent otherwise.
wikidatawikidata=1For places from our worldwide gazetteer: the Wikidata id. Absent otherwise.
country_infocountry_info=1The country's name and official_name, iso2, iso3, iso_numeric, continent, its UN un_m49 region, subregion and intermediate region, UN groupings (LDC, LLDC, SIDS, MEDC or LEDC), capital, population, area_km2, whether it is independent, a un_member and landlocked, its currency (code, name, symbol, subunit, separators, ISO number), calling_code and dial prefixes, languages, tld, flag, wikidata and neighbours.
codesNone for a house, street or point of interest; codes=1 for other resultsThe same point as a plus_code (Open Location Code), geohash, mgrs (to the metre; null beyond 80° S and 84° N), maidenhead locator, dms (degrees, minutes, seconds), mapcode and mapcode_international, and in India the digipin.
sunsun=1Today's sunrise, sunset, solar_noon, civil_dawn and civil_dusk in local time. Where the sun does not rise or set that day, those are null and all_day says light or dark.
regionsregions=1The statistical and administrative areas the point lies in: nuts (the EU's NUTS 0 to 3, code and name), admin (the country and each administrative level below it, with its name, country code, id, GeoNames id, population and Wikidata id where known, for a first-level division its ISO 3166-2 code, and for a country its official name and three-letter code, including places most lists leave out, such as Kosovo and Liberland) and marine (the sea or ocean, for a point offshore).
un_locodeNoneFor a UN/LOCODE query such as LOCODE:DEHAM: the code, name, subdivision, what the location serves as (port, airport, rail or road terminal ...), its status and date.
districtsdistricts=1Addresses and streets only. United States: the congressional district and its members of Congress, the state_upper and state_lower legislative districts and their members, and the school districts with their grades. Canada: the federal and provincial ridings. United Kingdom: the Westminster, Scottish Parliament and Senedd constituencies, the local authority, county division and ward. Australia: the local_government_area, ward, federal_electorate and state_electorate.
censuscensus=1Addresses and streets only. United States: state, county, tract and block group codes, the place and county subdivision with their class, the metro or micro area, combined area and metropolitan division, and the FFIEC tract figures when loaded. Canada: the economic region, census division and subdivision, metropolitan area, tract, designated place, population centre and dissemination area. Australia: the ABS mesh_block with its category (residential, commercial, parkland and so on), its area and how surely the address was placed in it, sa1 to sa4 and gccsa with their names, the indigenous location, area and region, and, once the ABS publishes them for the current edition, remoteness, urban_centre, significant_urban_area and section_of_state. Each code also comes as code_previous, its code in the previous ASGS edition, where the ABS correspondence gives one.
demographicsdemographics=1Addresses and streets in the United States: the American Community Survey (5-year) figures of the census tract, by category (demographics, economics, families, housing, social), each table with its value, margin of error and the share of the row above it.
road, intersectionroad=1Addresses and streets where road data is loaded: the nearest road's name, ref, class, max_speed_kmh, oneway, bridge, tunnel, distance_m and OpenStreetMap link, and the nearest junction of named roads with the streets that meet there.
sitesite=1Addresses in Australia: the points surveyed on the address site, each with its type, name (building centroid, front door, driveway frontage, property access point, letterbox and so on), lat, lon and reliability (from 1, surveyed, to 6, region); for a unit, the building it is part of with that building's own address and place id; for a building, how many units it holds.

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=...

Bulk lookups

Post a JSON body to the same path with queries, an array of up to 100 addresses, and the answer carries a results array with one entry per query in the order sent. Each entry counts as one request, and a batch larger than what is left of the allowance is refused whole.

Each entry holds its query and its results. The other parameters (limit, countries, lang, annotations and the rest) apply to every entry, sent either in the JSON body or in the query string.

$ curl -X POST "https://api.mygeocode.com/v1/forward" -H "Content-Type: application/json" -d '{"queries": ["Brandenburg Gate, Berlin", "Bahnhofstrasse 1, Zurich"]}'

Errors

400 invalid_request when neither q, a structured field nor place_id is present, when q is longer than 256 characters, when limit is outside 1 to 10, or when a batch holds more than 100 addresses. A malformed bounds or proximity is ignored. See errors for the rest.