Geocode a structured address
GET/geocode
const url = 'http://127.0.0.1:8080/geocode?address=10%20King%20Street&locality=Toronto®ion=Ontario&postcode=M5V%201A1&layer=address&country=NZ%2CAU';const options = {method: 'GET'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url 'http://127.0.0.1:8080/geocode?address=10%20King%20Street&locality=Toronto®ion=Ontario&postcode=M5V%201A1&layer=address&country=NZ%2CAU'Geocodes an address given as separate fields, and returns the best match
or no result. address is matched on its own, then checked against
locality, region and postcode.
- A house number missing from the data is interpolated between its
neighbours (
accuracy: interpolated), or answered with its street (accuracy: street). - A street matches
postcodeonly when postcode data confirms it. - A different house is never returned:
10/1367matches as written or as 1367, never as house 10. geocoding.queryis the form of the address that matched, which can differ fromaddress.
Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”House number and street, without town or postcode.
Example
10 King StreetCity or town.
Example
TorontoState, province or region.
Example
OntarioPostal code.
Example
M5V 1A1Number of candidates to consider. 0, the default, lets the server choose. At most one result is returned.
Kind of result: an address, a street, a POI, or an area such as a locality or region.
Consider only candidates of this layer. An unknown layer returns 400.
Return only results in these countries, as comma-separated ISO 3166-1 alpha-2 codes. A code that is not two letters returns 400. A code the Pack does not cover returns no results.
Example
NZ,AUResponses
Section titled “Responses”The best match, or no features when nothing matches.
A GeoJSON FeatureCollection answering /search, /autocomplete or
/geocode.
object
One forward geocoding result.
object
GeoJSON Point. coordinates is [lon, lat].
object
Properties of a forward geocoding result.
object
How precisely the coordinates locate the result, most precise first.
rooftop: the address or POI itself.interpolated: a house number placed between known neighbours.street: a point on the street.centroid: the centre of a mapped area.approximate: a point standing for something larger, such as a town or postcode.
Address parts stated by the source record.
object
Areas below the locality, outermost first (OSM addr:suburb,
addr:quarter, addr:neighbourhood).
Named place the house number belongs to where there is no street
(OSM addr:place).
POI category, such as amenity:cafe. Present only on POIs.
Administrative areas containing the result.
object
object
Stable ID from the source data, as in a result’s id.
object
Stable ID from the source data, as in a result’s id.
object
Stable ID from the source data, as in a result’s id.
object
Stable ID from the source data, as in a result’s id.
Named area outside the administrative levels, usually an island.
object
Stable ID from the source data, as in a result’s id.
object
Stable ID from the source data, as in a result’s id.
object
Stable ID from the source data, as in a result’s id.
object
Stable ID from the source data, as in a result’s id.
object
Stable ID from the source data, as in a result’s id.
Stable ID from the source data, such as osm:node:123.
One-line display label: name followed by its location.
Kind of result: an address, a street, a POI, or an area such as a locality or region.
House number and street for an address (12 King Street West), or
the name of a street, area or POI.
Row of the record in this Pack. Changes between Pack builds.
Source data the result comes from.
object
Source object type: an OSM node, way or relation, or a row of an
address dataset such as OpenAddresses.
Probability, from 0 to 1, that this is the address the query asks
for. Of results at 0.8, about 8 in 10 are correct. Present only when
the Pack is calibrated. 0 on a fallback result.
true when no match was found and the result is the most precise
area the query names instead: its postcode, a town or other area,
its region or its country. layer says which. Absent otherwise.
Text relevance. Higher is better. Comparable only within one
response: use confidence to judge a single result.
The query, API version and data attribution.
object
Attribution required by the data licence.
Query as received, trimmed, with each run of whitespace collapsed to one space.
API version. Changes only when a field is removed or changes meaning. New optional fields keep the version.
Example
{ "features": [ { "geometry": { "type": "Point" }, "properties": { "accuracy": "rooftop", "layer": "address", "source": { "object_type": "node" } }, "type": "Feature" } ], "geocoding": { "attribution": "© OpenStreetMap contributors, ODbL", "version": "1" }, "type": "FeatureCollection"}Headers
Section titled “Headers”ID the request is logged under: the request’s own X-Request-Id when it sent one. Include it in bug reports.
address is empty or too long, another field is too long, limit is too large, or a parameter is malformed.
Error response, an RFC 9457 problem document.
object
Human-readable explanation. Absent on 500 errors.
Stable error code. Branch on this.
Rejected parameters. Present only when the error is about parameters.
A rejected parameter.
object
Parameter name.
Why it was rejected.
ID the request is logged under. Include it in bug reports.
Name of the HTTP status. Do not branch on it.
URI identifying the problem type. Currently always about:blank.
Example
{ "detail": "q must not be empty", "error_code": "invalid_query", "invalid_params": [ { "name": "limit", "reason": "must be at most 50" } ], "request_id": "01JA7Q2K3M4N5P6Q7R8S9T0V1W", "status": 400, "title": "Bad Request", "type": "about:blank"}Headers
Section titled “Headers”ID the request is logged under: the request’s own X-Request-Id when it sent one. Include it in bug reports.
Method not allowed. The route accepts GET only.
Error response, an RFC 9457 problem document.
object
Human-readable explanation. Absent on 500 errors.
Stable error code. Branch on this.
Rejected parameters. Present only when the error is about parameters.
A rejected parameter.
object
Parameter name.
Why it was rejected.
ID the request is logged under. Include it in bug reports.
Name of the HTTP status. Do not branch on it.
URI identifying the problem type. Currently always about:blank.
Example
{ "detail": "q must not be empty", "error_code": "invalid_query", "invalid_params": [ { "name": "limit", "reason": "must be at most 50" } ], "request_id": "01JA7Q2K3M4N5P6Q7R8S9T0V1W", "status": 400, "title": "Bad Request", "type": "about:blank"}Headers
Section titled “Headers”Example
GETMethods the route accepts.
ID the request is logged under: the request’s own X-Request-Id when it sent one. Include it in bug reports.
Internal server error.
Error response, an RFC 9457 problem document.
object
Human-readable explanation. Absent on 500 errors.
Stable error code. Branch on this.
Rejected parameters. Present only when the error is about parameters.
A rejected parameter.
object
Parameter name.
Why it was rejected.
ID the request is logged under. Include it in bug reports.
Name of the HTTP status. Do not branch on it.
URI identifying the problem type. Currently always about:blank.
Example
{ "detail": "q must not be empty", "error_code": "invalid_query", "invalid_params": [ { "name": "limit", "reason": "must be at most 50" } ], "request_id": "01JA7Q2K3M4N5P6Q7R8S9T0V1W", "status": 400, "title": "Bad Request", "type": "about:blank"}Headers
Section titled “Headers”ID the request is logged under: the request’s own X-Request-Id when it sent one. Include it in bug reports.

