Best practices
Request accessWhen to use the Premium Geocoding API?
The TomTom Premium Geocoding API is a forward geocoding service that returns highly accurate address coordinates along with expanded address features required for last-mile delivery, such as the closest parking points, floor numbering, and building entrances (data not provided by standard geocoding). This enables, for example, address verification, route planning, and to-the-door navigation. Premium geocoding therefore guides couriers to the customer’s door for faster and more successful deliveries, compared to the standard geocoded location available in regular geocoding.
The Premium Geocoding API is built for automated systems processing complete, unambiguous postal addresses, or those that are incomplete, not well formatted, or with typos.
It can especially be used at multi-family apartment buildings that require more than just an address placed on the street.
Geocode is popular among following market segments: fleet & logistics, ride hailing, and food delivery.
How to use request parameters to get better results?
The following topics provide some helpful tips to improve your Premium Geocoding API query results.
Note: Constants and parameters enclosed in curly brackets { } must be replaced with their values.
Using unit for detailed addresses
In order to search detailed unit level address you should use the unit parameter. The unit details can also be within the query itself but for better accuracy use the unit parameter separately.
https://api.tomtom.com/search/2/premiumGeocode/3401 S Lamar Blvd, Austin, TX.json?unit=apt 3441&key={Your_API_Key}https://api.tomtom.com/search/2/premiumGeocode/3401 S Lamar Blvd, apt 3441, Austin, TX.json?key={Your_API_Key}Using geo-biasing with a lat/lon pair
In order to geo-bias your results to the relevant area for your user, you should always use a lat/lon pair 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 around the lat/lon:
https://api.tomtom.com/search/2/premiumGeocode/De Ruijterkade 154, 1011 AC, Amsterdam.json?lat=52.3773&lon=4.9084&key={Your_API_Key}Using 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 an item within 1000 meters of the given lat/lon:
https://api.tomtom.com/search/2/premiumGeocode/De Ruijterkade 154, 1011 AC, Amsterdam.json?lat=52.3773&lon=4.9084&radius=1000&key={Your_API_Key}Using idxSet
You can also specify the exact set of indexes to query in the idxSet parameter. For instance if you are only interested:
https://api.tomtom.com/search/2/premiumGeocode/3401 S Lamar Blvd, Austin, TX.json?lat=52.3773&lon=4.9084&idxSet=PAD,Str,Xstr,Geo,Addr&key={Your_API_Key}&unit=apt 3441The idxSet parameter value set of indexes that can be used are:
PAD= Point AddressesStr= StreetsGeo= GeographiesXstr= Cross Streets (intersections)Addr= Address range interpolation (when there is no PAD)
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/search/2/premiumGeocode/3401 S Lamar Blvd, Austin, TX.json?&countrySet=US&key={Your_API_Key}&unit=apt 3441See the TomTom Premium Geocoding API Market Coverage page for a list of all the countries supported by the Geocoding API engine.
Understanding a response
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": "3401 s lamar blvd austin tx", //echo of the query "queryType": "NON_NEAR", "queryTime": 156, //query time on server in milliseconds "numResults": 1, //total number of result in this response "offset": 0, //if limit and offset are being used for paging "totalResults": 1, //total number of hits within the entire database "fuzzyLevel": 1, //range of 2-4 indicating depth of strategies used "content": "premium" //Indicates if premium content returned in any results.
}, "results": [ { "content": "premium", //Indicates if premium content returned in this result. "type": "Point Address", //responses type (see table of types above) "id": "NL/PAD/p0/3802262", //non-stable id for this document (might change in subsequent release) "score": 13.2504415512, "matchConfidence": { "score": 1 //Represents overall textual match score, in the range of [0..1], where 1 means perfect match and 0 - no match. }, "address": { "streetNumber": "3401", "streetName": "South Lamar Boulevard", //The street name. "municipality": "Austin", //City / Town "countrySubdivision": "TX", //State or Province "postalCode": "78704", //Postal Code / Zip Code "extendedPostalCode": "78704-5805", //Extended postal code (availability dependent on region). "countryCode": "US", //A country's code (Note: This is a two-letter code, not a country name.). "country": "United States", //Country name "countryCodeISO3": "USA" //ISO alpha-3 country code "freeformAddress": "3401 South Lamar Boulevard, Austin, TX 78704", //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. "localName": "Austin", //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. "unit": "3441", //The unit number of the address. }, "addressDetails": { "numberOfUnits": 279, //The number of units in the building. "numberOfBuildings": 1, //The number of buildings in the complex. "floorNumber": 4, //The floor number of the address. "hasElevator": true, //Indicates whether the building has an elevator. "hasStair": true, //Indicates whether the building has stairs. "hasParking": true, //Indicates whether the building has parking. "wallHeight": 3 //The height of the wall. }, "position": { "lat": 52.37727, "lon": 4.90943 }, "viewport": { "topLeftPoint": { "lat": 52.37817, "lon": 4.90796 }, "btmRightPoint": { "lat": 52.37637, "lon": 4.9109 } }, "entryPoints": [ { "type": "route", "functions": [ "PARKING" //The function of the entry point, indicating Point to be PARKING ], "pathToNext": "WALKING", //The path to the next entry point, indicating WALKING "position": { "lat": 30.24054777888027, "lon": -97.78596058222561 } }, { "type": "route", "functions": [ "ENTRANCE" //The function of the entry point, indicating Point to be ENTRANCE ], "pathToNext": "WALKING", //The path to the next entry point, indicating WALKING "position": { "lat": 30.240719797674036, "lon": -97.78579765954056 } }, { "type": "route", "functions": [ "ELEVATOR" //The function of the entry point, indicating Point to be ELEVATOR ], "pathToNext": "WALKING", //The path to the next entry point, indicating WALKING "position": { "lat": 30.24062750793042, "lon": -97.78585748105236 } } ] } ]}