Geocode
Purpose
In many cases, the complete Search service might be too much. For instance, if you are only interested in traditional Geocoding, Search can also be exclusively accessed for address look-up. The Geocoding is performed by hitting the Geocode endpoint with just the address or partial address in question. The Geocoding index will be queried for everything above the street level data.
No POIs (Points of Interest) will be returned. Note that the geocoder
is very tolerant of typos and incomplete addresses. It will also handle everything from exact street addresses, streets, or intersections as well as higher-level geographies such as city centers, counties, states, etc.
Run this endpoint
You can easily run this and other endpoints. Go to the TomTom API Explorer page and follow the directions.
Request data
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 request format
https://{baseURL}/search/{versionNumber}/geocode/{query}.{ext}?key={Your_API_Key}&storeResult={storeResult}&typeahead={typeahead}&limit={limit}&ofs={ofs}&lat={lat}&lon={lon}&countrySet={countrySet}&radius={radius}&topLeft={topLeft}&btmRight={btmRight}&language={language}&extendedPostalCodesFor={extendedPostalCodesFor}&view={view}&mapcodes={mapcodes}&entityTypeSet={entityTypeSet}
URL request example
https://api.tomtom.com/search/2/geocode/De%20Ruijterkade%20154%2C%201011%20AC%2C%20Amsterdam.json?key={Your_API_Key}
curl command request example
curl 'https://api.tomtom.com/search/2/geocode/De%20Ruijterkade%20154%2C%201011%20AC%2C%20Amsterdam.json?key={Your_API_Key}'
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.
- The order of request parameters is not important.
Required parameters | Description |
---|---|
string | Base URL for calling the API. Values:
|
string | Service version number. Value: The current value is |
string | Query string. Must be properly URL encoded. Value: A properly URL encoded query string. |
string | A valid response format: Values: |
string | An API Key valid for the requested service. Value: Your valid |
Optional parameters | Description |
---|---|
| If the
|
| If the
|
| The maximum number of responses that will be returned. |
| The starting offset of the returned results within the full result set. The total number of results can be no more than 2000. If you want to receive all the results, you need to limit the number of results by using, for example the radius parameter. |
| Latitude, e.g., |
| Longitude, e.g., |
| Comma separated string of country codes in ISO 3166-1 alpha-2 or alpha-3 code formats (e.g., |
| If |
| Top-left position of the bounding box. This is specified as a comma-separated string composed by lat,lon (e.g., |
| Bottom-right position of the bounding box. This is specified as a comma-separated string composed by lat,lon (e.g., |
| Language in which search results should be returned. It should be one of the TomTom IETF Supported Language Tags , case insensitive. When data in the specified language is not available for a specific field or the language is not specified, the language best matched with your query is used. |
| Indexes for which extended postal codes should be included in the results. Available values are described in Additional Information indexes abbreviation values section. The value should be a comma-separated list of index types (in any order) or "None" for no indexes. By default, extended postal codes are included for all indexes except Geo. Extended postal code lists for geographies can be quite long, so they have to be explicitly requested when needed. Extended postal code is returned as the
|
view string | Geopolitical View. The context used to resolve the handling of disputed territories. Views include
|
| Enables the return of a comma-separted mapcodes list. It can also filter the response to only show selected mapcode types. See mapcodes in the response. 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.
Usage examples:
|
| A comma-separated list of entity types which can be used to restrict the result to the Geography result of a specific entity type.
If
Usage examples:
|
Request headers
Optional headers | Description |
---|---|
Enables response compression. Value: | |
Tracking-ID | Specifies an identifier for the request. It can be used to trace a call.
The value must match the regular expression
Value: An |
Response data
Response body
For illustrative purposes the example below is neatly indented and includes all possible response fields. Actual responses are more compact and the fields present will vary based on the result type and the data available. See the following response fields documentation for more information. When requesting JSON output the response has the following structure:
1{2 "summary": {3 "query": "2501 soquel dr santa cruz ca 95065",4 "queryType": "NON_NEAR",5 "queryTime": 8,6 "numResults": 1,7 "offset": 0,8 "totalResults": 1,9 "fuzzyLevel": 1,10 "geoBias": {11 "lat": 36.98844,12 "lon": -121.9748313 }14 },15 "results": []16}
Where each element of the results
array is in the following format:
1{2 "type": "Point Address",3 "id": "US/PAD/p0/45619296",4 "score": 15.725,5 "matchConfidence": {6 "score": 17 },8 "dist": 0.8875712594288668,9 "address": {10 "streetNumber": "2501",11 "streetName": "Soquel Dr",12 "municipalitySubdivision": "Santa Cruz, Live Oak",13 "municipality": "Santa Cruz, Live Oak",14 "countrySecondarySubdivision": "Santa Cruz",15 "countryTertiarySubdivision": "Santa Cruz",16 "countrySubdivision": "CA",17 "postalCode": "95065",18 "extendedPostalCode": "950652023",19 "countryCode": "US",20 "country": "United States Of America",21 "countryCodeISO3": "USA",22 "freeformAddress": "2501 Soquel Dr, Santa Cruz, CA 95065",23 "countrySubdivisionName": "California",24 "localName": "Santa Cruz"25 },26 "position": {27 "lat": 36.98844,28 "lon": -121.9748229 },30 "mapcodes": [31 {32 "type": "Local",33 "fullMapcode": "US-CA FS.WRH3",34 "territory": "US-CA",35 "code": "FS.WRH3"36 },37 {38 "type": "International",39 "fullMapcode": "S4ZW4.990V"40 },41 {42 "type": "Alternative",43 "fullMapcode": "US-CA 4349.S8W",44 "territory": "US-CA",45 "code": "4349.S8W"46 },47 {48 "type": "Alternative",49 "fullMapcode": "US-CA JJCH.H9DF",50 "territory": "US-CA",51 "code": "JJCH.H9DF"52 },53 {54 "type": "Alternative",55 "fullMapcode": "USA JJCH.H9DF",56 "territory": "USA",57 "code": "JJCH.H9DF"58 }59 ],60 "viewport": {61 "topLeftPoint": {62 "lat": 36.98934,63 "lon": -121.9759564 },65 "btmRightPoint": {66 "lat": 36.98754,67 "lon": -121.9736968 }69 },70 "entryPoints": [71 {72 "type": "main",73 "position": {74 "lat": 36.98817,75 "lon": -121.9748776 }77 }78 ],79 "addressRanges": {80 "rangeLeft": "1 - 3",81 "rangeRight": "2 - 12",82 "from": {83 "lat": 51.16561,84 "lon": 19.4848985 },86 "to": {87 "lat": 51.16545,88 "lon": 19.486389 }90 },91 "dataSources": {92 "geometry": {93 "id": "00004e4c-3100-3c00-0000-0000685e23c7"94 }95 }96}
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 |
object | Summary information about the search that was performed. summary object |
array | The result list, sorted in descending order by score. |
summary object | |
Field | Description |
string | The query as interpreted by the search engine. |
string | Response type. Can be
|
integer | Time spent on resolving the query. |
integer | The number of results in the response. |
integer | The starting offset of the returned results within the full result set. |
integer | The total number of results found. |
integer | The maximum fuzzy level required to provide results. |
object | The position used to bias the results: Latitude, Longitude |
results array | |
Field | Description |
string | Type of result. Value: One of:
|
string | the non-stable unique id for this result. |
double | The score of the result. A larger score means there is a probability that a result meeting the query criteria is higher.
|
object | The confidence of the result's textual match with the query. matchConfidence object |
double | Unit: meters. This is the distance to an object if |
object | The structured address for the result. address object |
object | The position of the result: Latitude, Longitude. |
array | List of mapcodes object |
object | A viewport which can be used to display the result on a map. viewport object |
object | Optional section. Only present if type == Geography. A bounding box which can be used to display the result on a map defined by minimum and maximum longitudes and latitudes. boundingBox object |
array | A list of entry points of the POI (Points of Interest). entryPoints array |
object | The address ranges on a street segment. Available only for results where the result type is equal to Address Range. addressRanges object |
object | An optional section. These are unique reference ids for use with the Additional Data service. dataSources object |
address object | |
Field | Description |
string | The building number on the street. |
string | The building name or code of the address. This can be a descriptive name, an alphanumeric string, or even a single alphabetic character or numerical digit. |
string | The street name. |
string | Sub / Super City |
string | City / Town |
string | County |
string | Named Area |
string | State or Province |
string | Postal Code / Zip Code |
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. Note: This field only appears for geographies having
|
string | Extended postal code (availability dependent on region). |
string | A country's code (Note: This is a two-letter code, not a country name.). |
string | Country name |
string | ISO alpha-3 country code |
string | An address line formatted according to the formatting rules of the
result's country of origin. In the case of countries, its full
country name. For the USA, in the case of geographies with
|
string | The full name of the first level of country administrative hierarchy.
This field appears only in case |
string |
|
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. |
matchConfidence object | |
Field | Description |
double | Represents the overall textual match score, in the range of [0..1], where 1 means a perfect match and 0 - no match. Example:
|
mapcodes object | |
Field | Description |
string | Type of mapcode:
|
string | The full form of a mapcode ( |
string | The
an address has little meaning unless the user also knows what state it's
in (just as, elsewhere, an address has little meaning if the user
doesn’t know what country it’s in). More information about
|
string | The mapcode without the |
viewport object | |
Field | Description |
object | Top-left corner of the rectangle: |
object | Bottom-right corner of the rectangle: |
boundingBox object | |
Field | Description |
object | Top-left position of the bounding box: |
object | Bottom-right position of the bounding box: |
entryPoints array | |
Field | Description |
string | The main entry point. One of:
|
array | If present, represents the type of access for the POI. Example: |
object | Position of the entry point. |
addressRanges object | |
Field | Description |
string | An address range on the left side of a street segment (assuming looking from the "from" end toward the "to" end). |
string | An address range on the right side of a street segment (assuming looking from the "from" end toward the "to" end). |
object | The beginning point of a street segment: Latitude, Longitude |
object | The end point of a street segment: Latitude, Longitude |
dataSources object | |
Field | Description |
object | Information about the geometric shape of the result. Only present if
|
geometry | |
Field | Description |
string | Pass this as |
LatLon | |
Field | Description |
float | Latitude. min/max: -90 to +90 |
float | Longitude. min/max: -180 to +180 |
Response codes
The following data table contains HTTP response codes signifying successful and failed requests to an API server.
Successful and failed response codes | |
---|---|
Code | Meaning & possible causes |
| OK : The search successfully returned zero or more results. |
| Bad Request : One or more parameters were incorrectly specified. |
| Forbidden : Possible causes include:
|
| Method Not Allowed : The HTTPS method ( |
| Not Found : The HTTPS request method ( |
| Too Many Requests : The API Key is over QPS (Queries per second). |
| Server Error : The service was unable to process your request. Contact support to resolve the issue. |
Response headers
The following table contains response headers sent back from an API server.
Header | Description |
---|---|
Ensures that clients implementing the CORS security model are able to access the response from this service. Value: An asterisk | |
Indicates the format of the response, as chosen by the client. Format: Values: | |
If requested by the client, the Search service applies gzip compression to the responses with the Accept-Encoding header. Value: | |
Tracking-ID | An identifier for the request. If the Tracking-ID header was specified, it is replicated in the response. Otherwise, it is generated automatically by the service. It is only meant to be used for support and does not involve tracking of you or your users in any form. Value: An |
Error response
The error response content type depends on the ext
parameter.
1{2 "errorText": "Error parsing 'language': Language tag 'en-ES' not supported",3 "detailedError": {4 "code": "BadRequest",5 "message": "Error parsing 'language': Language tag 'en-ES' not supported",6 "target": "language"7 },8 "httpStatusCode": "400"9}
1<?xml version="1.0" encoding="UTF-8"?>2<response>3 <errorText>Error parsing 'language': Language tag 'en-ES' not supported</errorText>4 <detailedError>5 <code>BadRequest</code>6 <message>Error parsing 'language': Language tag 'en-ES' not supported</message>7 <target>language</target>8 </detailedError>9 <httpStatusCode>400</httpStatusCode>10</response>
Error response fields
Primary fields | |
---|---|
Field | Description |
string | A human-readable description of the error. |
object | Detailed information about the error. detailedError object |
integer | HTTP response codes signifying failed requests to an API server. |
detailedError object | |
Field | Description |
string | One of a server-defined set of error codes. |
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. |
string | Optional. Target of the particular error. Value: The name of the request parameter causing the error. |
Additional information
Indexes abbreviation values
In some cases, a list of indexes can be passed as a parameter to query, which should be listed with their abbreviations, available values are:
Geo
= Geographies - areas on map which represent administrative divison of a land i.e., country, state, city.PAD
= Point Addresses - points on a map where a specific address with a street name and number can be found in the index, i.e., Soquel Dr 2501.Addr
= Address ranges - for some streets there are address points that are interpolated from the beginning and end of the street, those points are represented as address ranges.Str
= Streets - representation of streets on the map.XStr
= Cross Streets (intersections) - representations of junctions; places where two streets intersect.