Best practices
Public Preview Notice
Purpose
The following topics provide some helpful tips to improve your Search API query results.
Note: Constants and parameters enclosed in curly brackets { } must be replaced with their values.
Using geobias
In order to geo-bias your results to the relevant area for your user, you should always use a geobias parameter to help bias the results to the user’s location. Note, this is a non-restrictive bias, but for very common searches it will find the instances nearby.
This query will find places with pizza biased to the point lat,lon:
https://api.tomtom.com/maps/orbis/places/search/pizza.json?key={Your_API_Key}&apiVersion=1&geobias=point:37.8085,-122.4239This query will find places with pizza biased to the rectangle topLeftLat,topLeftLon,btmRightLat,btmRightLon:
https://api.tomtom.com/maps/orbis/places/search/pizza.json?key={Your_API_Key}&apiVersion=1&geobias=rectangle:37.8085,-122.4239,34.8085,-121.4239Using radius
If geo-biasing is not strong enough for keeping your results local to the user, you can also pass in a radius (in meters) to restrict the result to a given area. For instance, this query will only find pizza within 1000 meters of the given point lat/lon:
https://api.tomtom.com/maps/orbis/places/search/pizza.json?key={Your_API_Key}&apiVersion=1&geobias=point:37.8085,-122.4239&radius=1000Using idxSet
You can also specify the exact set of indexes to query in the idxSet parameter. For instance:
https://api.tomtom.com/maps/orbis/places/search/pizza.json?key={Your_API_Key}&apiVersion=1&geobias=point:37.8085,-122.4239&idxSet=POI,PAD,Str,Xstr,Geo,Addr,EPPThe idxSet parameter value set of indexes that can be used are:
POI= Points of interestPAD= Point AddressesStr= StreetsGeo= GeographiesXstr= Cross Streets (intersections)Addr= Address range interpolation (when there is no PAD)EPP= Extended Postal Codes (for the most accurate postal code search experience, especially relevant for countries like the UK and Ireland. If EPP is not used (by default), detailed postal code queries will be matched to Street results.)
Note: If you are using more than one index, do not include any spaces between them in the comma-separated string.
Using a subset of countries
You can also specify a subset of the countries on the server by adding a comma-separated list of countries in the form:
https://api.tomtom.com/maps/orbis/places/search/pizza.json?key={Your_API_Key}&apiVersion=1&countrySet=HR,CY,CZ,DK(search for pizza in Croatia, Cyprus, Czech Republic, and Denmark)
See the TomTom Search API Market Coverage page for a list of all the countries supported by the Search API engine.
Using different response formats
We also support JSON or XML formatted responses.
https://api.tomtom.com/maps/orbis/places/search/pizza.json?key={Your_API_Key}&apiVersion=1&geobias=point:37.8085,-122.4239https://api.tomtom.com/maps/orbis/places/search/pizza.xml?key={Your_API_Key}&apiVersion=1&geobias=point:37.8085,-122.4239Using pure Category Search
Finally, if you are interested in pure category search we have a special endpoint: Category Search . The following query will produce a category search for important tourist attractions:
https://api.tomtom.com/maps/orbis/places/search/categorySearch/important tourist monument.json?key={Your_API_Key}&geobias=point:37.8085,-122.4239Understanding a response summary
The following example uses JSON. Note: For your benefit, the code comments are preceded by // and are not part of the actual JSON.
{ "summary": { "query": "TomTom", // echo of the query "queryTime": 38, // query time on server in milliseconds "numResults": 10, // total number of result in this response "totalResults": 51, // total number of hits within the entire database // to find matches, e.g. 1 means more accurate and 4 means less }, "results": [ { "type": "POI", // responses type (see table of types above) "id": 50422, // non-stable id for this document (might change in subsequent release) "score": 4, // score of this document relative to other scores in same response "poi": { ...