Sorry, you need to enable JavaScript to visit this website.

Geometry Search

 

Service version: 2.0
Last edit: 2019.02.01

On this page

Purpose

The Geometry Search endpoint allows you to perform a free form search inside a single geometry or many of them.

  • The search results that fall inside the geometry/geometries will be returned.
  • To send the geometry you will use a POST or GET request with the JSON as a string value for the geometryList parameter.
  • POST is recommended for large datasets.
  • POST requests require the "Content-Type" header to be set to "application/json".
Option 1. Using a GET Request (for smaller geometry datasets)
Retreive the data from the API database using a HTTPS GET Request with the geometryList parameter value set as an array. This method is recommended for smaller datasets.
?geometryList=[
  {
    "type":"POLYGON","vertices":[
      "37.7524152343544,-122.43576049804686",
      "37.70660472542312,-122.43301391601562",
      "37.712059855877314,-122.36434936523438",
      "37.75350561243041,-122.37396240234374"
    ]
  },
  {
    "type":"CIRCLE","position":"37.71205,-121.36434","radius":6000
  },
  {
    "type":"CIRCLE","position":"37.31205,-121.36434","radius":1000
  }
]
Option 2. Using a POST Request (for larger geometry datasets)
Submit the data as a JSON file to the API database using a HTTP POST Request.
{
  "geometryList":[
    {
      "type":"POLYGON",
      "vertices":[
        "37.7524152343544,-122.43576049804686",
        "37.70660472542312,-122.43301391601562",
        "37.712059855877314,-122.36434936523438",
        "37.75350561243041,-122.37396240234374"
      ]
    },
    {
      "type":"CIRCLE",
      "position":"37.71205,-121.36434",
      "radius":6000
    },
    {
      "type":"CIRCLE",
      "position":"37.31205,-121.36434",
      "radius":1000
    }
  ]
}

▲ Return to top

Run this endpoint

You can easily run this and other endpoints.

  1. Go to the TomTom API Explorer page.
  2. Click an endpoint.
    1. Click Try it out.
    2. Enter/select all required parameter values and any optional parameter values.
    3. At the bottom of the form, click Execute.
  3. Review the Response.

Request data

Request formats

HTTPS Method: GET

URL format

For identification purposes:

  • Required constants and parameters are shown in bold text.
  • Optional parameters are shown in plain text.
https://api.tomtom.com/search/2/geometrySearch/pizza.json?key=*****&geometryList=%5B%7B%22type%22%3A%22POLYGON%22%2C%20% 22vertices%22%3A%5B%2237.7524152343544%2C%20-122.43576049804686%22%2C%20%2237.70660472542312%2C%20-122.43301391601562%22%2C%20%2237.712059855877314%2C%20-122.36434936523438%22%2C%20%2237.75350561243041%2C%20-122.37396240234374%22%5D%7D%2C%20%7B%22type%22%3A% 22CIRCLE%22%2C%20%22position%22%3A%2237.71205%2C%20-121.36434%22%2C%20%22radius%22%3A6000%7D%2C%20%7B%22type%22%3A% 22CIRCLE%22%2C%20%22position%22%3A%2237.31205%2C%20-121.36434%22%2C%20%22radius%22%3A1000%7D%5D&limit=10&language=en-us&extendedPostalCodesFor=POI&idxSet=POI

curl command

curl -X GET "https://api.tomtom.com/search/2/geometrySearch/pizza.json?&key=*****"
  geometryList=%5B%7B%22type%22%3A%22POLYGON%22%2C%20%22vertices%22%3A%5B%2237.7524152343544%2C%20-122.43576049804686%22%2C%20%2237.70660472542312%2C%20-122.43301391601562%22%2C%20%2237.712059855877314%2C%20-122.36434936523438%22%2C%20%2237.75350561243041%2C%20-122.37396240234374%22%5D%7D%2C%20%7B%22type%22%3A%22CIRCLE%22%2C%20%22position%22%3A%2237.71205%2C%20-121.36434%22%2C%20%22radius%22%3A6000%7D%2C%20%7B%22type%22%3A%22CIRCLE%22%2C%20%22position%22%3A%2237.31205%2C%20-121.36434%22%2C%20%22radius%22%3A1000%7D%5D
  &limit=10
  &language=en-us
  &extendedPostalCodesFor=POI
  &idxSet=POI
-H "accept: */*"

HTTPS Method: POST

URL format

For identification purposes:

  • Required constants and parameters are shown in bold text.
  • Optional parameters are shown in plain text.
https://api.tomtom.com/search/2/geometrySearch/pizza.json?key=*****&limit=10&language=en-us&extendedPostalCodesFor=POI&idxSet=POI

curl command

