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

Along Route Search

 

Service version: 2
Last edit: 2019.10.29

On this page

Purpose

The Along Route Search endpoint allows you to perform a fuzzy search for POIs along a specified route.

  • This search is constrained by specifying a detour time-limiting measure.
  • To send the route points you will use a POST request whose body will contain the route parameter in JSON format.
  • The minimum number of route points is 2.

It is possible that the original route will be altered, and some of its points may be skipped.

  • If the route that passes through the found point is faster than the original one, the detour time value is negative.
  • POST requests require the Content-Type header to be set to "application/json".

Example POST body (JSON)

{
  "route": {
    "points": [
      {
        "lat": 37.7524152343544,
        "lon":-122.43576049804686
      },
      {
        "lat": 37.70660472542312,
        "lon":-122.43301391601562
      },
      {
        "lat": 37.712059855877314,
        "lon":-122.36434936523438
      },
      {
        "lat": 37.75350561243041,
        "lon":-122.37396240234374
      }
    ]
  }
}

▲ 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

HTTPS Method: POST

URL format

For ease of viewing and identification:

  • Constants and parameters enclosed in angle brackets (< >) must be replaced with their values.
  • See the following Request parameters section with the Required and Optional parameters tables for these values.
https://<baseURL>/search/<versionNumber>/searchAlongRoute/<query>.<ext>?key=<Your_API_Key>[&limit=<limit>][&categorySet=<categorySet>][&brandSet=<brandSet>][&connectorSet=<connectorSet>][&view=<view>][&detourOffset=<detourOffset>][&sortBy=<sortBy>][&openingHours=<openingHours>][&spreadingMode=<spreadingMode>][&timeZone=<timeZone>][&mapcodes=<mapcodes>]

curl command format

curl -XPOST -H "Content-type: application/json" -d '{
  "route": {
    "points": [
      {
        "lat": 37.7524152343544,
        "lon":-122.43576049804686
      },
      {
        "lat": 37.70660472542312,
        "lon":-122.43301391601562
      },
      {
        "lat": 37.712059855877314,
        "lon":-122.36434936523438
      },
      {
        "lat": 37.75350561243041,
        "lon":-122.37396240234374
      }
    ]
  }
}' 'https://<baseURL>/search/<versionNumber>/searchAlongRoute/<query>.<ext>?key=<Your_API_Key>[&limit=<limit>][&categorySet=<categorySet>][&brandSet=<brandSet>][&connectorSet=<connectorSet>][&view=<view>][&detourOffset=<detourOffset>][&sortBy=<sortBy>][&openingHours=<openingHours>][&spreadingMode=<spreadingMode>][&timeZone=<timeZone>][&mapcodes=<mapcodes>]'

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, which are highlighted with [square brackets], 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
Parameter Description
baseURL
string
The base URL for calling the API.
Value: api.tomtom.com
versionNumber
string
The service version.
Value: The current value is 2.
query
string
The query string. It must be properly URL-encoded.
Value: A properly URL-encoded query string.
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.
maxDetourTime
integer
Maximum detour time.
Maximum value: 3600 seconds.
Optional headers
Header Description
[Accept-Encoding]
string
Enables response compression.
Value: gzip
Tracking-ID
string
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.

Optional parameters
Parameter Description
[limit]
integer
The maximum number of responses that will be returned.
Default value: 10
Maximum value: 20
[categorySet]
string
A comma-separated list of categories which could be used to restrict the result to Points Of Interest of specific categories. The list of categories can be discovered using the POI Categories endpoint.
Value: A comma-separated list of category identifiers (in any order).

  • Item order does not matter.
  • When multiple category identifiers are provided, only POIs that belong to (at least) one of the categories from the provided list will be returned.

Usage examples:

  • categorySet=7315 (search Points Of Interest of category Restaurant)
  • categorySet=7315025,7315017 (search Points Of Interest of category either Italian or French Restaurant)
[brandSet]
string
A comma-separated list of brand names which could be used to restrict the result to Points Of Interest of specific brands.
Value: A comma-separated list of brand names (in any order).

  • Item order does not matter.
  • When multiple brands are provided, only POIs that belong to (at least) one of the brands from the provided list will be returned.
  • Brands that contain a "," in their name should be put into quotes, for example: "A,B,C Comma".

