Structured Geocode

Service version: 2
Last edit: 2023.09.30

Purpose

Search can also be exclusively accessed for structured address look up. 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, street, or intersections, and 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

get
URL request format
https://{baseURL}/search/{versionNumber}/structuredGeocode.{ext}?key={Your_API_Key}&countryCode={countryCode}&limit={limit}&ofss={ofss}&streetNumber={streetNumber}&streetName={streetName}&crossStreet={crossStreet}&municipality={municipality}&municipalitySubdivision={municipalitySubdivision}&countryTertiarySubdivision={countryTertiarySubdivision}
&countrySecondarySubdivision={countrySecondarySubdivision}&countrySubdivision={countrySubdivision}&postalCode={postalCode}&language={language}&extendedPostalCodesFor={extendedPostalCodesFor}&view={view}&mapcodes={mapcodes}&entityTypeSet={entityTypeSet}

URL request example

get
URL request example
https://api.tomtom.com/search/2/structuredGeocode.json?key={Your_API_Key}&countryCode=US

curl command request example

get
curl command request example
curl 'https://api.tomtom.com/search/2/structuredGeocode.json?key={Your_API_Key}&countryCode=US'

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 parametersDescription

baseURL
string

Base URL for calling the API.
Values:

versionNumber
string

Service version number.
Value: The current value is 2.

structuredGeocode
string

Endpoint name.
Value: structuredGeocode

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 API Key.

countryCode
string

The code of the country being targeted.
Value: A country code (Note: This is a two-letter code, not a country name.)

Optional parametersDescription

limit
integer

The maximum number of responses that will be returned.
Default value: 10
Maximum value: 100

ofs
integer

The starting offset of the returned results within the full result set.
Default value: 0
Maximum value: 1900
The total number of results can be no more than 2000.

streetNumber
string

The street number for the structured address.
Value: A street number.

streetName
string

The street name for the structured address.
Value: A street name.

crossStreet
string

The cross street name for the structured address.
Value: A cross street name.

municipality
string

The municipality (city/town) for the structured address.
Value: A municipality.

municipalitySubdivision
string

The municipality subdivision (sub/super city) for the structured address.
Value: A municipality subdivision.

countryTertiarySubdivision
string

The named area for the structured address.
Value: A country tertiary subdivision.

countrySecondarySubdivision
string

The county for the structured address.
Value: A country name.

countrySubdivision
string

The state or province for the structured address.
Value: A country subdivision.

postalCode
string

The zip code or postal code for the structured address.
Value: A zip or postal code.

language
string

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.
Value: A TomTom IETF Supported Language Tag.

extendedPostalCodesFor
string

Indexes for which extended postal codes should be included in the results. Available values are described in the additional information indexes Indexes abbreviated 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 an extendedPostalCode property of an address. Availability is region-dependent.
Value: A comma-separated list of index types.
Usage examples :

  • extendedPostalCodesFor=POI

  • extendedPostalCodesFor=PAD,Addr,POI

  • extendedPostalCodesFor=None

view
string

Geopolitical View. The context used to resolve the handling of disputed territories. Views include Unified, along with AR, IL, IN, MA, PK, RU, TR, and CN which are respectively tailored for Argentina, Israel, India, Morocco, Pakistan, Russia, Turkey, and China.
Default values:

  • Argentina, default view: AR, available views:
    Unified, IL, IN, MA, PK, RU, TR, CN

  • India, default view: IN, available views: -

  • Morocco, default view: MA, available views:
    Unified, AR, IL, IN, PK, RU, TR, CN

  • Pakistan, default view: PK, available views:
    Unified, AR, IL, IN, MA, RU , TR, CN

  • Russia, default view: RU, available views:
    Unified, AR, IL, IN, MA, PK, TR, CN

  • Turkey, default view: TR, available views:
    Unified, AR, IL, IN, MA, PK, RU, CN

  • China, default view: CN, available views:
    Unified, AR, IL, IN, MA, PK, RU, TR

  • Others, default view: Unified, available views:
    AR, IL, IN, MA, PK, RU, TR, CN

entityTypeSet
string

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 entityTypeSet is specified, only a Geography result with a proper entity type will be returned.
Value: A comma-separated list of of entity types. Item order in the list does not matter. Values are case sensitive.
Available values:

  • Country
  • CountrySubdivision
  • CountrySecondarySubdivision
  • CountryTertiarySubdivision
  • Municipality
  • MunicipalitySubdivision
  • Neighborhood
  • PostalCodeArea