curl -v -XPOST -H "Content-type: application/json" -d '{
  "geometryList":[
    {
      "type":"POLYGON",
      "vertices":[
        "37.7524152343544,-122.43576049804686",
        "37.70660472542312,-122.43301391601562",
        "37.712059855877314,-122.36434936523438",
        "37.75350561243041,-122.37396240234374"
      ]
    },
    {
      "type":"CIRCLE",
      "position":"37.71205,-121.36434",
      "radius":6000
    },
    {
      "type":"CIRCLE",
      "position":"37.31205,-121.36434",
      "radius":1000
    }
  ]
}' 'https://api.tomtom.com/search/2/geometrySearch/pizza.json?key=*****&limit=10&language=en-us&extendedPostalCodesFor=POI&idxSet=POI'

▲ Return to top

Request parameters

The following data 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.
  • A parameter's data type is shown under its name.
  • 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
Parameter Description
baseURL
string
Base URL for calling the API.
Value: api.tomtom.com
versionNumber
integer
Service version number.
Value: The current value is 2.
query
string
Query string. Must be properly URL encoded.
Value: A properly URL encoded query string.
ext
string
Valid response formats. Values: JSON, JSONP, JS, or XML
key
string
An API Key valid for the requested service.
Value: Your valid API Key.
Optional parameters
Parameter Description
geometryList
object
List of geometries to search in (JSON).

  • Available types are POLYGON and CIRCLE.
  • The format is as in the example above.
  • The circle radius unit is in meters.
  • The list (array) can contain up to 50 geometries, each consisting of up to 50 vertices.

Value: A list of geometries.

limit
integer
The maximum number of responses that will be returned.
Default value: 10
Maximum value: 100
language
string
Language in which search results should be returned.

  • Should be one of supported IETF language tags, case insensitive.
  • When data in specified language is not available for a specific field, default langauge is used.

Value: A supported IETF language tag.

extendedPostalCodesFor
string
Indexes for which extended postal codes should be included in the results.

  • Available values are described in additional information indexes abbreviation values section.
  • 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.

Usage examples:

  • extendedPostalCodesFor=POI
  • extendedPostalCodesFor=PAD,Addr,POI
  • extendedPostalCodesFor=None

Extended postal code is returned as an extendedPostalCode property of an address. Availability is region-dependent.
Value: A comma-separated list of index types.

idxSet
string
The idxSet parameter allows for fine tuning Search by specifying which indexes to utilize for the search. The pre-defined indexes are:

  • Addr = Address range interpolation (when there is no PAD)
  • Geo = Geographies
  • PAD = Point Addresses
  • POI = Points of Interest
  • Str = Streets
  • XStr = Cross Streets (intersections)

Usage examples:

  • idxSet=POI (search Points Of Interest only)
  • idxSet=PAD,Addr (search addresses only)

Values: See the preceding list of pre-defined indexes.

▲ Return to top

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 field documentation for more information.

When requesting JSON output, the Response has the following structure:

{
    "summary": {
        "query": "pizza",
        "queryType": "NON_NEAR",
        "queryTime": 82,
        "numResults": 10,
        "offset": 0,
        "totalResults": 479,
        "fuzzyLevel": 1
    },
    "results": []
}

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

{
    "type": "POI",
    "id": "US/POI/p0/9033556",
    "score": 4,
    "info": "search:ta:840061001865142-US",
    "entityType": "Municipality",
    "poi": {
        "name": "Upper Crust Pizza & Pasta",
        "phone": "+(1)-(831)-4762333",
        "url": "www.uppercrustsc.com/",
        "categories": [
            "pizza",
            "restaurant"
        ],
        "classifications": [
            {
                "code": "RESTAURANT",
                "names": [
                    {
                        "nameLocale": "en-US",
                        "name": "pizza"
                    },
                    {
                        "nameLocale": "en-US",
                        "name": "restaurant"
                    }
                ]
            }
        ]
    },
    "address": {
        "streetNumber": "2501",
        "streetName": "Soquel Dr",
        "municipalitySubdivision": "Santa Cruz, Live Oak",
        "municipality": "Santa Cruz, Live Oak",
        "countrySecondarySubdivision": "Santa Cruz",
        "countryTertiarySubdivision": "Santa Cruz",
        "countrySubdivision": "CA",
        "postalCode": "95065",
        "extendedPostalCode": "950652023",
        "countryCode": "US",
        "country": "United States Of America",
        "countryCodeISO3": "USA",
        "freeformAddress": "2501 Soquel Dr, Santa Cruz, CA 95065",
        "countrySubdivisionName": "California"
    },
    "position": {
        "lat": 36.98844,
        "lon": -121.97483
    },
    "viewport": {
        "topLeftPoint": {
            "lat": 36.98934,
            "lon": -121.97596
        },
        "btmRightPoint": {
            "lat": 36.98754,
            "lon": -121.9737
        }
    },
    "entryPoints": [
        {
            "type": "main",
            "position": {
                "lat": 36.98817,
                "lon": -121.97487
            }
        }
    ],
    "addressRanges": {
        "rangeLeft": "1 - 3",
        "rangeRight": "2 - 12",
        "from": {
            "lat": 51.16561,
            "lon": 19.48489
        },
        "to": {
            "lat": 51.16545,
            "lon": 19.4863
        }
    },
    "dataSources": {
        "chargingAvailability": {
            "id": "442009000132285"
        },
        "geometry": {
            "id": "00004e4c-3100-3c00-0000-0000685e23c7"
        }
    }
}

