Reverse Geocode
Purpose
The TomTom Reverse Geocoding API gives users a tool to translate a coordinate (for example: 37.786505, -122.3862
) into a human-understandable street address, street element, or geography.
Most often, this is needed in tracking applications where you receive a GPS feed from the device or asset and you want to know the address.
Run this endpoint
You can easily run this and other endpoints. Go to the TomTom API Explorer page and follow the directions.
Request data
A request returns information for a given position. The type of response depends on the available data:
- address: Returns the most detailed information.
- street element: Less detailed; returned when there is no address data.
- geography: Returns the smallest available geographic data.
- This is returned when there is no address or street element data.
- You can specify the level of geography (see the entityType parameter in the request parameters section) to get a geometry.
- The geometry data can be fetched using the Additional Data service.
HTTPS Method: GET
For ease of viewing and identification:
- Constants and parameters enclosed in curly brackets { } must be replaced with their values.
- Please see the following Request parameters section with the required and optional parameters tables for their values. The generic request format is as follows.
URL format
https://{baseURL}/search/{versionNumber}/reverseGeocode/{position}.{ext}?key={Your_API_Key}&returnSpeedLimit={returnSpeedLimit}&heading={heading}&radius={radius}&number={number}&returnRoadUse={returnRoadUse}&roadUse={roadUse}&entityType={entityType}&callback={callback}&language={language}&allowFreeformNewline={allowFreeformNewline}&returnMatchType={returnMatchType}&view={view}&mapcodes={mapcodes}&filter={filter}
curl command format
curl 'https://{baseURL}/search/{versionNumber}/reverseGeocode/{position}.{ext}?key={Your_API_Key}&returnSpeedLimit={returnSpeedLimit}&heading={heading}&radius={radius}&number={number}&returnRoadUse={returnRoadUse}&roadUse={roadUse}&entityType={entityType}&callback={callback}&language={language}&allowFreeformNewline={allowFreeformNewline}&returnMatchType={returnMatchType}&view={view}&mapcodes={mapcodes}&filter={filter}'
Request parameters
The following table describes the parameters that can be used in a request.
- Required parameters must be used or the call will fail.
- Optional parameters may be used.
- If there is a default value that will be assumed when an optional parameter is not used, it is shown in the table.
- The order of request parameters is not important.
Required parameters | Description |
---|---|
baseURL string | Base URL for calling the API. Values:
|
versionNumber string | The service version. Value: The current value is 2 . |
position comma-separated string | This is specified as a comma-separated string composed by lat,lon. Value: lat,lon Example: 37.553,-122.453 |
ext string | A valid response format: Values: json , jsonp , js , or xml |
key string | An API Key valid for the requested service. Value: Your valid TomTom API Key . |
Optional parameters | Description |
---|---|
returnSpeedLimit boolean | Enables the return of the posted speed limit (where available). Default value: false |
heading float | The directional heading of the vehicle in degrees, for travel along a segment of roadway.
-360 to 360 . |
radius integer | The maximum distance in meters from the specified position for the reverseGeocode to consider.Default value: 10000 meters (10 km). |
number string | If a number is sent in along with the request, the response may include the side of the street (Left/Right), and also an offset position for that number. Note: The number can include a character such as "94c". Value: A number. |
returnRoadUse boolean | Enables the return of the roadUse array for reverseGeocodes at street level.Default value: false . |
roadUse array | Restricts reverseGeocodes to a certain type of road use.Value: The roadUse JSON array for reverseGeocodes can be one or more of:GET roadUse JSON array
See RFC 8259: "An array structure is represented as square brackets surrounding zero or more values (or elements). Elements are separated by commas. array = begin-array [ value *( value-separator value ) ] end-array ". |
entityType comma-separated string | This parameter specifies the level of filtering performed on geographies.
Values: One or more of:
|
callback string | Specifies the callback method. Default value: cb |
language string | The language in which search results should be returned.
Default value: NGT Deprecation notice: Support for no-NO will be removed in favour of no-NB. |
allowFreeformNewline boolean | The format of newlines in the formatted address.
false . |
returnMatchType boolean | This includes information on the type of match the geocoder achieved in the response. Default value: false . |
view string | Geopolitical View.
Default values:
|
mapcodes comma-separated string | Enables the return of mapcodes. Can also filter the response to only show selected mapcode types. See mapcode in the response.Values: One or more of:
A mapcode represents a specific location, to within a few meters. Every location on Earth can be represented by a mapcode. Mapcodes are designed to be short, easy to recognize, remember and communicate. Visit the Mapcode project website for more information. |
filter comma-separated string | Excludes a certain group of inspected address-carrying elements in order to find the closest match to a requested point. Value: ["BackRoads"] BackRoads - Roads that do not have an official name and any other kind of address information attached: unaddressable paths, forest paths, tracks, commercial driveways used as service roads, hiking paths, etc. Use of this filter is advised in cases where obtaining accurate address is top priority. It should not be used in a 'vehicle/asset tracking' use case or in road elements 'matching/focus' use case(s). |
Request headers
The following table describes HTTP request headers.
Optional headers | Description |
---|---|
Accept-Encoding | Enables response compression. Value: gzip |
Tracking-ID | Specifies an identifier for the request.
Value: An identifier for the request. |
Response data
Response body
For illustrative purposes the examples below are neatly indented.
- Please note that actual responses will vary based on the result type and the data available.
- See the following response field section for more information.
When requesting JSON output, the response has the following structure:
1{2 "summary": {3 "queryTime": 102,4 "numResults": 15 },6 "addresses": []7}
Example response for the result of the Point Address
type is in the following format:
Point Address type example response - JSON
1{2 "summary": {3 "queryTime": 17,4 "numResults": 15 },6 "addresses": [7 {8 "address": {9 "buildingNumber": "2501",10 "streetNumber": "2501",11 "routeNumbers": [],12 "street": "Soquel Drive",13 "streetName": "Soquel Drive",14 "streetNameAndNumber": "2501 Soquel Drive",15 "speedLimit": "35.00MPH",16 "countryCode": "US",17 "countrySubdivision": "CA",18 "countrySecondarySubdivision": "Santa Cruz",19 "municipality": "Santa Cruz",20 "postalCode": "95065",21 "municipalitySubdivision": "Santa Cruz, Live Oak",22 "sideOfStreet": "L",23 "offsetPosition": "36.988430,-121.974731",24 "country": "United States",25 "countryCodeISO3": "USA",26 "freeformAddress": "2501 Soquel Drive, Santa Cruz, CA 95065",27 "boundingBox": {28 "northEast": "36.988197,-121.974752",29 "southWest": "36.988156,-121.975108",30 "entity": "position"31 },32 "extendedPostalCode": "950651900",33 "countrySubdivisionName": "California",34 "localName": "Santa Cruz"35 },36 "position": "36.988159,-121.974762",37 "roadUse": [38 "Arterial"39 ],40 "matchType": "AddressPoint",41 "mapcodes":[42 {43 "type":"Local",44 "fullMapcode":"US-CA FS.WRH3",45 "territory":"US-CA",46 "code":"FS.WRH3"47 },48 {49 "type":"International",50 "fullMapcode":"S4ZW4.990V"51 },52 {53 "type":"Alternative",54 "fullMapcode":"US-CA 4349.S8W",55 "territory":"US-CA",56 "code":"4349.S8W"57 },58 {59 "type":"Alternative",60 "fullMapcode":"US-CA JJCH.H9DF",61 "territory":"US-CA",62 "code":"JJCH.H9DF"63 },64 {65 "type":"Alternative",66 "fullMapcode":"USA JJCH.H9DF",67 "territory":"USA",68 "code":"JJCH.H9DF"69 }70 ]71 }72 ]73}
Example response for the Geography result with entityType=PostalCodeArea
filtering:
Geography example response - JSON
1{2 "summary": {3 "queryTime": 10,4 "numResults": 15 },6 "addresses": [7 {8 "address": {9 "routeNumbers": [],10 "countryCode": "US",11 "countrySubdivision": "CA",12 "countrySecondarySubdivision": "Santa Cruz",13 "municipality": "Santa Cruz",14 "postalName": "Santa Cruz",15 "postalCode": "95065",16 "country": "United States",17 "countryCodeISO3": "USA",18 "freeformAddress": "Santa Cruz, CA 95065",19 "boundingBox": {20 "northEast": "37.085762,-121.949375",21 "southWest": "36.983408,-122.013236",22 "entity": "position"23 },24 "countrySubdivisionName": "California"25 },26 "position": "36.988171,-121.974876",27 "dataSources": {28 "geometry": {29 "id": "00005543-3300-3c00-0000-00004dc8b8e5"30 }31 },32 "entityType": "PostalCodeArea",33 "mapcodes":[34 {35 "type":"Local",36 "fullMapcode":"US-CA FS.WRG0",37 "territory":"US-CA",38 "code":"FS.WRG0"39 },40 {41 "type":"International",42 "fullMapcode":"S4ZW4.89XV"43 },44 {45 "type":"Alternative",46 "fullMapcode":"US-CA 4349.S7L",47 "territory":"US-CA",48 "code":"4349.S7L"49 },50 {51 "type":"Alternative",52 "fullMapcode":"US-CA JJCH.H9CF",53 "territory":"US-CA",54 "code":"JJCH.H9CF"55 },56 {57 "type":"Alternative",58 "fullMapcode":"USA JJCH.H9CF",59 "territory":"USA",60 "code":"JJCH.H9CF"61 }62 ]63 }64 ]65}
Response fields
The following tables describe all of the fields that can appear in a response. Fields are listed by the response section they belong to and in the order that they appear in the response.
Primary fields | |
---|---|
Field | Description |
summary object | Summary information about the search that was performed.summary object |
addresses array | The result list, sorted in descending order by score.addresses array |
summary object | |
Field | Description |
queryTime integer | The time spent on resolving the query (in milliseconds). |
numResults integer | The number of results in the response. |
addresses array | |
Field | Description |
address object | The structured address for the result.address object |
position double (LatLon) | Position of the result in a form of "latitude,longitude" coordinates. Example: 37.553,-122.453 |
roadUse array | List of road usage types at the address. Zero or more of:
|
matchType string | Information on the type of match. One of:
|
dataSources object | Optional section. Reference ids for use with the Additional Data service. dataSources objectgeometry object |
mapcodes array | Optional section. List of mapcode objects.mapcode object |
address object | |
Field | Description |
buildingNumber string Deprecated | The building number on the street.
|
streetNumber string | The building number on the street. |
routeNumbers array | The codes used to unambiguously identify the street. |
street string Deprecated | The street name.
|
streetName string | The street name. |
streetNameAndNumber string | The street name and number. |
speedLimit string | The speed limit for the street in the form DD.DDUUU, For example:
|
countryCode string | Country (Note: This is a two-letter code, not a country name.) |
countrySubdivision string | State or Province |
countrySecondarySubdivision string | County |
countryTertiarySubdivision string | Named Area |
municipality string | City / Town |
postalName string | An address component which represents the name for a postal code that is related to a single administrative area, city, town, or other populated place.
|
postalCode string | Postal Code / Zip Code |
municipalitySubdivision string | Sub / Super City |
sideOfStreet string | The left or right side of the street location. This is returned only when the number parameter was defined. |
offsetPosition string | The offset position coordinates of the location. Example: 37.553,-122.453 |
country string | Country name |
countryCodeISO3 string | ISO alpha-3 country code |
freeformAddress string | An address line formatted according to the formatting rules of a Result's country of origin, or in the case of a country, its full country name. |
boundingBox object | The bounding box of the location.boundingBox object |
countrySubdivisionName string | The full name of a first level of country administrative hierarchy.
|
countrySubdivisionCode string | countrySubdivisionCode prefixed by countryCode and the hyphen (countryCode-countrySubdivisionCode ) forms the ISO 3166-2 code.countrySubdivisionCode examples: TX for Texas, SCT for Scotland, ON for Ontario, ZE for Zeeland and BB for Brandenburg.
|
localName string | An address component which represents the name of a geographic area or locality that groups a number of addressable objects for addressing purposes, without being an administrative unit. |
extendedPostalCode string | Extended postal code (availability is dependent on the region). |
boundingBox object | |
Field | Description |
northEast comma-separated floats | North-east (top-left) latitude ,longitude coordinate of the bounding box. |
southWest comma-separated floats | South-west (bottom-right) latitude ,longitude coordinate of the bounding box. |
entity string | Entity type source of the bounding box. Note: For reverse-geocoding this is always equal to position. |
dataSources object | |
Field | Description |
geometry object | Information about the geometric shape of the result. Only present if type == Geography .geometry object |
geometry object | |
Field | Description |
id string | Pass this as geometryId to the Additional Data service to fetch geometry information for this result. |
mapcode object | |
Field | Description |
type string | Type of mapcode. Possible values:Local : The shortest possible (and easiest to remember) mapcode.
International : this mapcode is unambiguous. It is also the longest.Alternative : alternatives to Local mapcodes.
|
fullMapcode string | The full form of a mapcode (territory + code ). It is always unambiguous.
|
territory string | The territory element of the mapcode.
|
code string | The mapcode without the territory element.
|
Default view mapping
Default view is recognized based on the country the request came from.
Country | Default view | Other available views |
---|---|---|
Argentina | AR | Unified, IL, IN, MA, PK, RU, TR, CN |
India | IN | - |
Morocco | MA | Unified , AR , IL , IN , PK , RU , TR , CN |
Pakistan | PK | Unified , AR , IL , IN , MA , RU , TR , CN |
Russia | RU | Unified , AR , IL , IN , MA , PK , TR , CN |
Turkey | TR | Unified , AR , IL , IN , MA , PK , RU , CN |
China | CN | Unified , AR , IL , IN , MA , PK , RU , TR |
Others | Unified | AR , IL , IN , MA , PK , RU , TR , CN |
Response codes
The following data table contains response codes signifying successful and failed requests to an API server.
Code | Meaning & possible causes |
---|---|
200 | OK The search successfully returned zero or more results. |
400 | Bad request: One or more parameters were incorrectly specified. |
403 | Forbidden: Possible causes include,
|
405 | Method Not Allowed: The HTTP method (GET , POST , etc.) is not supported for this request. |
404/596 | Not Found: The HTTP request method (GET , POST , etc.) or path is incorrect. |
429 | Too Many requests: The API Key is over QPS (Queries per second). |
5xx | Server Error: The service was unable to process your request. Contact support to resolve the issue. |
Response headers
The following data table contains response headers sent back from an API server.
Header | Description |
---|---|
Access-Control-Allow-Origin | Ensures that clients implementing the CORS security model are able to access the response from this service. Value: An asterisk * that signifies access to the TomTom API using the Access-Control-Allow-Origin (ACAO) header in its response indicating which origin sites are allowed. |
Content-Type | Indicates the format of the response, as chosen by the client. Format: type/subtype; charset=utf-8 Value: type/subtype is one of:
|
Content-Encoding | The Reverse Geocode service applies gzip compression to the responses if requested by the client with the Accept-Encoding header. Value: gzip |
Tracking-ID | An identifier for the request.
identifier for the request. |
Error response
The content type of an error response depends on the requested output format (.json
or .xml
).
1{2 "error": "Invalid request: invalid position: latitude/longitude out of range.",3 "httpStatusCode": 400,4 "detailedError": {5 "code": "BadRequest",6 "message": "Invalid request: invalid position: latitude/longitude out of range.",7 "target": "position"8 }9}
1<?xml version="1.0" encoding="UTF-8" standalone="yes"?>2<response>3 <error>Invalid request: invalid position: latitude/longitude out of range.</error>4 <httpStatusCode>400</httpStatusCode>5 <detailedError>6 <code>BadRequest</code>7 <message>Invalid request: invalid position: latitude/longitude out of range.</message>8 <target>position</target>9 </detailedError>10</response>
Error response fields
Primary fields | Description |
---|---|
error string | A human-readable description of the error code. It is intended as an aid to developers and is not suitable for exposure to end users. |
httpStatusCode integer | HTTP error code. |
detailedError object | Detailed information about the error.detailedError object |
detailedError object | |
Field | Description |
code string | One of the defined error codes. |
message string | A human-readable representation of the error code. It is intended as an aid to developers and is not suitable for exposure to end users. |
target string | Optional. Target of the particular error. Value: The name of the request parameter. |
Error code hierarchy
A list of predefined, hierarchical, human-readable error codes.
The httpStatusCode
relates to HTTP error codes. An error code in detailedError
can redefine httpStatusCode
to one of the codes described in this section.
In the future, the list may be extended with additional codes.
Error code | Description |
---|---|
BadRequest | The code for requests which ended with HTTP |
Forbidden | The code for requests which ended with HTTP |
InternalServerError | The code for requests which ended with HTTP 500 Internal Server Error . The service cannot handle the request right now, an unexpected condition was encountered. |
ServerTimeout | The code for requests which ended with HTTP 504 Gateway Timeout . The service cannot handle the request right now, this is certainly a temporary state. |