Usage examples:

  • brandSet=Tomtom (search Points Of Interest of ¨Tomtom¨ brand)
  • brandSet=Tomtom,Foobar (search Points Of Interest of ¨Tomtom¨ brand OR ¨Foobar¨ brand)
  • brandSet=¨A,B,C Comma¨ (search Points Of Interest of ¨A,B,C Comma¨ brand)
[connectorSet]
string
A comma-separated list of connector types which could be used to restrict the result to Points Of Interest of type Electric Vehicle Station supporting specific connector types. List of supported connector types
Value: A comma-separated list of connector types (in any order).

  • Item order does not matter.
  • When multiple connector types are provided, only POIs that support (at least) one of the connector types from the provided list will be returned.

Usage examples:

  • connectorSet=IEC62196Type2CableAttached (search Points Of Interest of type Electric Vehicle Station supporting IEC62196Type2CableAttached)
  • connectorSet=IEC62196Type2Outlet,IEC62196Type2CableAttached (search Points Of Interest of type Electric Vehicle Station supporting IEC62196Type2CableAttached or IEC62196Type2Outlet)
[view]
string
Geopolitical view. The context used to resolve handling disputed territories.

  • Views include Unified, along with IN, PK, IL, MA and AR, which are respectively tailored for India, Pakistan, Israel, Morocco, and Argentina.
  • When this parameter is not used, the defaulting behavior will assign the following views. India: IN, Pakistan: PK, Morocco: MA, Argentina: AR, others: Unified.

Default values:

  • 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
[detourOffset]
boolean
Parameter which turns on calculation of the distance between the start of the route and the starting point of the detour to a POI.
Default value: false

  • Detour offset is also calculated when sortBy parameter is set to detourOffset.
  • Value is provided in a response only when detourOffset is set to true.
[sortBy]
string
Parameter which provides possibility to sort returned results.
Default value: detourTime
Values: detourTime, detourDistance, detourOffset

  • Detour distance will be calculated as a difference between the original distance and the distance of a new route with Point Of Interest location.
  • detourDistance field will be present in every response regardless of sorting parameter.
  • If detour offset is set to false detourOffset=false and sorting parameter is set to detourOffset sortBy=detourOffset then detour offset will be calculated and results will be sorted as expected, but detourOffset value will not be present in the response.

Usage examples:

  • sortBy=detourTime (sorts returned results by detour distance)
  • sortBy=detourOffset (sorts returned results by detourOffset)
[openingHours]
string
List of opening hours for a POI (Points of Interest).
Values: nextSevenDays

  • Mode shows the opening hours for next week, starting with the current day in the local time of the POI.

Usage examples:

  • openingHours=nextSevenDays
[spreadingMode]
string
Enables the spreading of returned results evenly along the route.
Values: auto
[mapcodes]

string
Enables the return of a comma-separated mapcodes list. 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 (only returns 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)
[timeZone]
string
Used to indicate the mode in which the timeZone object should be returned.
Values: iana

  • Mode shows the IANA ID which allows the user to determine the current time zone for the POI.

Usage examples:

  • timeZone=iana

▲ 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 fields section for more information.

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

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

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