▲ Return to top

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.
results[]
array
Result list, sorted in descending order by score.
summary{} object
Field Description
query
string
Query as interpreted by the search engine.
queryType
string
Response type. See the following response types.
queryTime
integer
Time spent on resolving the query.
numResults
integer
Number of Results in the response.
offset
integer
Starting offset of the returned Results within the full Result set.
totalResults
integer
Total number of Results found.
fuzzyLevel
integer
Maximum fuzzy level required to provide Results.
results[] array
Field Description
type
string (POI)
Type of Result. One of:

  • POI
  • Street
  • Geography
  • Point Address
  • Address Range
  • Cross Street
id
string
Non-stable id for this Result.
score
double
Score of the Result. A larger score means there is a probability that a Result meeting the query criteria is higher.
dist
double
Unit: meters
info
string
Information about the original data source of the Result.
entityType
string
Optional section.
Only present if type = = Geography. One of:

  • Country
  • CountrySubdivision
  • CountrySecondarySubdivision
  • CountryTertiarySubdivision
  • Municipality
  • MunicipalitySubdivision
  • Neighbourhood
  • PostalCodeArea
poi
object
Optional section. Only present if type = = POI.
address
object
Structured address for the Result.
position
object
Position of the Result: Latitude, Longitude
viewport
object
A viewport which can be used to display the Result on a map.
entrypoints
array
List of entry points of the POI.
dataSources
object
Optional section. Reference ids for use with the Additional Data service.
poi{} object
Field Description
name
string
Name of the POI.
phone
string
Telephone number.
url
string
Website URL.
categories
array
The list of POI categories.
Deprecated Use classifications instead.
May 1, 2018:

  • The categories response field has been deprecated.
  • It will be withdrawn following a 12 month deprecation period.
  • The planned withdrawal date is May 1, 2019.
classifications
array
The list of POI category classifications.
classifications[] array
Field Description
code
string
Fixed top-level category code.
names
array
List of category names with locale code information. Currently only the en-US locale is returned.
names[] array
Field Description
nameLocale
string
Locale code of this category name.
name
string
Category name in given locale.
address{} object
Field Description
streetNumber
string
The building number on the street.
streetName
string
The street name.
municipalitySubdivision
string
Sub / Super City
municipality
string
City / Town
countrySecondarySubdivision
string
Country
countryTertiarySubdivision
string
Named Area
countrySubdivision
string
State or Province
postalCode
string
Postal Code / Zip Code
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 formatting rules of a result's country of origin, or
  • In the case of countries, its full country name.
countrySubdivisionName
string
A full name of a first level of country administrative hierarchy.

  • This field appears only in case countrySubdivision is presented in an abbreviated form.
  • Supported only for USA, Canada, and Great Britain.
viewport{} object
Field Description
topLeftPoint
string
Top left corner of the rectangle:
LatLon
btmRightPoint
string
Bottom right corner of the rectangle:
LatLon
entryPoints[] array
Field Description
type
string
Main entry point. One of:

  • main
  • minor
position
string
Position of the entry point: Latitude, Longitude
addressRanges{} object
Field Description
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
string
A beginning point of a street segment: Latitude, Longitude
to
string
An end point of a street segment: Latitude, Longitude
dataSources{} object
Field Description
geometry
object
Information about the geometric shape of the result. Only present if type == Geography or POI.
charging availability
object
Information about the charging stations availability.
Only present if type == POI. Charging Availability
geometry{} object
Field Description
id
String
Pass this as geometryId to the Additional Data service to fetch geometry information for this result.
charging availability{} object
Field Description
id
string
Pass this as chargingAvailabilityId to the Additional Data service
to fetch charging availability information for this result.
lat/lon
Field Description
lat
double
Latitude.
lon
double
Longitude.

▲ Return to top

HTTP Response codes

The following 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:

  • 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.
5xx Server Error: The service was unable to process your Request. Contact support to resolve the issue.

▲ Return to top

Response headers

The following table contains Response headers sent back from an API server.

Header Description
Access-Control-Allow-Origin Ensures that clients that implement the CORS security model are able to access the response from this service.
Value: *
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
  • text/xml

▲ Return to Top