Forward geocoding
Turn text into coordinates. Accepts full addresses, partial addresses, postcodes, place names and points of interest, in any language.
Parameters
| Parameter | Type | Description |
|---|---|---|
qrequired* | string | Free-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, country | string | *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_id | string | *A place_id from autocomplete. Returns that one place with full components and bounds. Overrides q. |
limitoptional | integer | Maximum results, 1 to 10. Default 5. |
countriesoptional | string | Comma-separated ISO 3166-1 alpha-2 codes, at most 10. Only results in these countries are returned. Example: gb,ie. |
boundsoptional | string | south,west,north,east in decimal degrees. Results inside the box rank first. Add strict=1 to exclude results outside it. |
proximityoptional | string | lat,lon. Results near this point rank first. |
typesoptional | string | Comma-separated subset of address, street, postcode, city, region, country, poi. Default all. |
langoptional | string | ISO 639-1 code for names in the response. Default en. |
timezone, elevation, wikidata, country_info, codes, sun, regions, districts, census, demographics, road, siteoptional | flag | Extra 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. |
annotationsoptional | integer | 1 switches on every flag above at once. Default 0. |
keyoptional | string | API 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]){
"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
| Field | Type | Description |
|---|---|---|
query | string | The text we interpreted, after trimming. |
results | array | Matches, best first. Empty when nothing matched. |
results[].formatted | string | Full address in the country's conventional format. |
results[].lat, lon | number | WGS 84 decimal degrees. |
results[].distance_m | integer | Only when q is a lat,lon pair: metres from that point to the place returned. |
results[].type | string | address, 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[].precision | string | house, street, postcode, city, region, country. What the point represents. See coverage. |
results[].confidence | number | 0 to 1. How well the result matches the query. Below 0.5 means we guessed. |
results[].place_id | string | Stable identifier for this place. |
results[].components | object | Address parts. See below. |
results[].bounds | object | north, south, east, west of the matched feature. |
results[].parcel | object | United 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[].place | object | When 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_place | string | With place: its name before the address, ready to show. formatted stays the address alone. |
results[].codes | object | The 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[].population | integer | For a city, region or country from our worldwide gazetteer: its population. |
results[].un_locode | object | For 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, site | object | Only 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.
| Key | Meaning |
|---|---|
poi, building | Name of a point of interest or building, when the match is one. |
unit, level | Flat or unit, and floor, where the address names them. |
house_number | Including letters and ranges: 221B, 12-14. |
road | Street name with its type: Baker Street, Avenue Anatole France. |
lot | Australia: the lot number of an address that has no house number. |
suburb | Sub-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). |
municipality | US 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). |
city | City, 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. |
county | County or district. |
state, state_code | State, 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. |
postcode | Postal code, formatted as the postal authority formats it. |
country, country_code | Country name and lower-case ISO 3166-1 alpha-2 code. |
official_name | For 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.
| Field | Flag | Meaning |
|---|---|---|
timezone | timezone=1 | IANA 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_m | elevation=1 | Ground height in metres above sea level, from the same model as the elevation endpoint. null if the elevation service does not answer in time. |
population | None | For a city, region or country from our worldwide gazetteer: its population. Absent otherwise. |
wikidata | wikidata=1 | For places from our worldwide gazetteer: the Wikidata id. Absent otherwise. |
country_info | country_info=1 | The 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. |
codes | None for a house, street or point of interest; codes=1 for other results | The 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. |
sun | sun=1 | Today'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. |
regions | regions=1 | The 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_locode | None | For 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. |
districts | districts=1 | Addresses 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. |
census | census=1 | Addresses 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. |
demographics | demographics=1 | Addresses 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, intersection | road=1 | Addresses 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. |
site | site=1 | Addresses 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
- Results are ordered by a combination of confidence, precision and proximity. The first result is the one to use unless you are showing a picker.
- A house placed along its street from the street's number range is still
precision: house. When a house number cannot be found on a known street, the result hastype: streetandprecision: street, at the street. Checkprecisionif that matters to you. - Postcodes alone are fine as
q. For postcode-only workloads the postal code endpoint is faster and returns the postal authority's place name. - A query in one script for a place that uses another (Cyrillic for a Japanese address, say) works, but
langdecides the script of the response.
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.
| Provider | Host | Path |
|---|---|---|
| Google Maps Platform | gapi.mygeocode.com | /maps/api/geocode/json?address=... |
| Bing Maps REST Services | bing.mygeocode.com | /REST/v1/Locations?q=.../REST/v1/Locations?countryRegion=...&locality=...&addressLine=... |
| HERE Geocoding and Search | here.mygeocode.com | /v1/geocode?q=.../v1/geocode?qq=street=...;city=... |
| Mapbox Geocoding | mapbox.mygeocode.com | /geocoding/v5/mapbox.places/{query}.json/search/geocode/v6/forward?q=... |
| Geocode.Farm | farm.mygeocode.com | /forward/?addr=.../v3/json/forward/?addr=... |
| OpenStreetMap Nominatim | osm.mygeocode.com | /search?q=...&format=json/search?street=...&city=...&country=...&format=json |
| OpenCage | opencage.mygeocode.com | /geocode/v1/json?q=.../geocode/v1/geojson?q=... |
| LocationIQ | locationiq.mygeocode.com | /v1/search?q=...&format=json |
| Geoapify | geoapify.mygeocode.com | /v1/geocode/search?text=... |
| TomTom Search | tomtom.mygeocode.com | /search/2/geocode/{query}.json/search/2/structuredGeocode.json?countryCode=...&streetName=... |
| MapQuest Geocoding | mapquest.mygeocode.com | /geocoding/v1/address?location=.../geocoding/v1/batch?location=...&location=... |
| Geocodio | geocodio.mygeocode.com | /v1.7/geocode?q=.../v1.7/geocode (POST, JSON array) |
| PositionStack | positionstack.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.