Usage examples:

  • entityTypeSet=Municipality: Only returns results with a Municipality entity type.

  • entityTypeSet=Municipality,MunicipalitySubdivision: Returns results with a Municipality or MunicipalitySubdivision entity type.

Request headers

Optional headersDescription
Accept-Encoding

Enables response compression.
Value: gzip

Tracking-ID

Specifies an identifier for the request.

  • It can be used to trace a call.
  • The value must match the regular expression '^[a-zA-Z0-9-]{1,100}$'.
  • An example of the format that matches this regular expression is UUID: (e.g., 9ac68072-c7a4-11e8-a8d5-f2801f1b9fd1).
  • For details check RFC 4122.
  • If specified, it is replicated in the Tracking-ID response header.
  • It is only meant to be used for support and does not involve tracking of you or your users in any form.

Value: An identifier for the request.

Default view mapping

Default view is recognized based on the country the request came from.

CountryDefault and available views
Argentina

Default view: AR
Available views: Unified, IL, IN, MA, PK, RU, TR

India

Default view: IN
Available views: -

Morocco

Default view: MA
Available views: Unified, AR, IL, IN, PK, RU, TR

Pakistan

Default view: PK
Available views: Unified, AR, IL, IN, MA, RU, TR

Russia

Default view: RU
Available views: Unified, AR, IL, IN, MA, PK, TR

Turkey

Default view: TR
Available views: Unified, AR, IL, IN, MA, PK, RU

Others

Default view: Unified
Available views: AR, IL, IN, MA, PK, RU, TR

mapcodes
string

Enables the return of a comma-separated mapcodes list. It can also filter the response to only show selected mapcode types. See mapcodes in the response.
Values: One or more of:

  • Local

  • International

  • Alternative

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:

  • mapcodes=Local (returns only the local mapcode for a location)

  • mapcodes=Local,Alternative (returns both, local, and alternative mapcodes for a location)

  • mapcodes=Local,Alternative,International (returns all possible mapcodes for a location)

Response data

Response body

For illustrative purposes, the following code examples are 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 field section for more information. When requesting JSON output the response has the following structure:

Response structure - JSON
1{
2 "summary": {
3 "query": "2501 soquel dr",
4 "queryType": "NON_NEAR",
5 "queryTime": 21,
6 "numResults": 1,
7 "offset": 0,
8 "totalResults": 1,
9 "fuzzyLevel": 1
10 },
11 "results": []
12}

Each element of the results array is in the following format:

Results array elements format - JSON
1{
2 "type": "Point Address",
3 "id": "US/PAD/p0/45619296",
4 "score": 7.675,
5 "address": {
6 "streetNumber": "2501",
7 "streetName": "Soquel Dr",
8 "municipalitySubdivision": "Santa Cruz, Live Oak",
9 "municipality": "Santa Cruz, Live Oak",
10 "countrySecondarySubdivision": "Santa Cruz",
11 "countryTertiarySubdivision": "Santa Cruz",
12 "countrySubdivision": "CA",
13 "postalCode": "95065",
14 "extendedPostalCode": "950652023",
15 "countryCode": "US",
16 "country": "United States Of America",
17 "countryCodeISO3": "USA",
18 "freeformAddress": "2501 Soquel Dr, Santa Cruz, CA 95065",
19 "countrySubdivisionName": "California",
20 "localName": "Santa Cruz"
21 },
22 "position": {
23 "lat": 36.98844,
24 "lon": -121.97482
25 },
26 "mapcodes": [
27 {
28 "type": "Local",
29 "fullMapcode": "US-CA FS.WRH3",
30 "territory": "US-CA",
31 "code": "FS.WRH3"
32 },
33 {
34 "type": "International",
35 "fullMapcode": "S4ZW4.990V"
36 },
37 {
38 "type": "Alternative",
39 "fullMapcode": "US-CA 4349.S8W",
40 "territory": "US-CA",
41 "code": "4349.S8W"
42 },
43 {
44 "type": "Alternative",
45 "fullMapcode": "US-CA JJCH.H9DF",
46 "territory": "US-CA",
47 "code": "JJCH.H9DF"
48 },
49 {
50 "type": "Alternative",
51 "fullMapcode": "USA JJCH.H9DF",
52 "territory": "USA",
53 "code": "JJCH.H9DF"
54 }
55 ],
56 "viewport": {
57 "topLeftPoint": {
58 "lat": 36.98934,
59 "lon": -121.97595
60 },
61 "btmRightPoint": {
62 "lat": 36.98754,
63 "lon": -121.97369
64 }
65 },
66 "entryPoints": [
67 {
68 "type": "main",
69 "position": {
70 "lat": 36.98817,
71 "lon": -121.97487
72 }
73 }
74 ],
75 "addressRanges": {
76 "rangeLeft": "1 - 99",
77 "rangeRight": "2 - 130",
78 "from": {
79 "lat": 37.33666,
80 "lon": -121.88951
81 },
82 "to": {
83 "lat": 37.338,
84 "lon": -121.89049
85 }
86 },
87 "dataSources": {
88 "geometry": {
89 "id": "0000504c-3200-4600-0000-0000478d98c6"
90 }
91 }
92}

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
FieldDescription

