Skip to main content

GET /v1/geocode

Overview​

Forward geocoding converts a street address, place name, or search query into geographic coordinates. The API returns up to 50 results ranked by relevance, powered by OpenStreetMap data.

Request​

GET https://api.geocodeme.net/v1/geocode

Required header: X-Api-Key: gm_YOUR_API_KEY

Parameters​

ParameterTypeRequiredDefaultDescription
qstringYesn/aAddress or place name to geocode
limitintegerNo5Maximum number of results to return (1 to 50). Higher values increase response size. There is no pagination: all results are returned in a single response.
countrycodesstringNon/aComma-separated ISO 3166-1 alpha-2 codes restricting results within the covered area (e.g. de, es,pt). Region aliases (gp, mq, gf, yt, re, eu) choose which regional index is searched; every other code is applied on top as a country filter. The two compose, and mixing them only ever narrows (eu,de returns the same results as de while querying one instance instead of six), whereas a second code of the same kind widens, as a list should (de,es, gp,mq). fr is a country code, not an alias: it means all French data, mainland and overseas. Codes outside the covered area return no results. See Region aliases and country filters.
formatstringNojsonResponse format: json or geojson

Region aliases and country filters​

countrycodes carries two independent decisions, and they combine:

  • where to search. The region aliases gp (Guadeloupe), mq (Martinique), gf (French Guiana), yt (Mayotte), re (Réunion) and eu (continental Europe) each select one regional index. They are resolved by our router and never forwarded to the search engine. With no alias in the list, all six regional instances are queried.
  • what to keep. Every other code (de, es, pt, fr…) is forwarded as a country filter, read as a logical OR, and applied inside the instances selected above.

Mixing the two kinds always narrows. Add a country code to an alias and you keep the same area, filtered; add an alias to a country code and you keep the same filter over a smaller area. Neither can widen the answer.

Adding a code of the same kind widens, exactly as a list should: several aliases search several regions (gp,mq covers both islands), and several country codes are read as a logical OR (de,es returns German and Spanish results).

countrycodesInstances queriedCountry filterWhat you get
(absent)all sixnonethe whole covered area
deall sixdeGerman results; only the continental index holds any
eucontinental onlynoneanything in continental Europe
eu,decontinental onlydethe same results as de, from one instance instead of six
frall sixfrall French data: mainland and the five overseas regions
fr,eucontinental onlyfrmainland France only, a strict subset of fr
gpGuadeloupe onlynoneanything in Guadeloupe
gp,mqGuadeloupe + Martiniquenoneanything in those two islands
gp,deGuadeloupe onlydeempty: you asked for German addresses in Guadeloupe
eu,zzcontinental onlyzzempty: zz is not a covered country

Codes are case-insensitive, surrounding spaces are ignored, duplicates are removed and the forwarded filter is sorted, so eu,de, de,eu and EU, DE are one and the same request.

An unrecognised or uncovered code is never silently discarded: it stays a filter and produces an honest empty list rather than a broader answer.

Latency tip. If you already know the country is in continental Europe, prefixing the alias (eu,de instead of de) narrows the fan-out from six instances to one for an identical result.

/v1/autocomplete selects, but cannot filter

/v1/autocomplete reads the same aliases and follows the same selection rule: an alias chooses the index that is searched, and a code can only ever bring in the index it designates; mixing kinds never widens there either, while a second alias does (gp,mq). gp,fr narrows to Guadeloupe there exactly as it does here, and fr,eu searches the continental index on both.

What it has not got is the filter half of the composition: its suggestion engine has no country filter to forward, so a code that is not an alias selects nothing rather than restricting anything. Two consequences if you share countrycodes values between the endpoints:

  • eu,de returns all of continental Europe there; Germany only here.
  • a value that contains no alias returns no suggestion at all there: de and fr,de both come back empty, where here de returns German results and fr,de returns French or German ones.

Filter suggestions client-side on address.country_code.

Code Examples​