{
  "type": "POI",
  "id": "US/POI/p0/9033556",
  "score": 4.999,
  "dist": 32.32909635789851,
  "info": "search:ta:840061001865142-US",
  "poi": {
    "name": "Upper Crust Pizza & Pasta",
    "phone": "+(1)-(831)-4762333",
    "url": "www.uppercrustsc.com/",
    "brands": [
      {
        "name": "Upper Crust"
      }
    ],
    "categorySet": [
      {
        "id": 7315015
      }
    ],
    "categories": [
      "pizza",
      "restaurant"
    ],
    "openingHours": {
      "mode": "NEXT_SEVEN_DAYS",
      "timeRanges": [
        {
          "startTime": {
            "date": "2019-02-05",
            "hour": 7,
            "minute": 0
          },
          "endTime": {
            "date": "2019-02-05",
            "hour": 21,
            "minute": 0
          }
        },
        {
          "startTime": {
            "date": "2019-02-06",
            "hour": 7,
            "minute": 0
          },
          "endTime": {
            "date": "2019-02-06",
            "hour": 21,
            "minute": 0
          }
        },
        {
          "startTime": {
            "date": "2019-02-07",
            "hour": 7,
            "minute": 0
          },
          "endTime": {
            "date": "2019-02-07",
            "hour": 21,
            "minute": 0
          }
        },
        {
          "startTime": {
            "date": "2019-02-08",
            "hour": 7,
            "minute": 0
          },
          "endTime": {
            "date": "2019-02-08",
            "hour": 21,
            "minute": 0
          }
        },
        {
          "startTime": {
            "date": "2019-02-09",
            "hour": 7,
            "minute": 0
          },
          "endTime": {
            "date": "2019-02-09",
            "hour": 21,
            "minute": 0
          }
        },
        {
          "startTime": {
            "date": "2019-02-10",
            "hour": 7,
            "minute": 0
          },
          "endTime": {
            "date": "2019-02-10",
            "hour": 12,
            "minute": 0
          }
        },
        {
          "startTime": {
            "date": "2019-02-10",
            "hour": 14,
            "minute": 0
          },
          "endTime": {
            "date": "2019-02-10",
            "hour": 21,
            "minute": 0
          }
        }
      ]
    },
    "classifications": [
      {
        "code": "RESTAURANT",
        "names": [
          {
            "nameLocale": "en-US",
            "name": "pizza"
          },
          {
            "nameLocale": "en-US",
            "name": "restaurant"
          }
        ]
      }
    ],
    "timeZone": {
      "ianaId": "Europe/Andorra"
    }
  },
  "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",
    "localName": "Santa Cruz"
  },
  "position": {
    "lat": 36.98844,
    "lon": -121.97483
  },
  "mapcodes":[
    {
      "type":"Local",
      "fullMapcode":"US-CA FS.WRH3",
      "territory":"US-CA",
      "code":"FS.WRH3"
    },
    {
      "type":"International",
      "fullMapcode":"S4ZW4.990V"
    },
    {
      "type":"Alternative",
      "fullMapcode":"US-CA 4349.S8W",
      "territory":"US-CA",
      "code":"4349.S8W"
    },
    {
      "type":"Alternative",
      "fullMapcode":"US-CA JJCH.H9DF",
      "territory":"US-CA",
      "code":"JJCH.H9DF"
    },
    {
      "type":"Alternative",
      "fullMapcode":"USA JJCH.H9DF",
      "territory":"USA",
      "code":"JJCH.H9DF"
    }
  ],
  "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
      }
    }
  ],
  "detourTime": 113,
  "detourDistance": 211,
  "detourOffset": 156,
  "dataSources": {
    "chargingAvailability": {
      "id": "442009000132285"
    },
    "geometry": {
      "id": "00004e4c-3100-3c00-0000-0000685e23c7"
    }
  }
}

▲ Return to top

Response fields

The following table describes 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
results[]
array
The result list, sorted in descending order by score.
results[] array
summary{} object
Field Description
query
string
The query as interpreted by the search engine.
queryType
string
Response type. Can be NEARBY or NON_NEAR.
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.
results[] array
Field Description
type
string
The type of Result. One of:

  • POI
  • Street
  • Geography
  • Point Address
  • Address Range
  • Cross Street

poi{} object

id
string
The non-stable unique id for this Result.
score
double
The 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. This is the distance to an object if geobias was provided.
info
string
Information about the original data source of the Result.
poi
object
Optional section. Only present if type = = POI.
poi{} object
address
object
Structured address for the Result.
address{} object
position
object
Position of the Result: Latitude,Longitude.
Example: 37.819722,-122.478611
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
entrypoints
array
List of entry points of the POI (Point of Interest).
entryPoints[] array
detourTime
integer
Detour time in seconds.
detourDistance
integer
Detour distance in meters.
detourOffset
integer
Detour offset in meters.
dataSources
object
Optional section. Reference ids for use with the Additional Data service.
dataSources{} object
poi{} object
Field Description
name
string
Name of the POI.
phone
string
Telephone number.
brands
array
The list of POI brands.
brands[] array
url
string
Website URL.
categories
array
Deprecated
The list of POI categories.

  • Use the classifications[] array instead.
  • See the following field.

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.