summary
object

Summary information about the search that was performed. summary object

results
array

The result list, sorted in descending order by score. results array

summary object
FieldDescription

query
string

Query as interpreted by the search engine.

queryType
string
Deprecated

Response type. Can be NEARBY or NON_NEAR.

May 13, 2023

  • The queryType parameter has been deprecated and will be withdrawn following a 12 month deprecation period.
  • The planned withdrawal date is May 13, 2024.
  • Following withdrawal, API requests that include the queryType parameter will receive an HTTP 400 error in the response.

queryTime
integer

Time spent on resolving the query.

numResults
integer

The number of results in the response.

offset
integer

The starting offset of the returned results within the full result set.

totalResults
integer

The total number of results found.

fuzzyLevel
integer

The maximum fuzzy level required to provide results.

geoBias
object

The position used to bias the results: Latitude,Longitude LatLon

results array
FieldDescription

type
string

Type of result.
Value: One of:

  • Street

  • Geography

  • Point Address

  • Address Range

  • Cross Street

id
string

The non-stable unique id for this result.

score
double
Deprecated

The score of the result. A larger score means there is a probability that a result meeting the query criteria is higher.

May 13, 2023

  • The score parameter has been deprecated and will be withdrawn following a 12 month deprecation period.
  • The planned withdrawal date is May 13, 2024.
  • Following withdrawal, API requests that include the score parameter will receive an HTTP 400 error in the response.

dist
double

Unit: meters. This is the distance to an object if geobias was provided.

address
object

The structured address for the result.

position
object

The position of the result: Latitude,Longitude. LatLon

mapcodes
array

List of mapcode objects. mapcodes object

viewport
object

A viewport which can be used to display the result on a map. viewport object

boundingBox
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

entrypoints
array

The list of entry points of the POI. entryPoints array

addressRanges
object

Address ranges on a street segment. Available only for results where the result type is equal to "Address Range". addressRanges object

dataSources
object

Optional section. Reference unique ids for use with the Additional Data service. dataSources object

address object
FieldDescription

streetNumber
string

The building number on the street.

streetName
string

The street name.

municipalitySubdivision
string

Sub / Super City

municipality
string

City / Town

countrySecondarySubdivision
string

County

countryTertiarySubdivision
string

Named Area

countrySubdivision
string

State or Province

postalCode
string

Postal Code / Zip Code

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. Note: This field only appears for geographies having entityType == PostalCodeArea. It is only supported for the USA.

extendedPostalCode
string

Extended postal code (availability dependent on region).

countryCode
string

Country

country
string

Country name

countryCodeISO3
string

ISO alpha-3 country code

freeformAddress
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 entityType == PostalCodeArea, it will contain the postalName field value.

countrySubdivisionName
string

The full name of the first level of a country administrative hierarchy. This field appears only in case countrySubdivision is presented in an abbreviated form. It is only supported only for the USA, Canada, and Great Britain.

countrySubdivisionCode
string

countrySubdivisionCode prefixed by countryCode (countryCode-countrySubdivisionCode) and the hyphen forms the ISO 3166-2 code. Only present if returned document has entityType == CountrySubdivision.
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.

mapcodes object
FieldDescription

type
string