curl -H "X-Api-Key: gm_YOUR_API_KEY" \
"https://api.geocodeme.net/v1/geocode?q=10%20Rue%20de%20Rivoli%2C%20Paris&limit=3"

Response​

info

All responses include rate limiting headers (X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Monthly-Remaining, etc.).

JSON Response​

{
"results": [
{
"lat": 48.8566,
"lon": 2.3522,
"name": null,
"display_name": "10, Rue de Rivoli, 4e Arrondissement, Paris, Île-de-France, 75004, France",
"type": "house",
"importance": 0.62,
"address": {
"house_number": "10",
"road": "Rue de Rivoli",
"city": "Paris",
"state": "Île-de-France",
"postcode": "75004",
"country": "France",
"country_code": "fr"
}
}
],
"attribution": "© OpenStreetMap contributors",
"meta": {
"took_ms": 45,
"cache_hit": false
}
}

GeoJSON Response​

When format=geojson, the response is a standard GeoJSON FeatureCollection:

{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [2.3522, 48.8566]
},
"properties": {
"name": null,
"display_name": "10, Rue de Rivoli, 4e Arrondissement, Paris, Île-de-France, 75004, France",
"type": "house",
"importance": 0.62,
"address": {
"house_number": "10",
"road": "Rue de Rivoli",
"city": "Paris",
"state": "Île-de-France",
"postcode": "75004",
"country": "France",
"country_code": "fr"
}
}
}
],
"attribution": "© OpenStreetMap contributors",
"meta": {
"took_ms": 45,
"cache_hit": false
}
}

Schema​

Top-level response​

FieldTypeDescription
resultsarrayArray of GeocodingResult objects
attributionstringAlways "© OpenStreetMap contributors"
metaobjectRequest metadata
meta.took_msintegerServer processing time in milliseconds
meta.cache_hitbooleanWhether the response was served from cache

GeocodingResult​

FieldTypeDescription
latfloatLatitude of the result
lonfloatLongitude of the result
namestring | nullProper name of the place, from the OpenStreetMap name tag; null when the object has no name. See The name field
display_namestringFull human-readable address
typestringOSM place type (e.g. house, road, city, building); may be null
importancefloatRelevance score between 0 and 1; may be null
addressobjectStructured address components; may be null

The name field​

name is a top-level field carrying the OpenStreetMap name tag of the object: "Musée du Louvre", "École élémentaire Jules Ferry", "Boulangerie Chez Momo". It is not an address component and never appears inside address.

{
"lat": 48.8606,
"lon": 2.3376,
"name": "Musée du Louvre",
"display_name": "Musée du Louvre, Rue de Rivoli, 1er Arrondissement, Paris, Île-de-France, 75001, France",
"type": "museum",
"importance": 0.83
}
  • null when the object has no name tag: the usual case for a plain street or a numbered address. The field is always present in the payload, with the JSON value null, never an empty string.
  • Different from type, which carries the OSM category (museum, school, bakery, house): the two are complementary, not redundant.
  • Different from the head of display_name. Use name as the title of a result and display_name as the address line underneath; never split display_name on its first comma to obtain a title; on 10, Rue de Rivoli, … that yields 10.

The same field, with the same contract, is returned by /v1/reverse and /v1/autocomplete. With format=geojson it sits in properties, just before display_name.

Address​

All fields are optional and depend on the location:

FieldTypeDescription
house_numberstringHouse or building number
roadstringStreet name
citystringCity name
townstringTown name (alternative to city for smaller settlements)
villagestringVillage name (alternative to city for rural areas)
countystringCounty or district
statestringState or region
postcodestringPostal or ZIP code
countrystringCountry name
country_codestringISO 3166-1 alpha-2 country code (e.g. fr)

Error Responses​

The most common errors for this endpoint:

Missing q parameter​

{
"error": {
"code": "MISSING_PARAMETER",
"message": "Required parameter 'q' is missing",
"field": "q"
}
}

Invalid API key​

{
"error": {
"code": "INVALID_API_KEY",
"message": "API key missing or invalid"
}
}

For the full error reference, see Error Codes.