See: Category Codes

categorySet
array
The list of the most specific POI categories.
categorySet[] array
openingHours
object
List of opening hours for a POI (Points of Interest).
openingHours{} object
classifications
array
The list of POI category classifications.
classifications{} object
timeZone
object
Time zone information for the POI.
timeZone{} object
categorySet[] array
Field Description
id
number
Category id. Full list of available categories is available under POI Categories endpoint.
brands[] array
Field Description
name
string
Brand name.
classifications{} object
Field Description
code
string
Fixed top-level category code. See Category Codes
names
array
List of category names with locale code information. Currently only the en-US locale is returned.
names[] array
names[] array
Field Description
nameLocale
string
The locale code of this category name.
name
string
Category name in the given locale.
address{} object
Field Description
streetNumber
string
The number of the building 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
extendedPostalCode
string
Extended postal code (availability dependent on region)
countryCode
string
Country (Note: This is a two-letter code, not a country name.)
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 case of countries, its full country name.
countrySubdivisionName
string
The full name of the first level of a country's administrative hierarchy.

  • This field appears only in case countrySubdivision is presented in an abbreviated form.
  • Supported only for USA, Canada, and Great Britain.
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
Field Description
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 e.g.,
    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:

  • The 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 always in the Latin alphabet.
This field is not returned for the International mapcodes - use fullMapcode instead.
viewport{} object
Field Description
topLeftPoint
string
Top-left corner of the rectangle: Latitude, Longitude
btmRightPoint
string
Bottom-right corner of the rectangle: Latitude, Longitude
entryPoints[] array
Field Description
type
string
The main entry point. One of:

  • main
  • minor
position
string
Position of the entry point: Latitude,Longitude
Example: 37.819722,-122.478611
dataSources{} object
Field Description
chargingAvailability
object
Information about the charging stations availability. Only present if type == POI.
geometry
object
Information about the geometric shape of the result. Only present if type == Geography or POI.
chargingAvailability{} object
Field Description
id
string
Pass this as chargingAvailability to the EV Charging Stations Availability service to fetch charging availability information for this result.
geometry{} object
Field Description
id
string
Pass this as geometryId to the Additional Data service to fetch geometry information for this result.
openingHours{} object
Field Description
mode
string
Mode used in the Request.
timeRanges
array
List of time ranges for the next 7 days.
timeRanges[] array
timeRanges[] array
startTime
object
The point in the next 7 days range when a given POI is being opened.
(or the beginning of the range if it was opened before the range)
inclusive
startTime{} object
endTime
object
The point in the next 7 days range when a given POI is being opened.
(or the beginning of the range if it was opened before the range)
exclusive
endTime{} object
startTime{} object, endTime{} object
date
string
Represents current day in calendar year in POI time zone.
hour
integer
Hours are in the 24 hour format in the local time of a POI; possible values are 0 - 23.
minute
integer
Minutes are in the local time of a POI; possible values are 0 - 59.
timeZone{} object
ianaId
string
ID from the IANA Time Zone Database.

▲ Return to top

HTTP Response codes

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 server 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 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
  • 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.

▲ Return to top

Error Response

The error Response content type depends on the ext parameter.

Error Response example (JSON)

{
  "errorText":"Error parsing 'language': Language tag 'en-ES' not supported",
  "detailedError":{
    "code":"BadRequest",
    "message":"Error parsing 'language': Language tag 'en-ES' not supported",
    "target":"language"
    },
  "httpStatusCode":"400"
}

Error Response example (XML)

<?xml version="1.0" encoding="UTF-8"?>
<response>
  <errorText>Error parsing 'language': Language tag 'en-ES' not supported</errorText>
  <detailedError>
    <code>BadRequest</code>
    <message>Error parsing 'language': Language tag 'en-ES' not supported</message>
    <target>language</target>
  </detailedError>
  <httpStatusCode>400</httpStatusCode>
</response>

▲ Return to top

Error Response fields

Primary fields
Field Description
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
Field Description
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.
Values:

  • The name of the Request parameter causing error.

▲ Return to top

You are here