Type of mapcode:
Local: The shortest possible (and easiest to remember) mapcode. Local mapcodes are especially useful when the user knows what territory the mapcode is in (for example, when an application is designed to be used inside just one European country or US state). Note that the code element of a Local mapcode is ambiguous when used without the territory element. For example, the "4J.P2" mapcode can mean the Eiffel Tower location (48.858380, 2.294440) (with the territory set to FRA), but also some place in Amsterdam-Noord, Netherlands (52.382184, 4.911021) (with the territory set to NLD).
International: This mapcode is unambiguous. It is also the longest.
Alternative: Alternatives to Local mapcodes. Each Alternative mapcode points to slightly different coordinates due to the way mapcodes are computed (see the mapcode documentation). For example, the position from a response can be encoded as "5DM.WC" (51.759244, 19.448316) and the "VHJ.036" (51.759245, 19.448264), which are close to each other, but not exactly the same place.

fullMapcode
string

The full form of a mapcode (territory + code). It is always unambiguous. The territory element is always in the Latin alphabet. In an International mapcode, the territory part is empty.

territory
string

The territory element of the mapcode. The territory element is always in the Latin alphabet. Usually, the territory is the ISO 3166-1 alpha 3 abbreviation for the country name. However in these eight very large countries:

  • USA
  • Canada
  • Mexico
  • Brazil
  • India
  • Australia
  • Russia
  • China

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 territory codes is available at Territories for mapcodes. This field is not returned for an International mapcode.

code
string

The mapcode without the territory element. It consists of two groups of letters and digits separated by a dot. The code is using the same language and alphabet as the response. The language parameter may be used to modify the language and alphabet of both the response and the code (for example: Cyrillic for the language ru-RU). This field is not returned for the International mapcodes. Use fullMapcode instead.

viewport object
FieldDescription

topLeftPoint
object

Top-left corner of the rectangle: LatLon

btmRightPoint
object

Bottom-right corner of the rectangle: LatLon

boundingBox object
FieldDescription

topLeftPoint
object

Top-left position of the bounding box: LatLon

btmRightPoint
object

Bottom-right position of the bounding box: LatLon

entryPoints array
FieldDescription

type
string

The main entry point. One of:

  • main

  • minor

functions array

If present, represents the type of access for the POI.
Example: FrontDoor

position
object

Position of the entry point: LatLon

addressRanges object
FieldDescription

rangeLeft
string

An address range on the left side of a street segment (assuming looking from the "from" end toward the "to" end).

rangeRight
string

An address range on the right side of a street segment (assuming looking from the "from" end toward the "to" end).

from
object

The beginning point of a street segment: Latitude, Longitude: LatLon

to
object

An end point of a street segment: Latitude, Longitude LatLon

dataSources object
FieldDescription

geometry
object

Information about the geometric shape of the result. Only present if type == Geography. geometry object

geometry object
FieldDescription

id
string

Pass this as geometryId to the Additional Data service to fetch geometry information for this result.

LatLon float
FieldDescription

lat
float

Latitude. min/max: -90 to +90
Reference: Latitude, Longitude, and Coordinate System Grids

lon
float

Longitude. min/max: -180 to +180
Reference: Latitude, Longitude, and Coordinate System Grids

Response codes

The following table contains response codes signifying successful and failed requests to an API server.

CodeMeaning and 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:

  • Service requires SSL
  • Not authorized
  • Rate or volume limit exceeded
  • Unknown referer
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 table contains response headers sent back from the API server.

HeaderDescription
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: application/json, text/javascript, or text/xml.

Content-Encoding

If requested by the client, the Search service applies gzip compression to the responses with the Accept-Encoding header.
Value: gzip

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 identifier for the request.

Error response

The error response content type depends on the <ext> parameter.

Response content type - JSON
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}
Response content type - XML
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
FieldDescription

errorText
string

A human-readable description of the error.

detailedError
object

Detailed information about the error. detailedError object

httpStatusCode
integer

HTTP response codes signifying failed requests to an API server.

detailedError object
FieldDescription

code
string

One of a server-defined set of error codes.

message
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.

target
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 a query, which should be listed with their abbreviations. Available values are:

  • Geo: Geographies - areas on map which represent administrative division of a land i.e., country, state, city.
  • PAD: Point Addresses - points on map where specific address with street name and number can be found in 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.