/location-mapper

The /location_mapper call allows for searching for a Tripadvisor id using lat long +  the name of the property. Once the Tripadvisor ID is found, you can call /location to get  the business details.  

Access to this call is dependent on the partner's ID matching strategy.   Many partners send spreadsheet files to Tripadvisor in order to map their property IDs. Contact your Acccount Manager with any questions.

 
There are 2 possible ways for searching the Tripadvisor ID using API /location_mapper

1 - using latitude and longitude (as required fields) + property name (optional) with parameter "q"



The result of the API request will be - all locations found using Geo Rectangle (ie built from a Geo Center Point in latitude and longitude, than calculates the distance from the center point, sorts by this distance and takes the first 10 nearest places).

Request

http://api.tripadvisor.com/api/partner/2.0/location_mapper/42.344978,-71.119030?key=<CONTENT API KEY HERE>-mapper&category=hotels&q=Beacon%20Townhouse%20Inn%201023

Options

Name Description
category Filters result set based on property type. Valid options are: "hotels", "attractions", and "restaurants". The value for this parameter can be specified through a comma. Example "&category=hotels,restaurants". 
q Query string for narrowing searches. Recommended to use property name.
lang The desired language locale (ex: &lang=de).
distance This is radius used to create Geo Rectangle from point (parameters "latitude" and "longitude" from the URL). The default value is 1.00 (miles) and cannot be more than 25. You can type in the URL this value bigger then 25 but in the code it will be restricted to 25.0 miles
fields Parameter to specify a comma-separated list of place data types to return from the location endpoint (additional fields to the main fields).  Valid options are: "phone" ," rating", "coordinates". The value for this parameter can be specified through a comma. Example "&fields=phone,rating,coordinates"

 


2 - using property name (as required field) with parameter "q" (without mandatory use of latitude and longitude)


The result of the API will be - 10 locations found by matching names.You can also use longitude and latitude to search more accuracy (parameter "location". Example: "&location=42.3455,-71.10767")

 

Request

https://api.tripadvisor.com/api/partner/2.0/location_mapper?key=<CONTENT API KEY HERE>-mapper&category=hotels&q=Beacon%20Townhouse%20Inn%201023&location=42.3455,-71.10767

Options

Name Description
category Filters result set based on property type. Valid options are: "hotels", "attractions", and "restaurants". The value for this parameter can be specified through a comma. Example "&category=hotels,restaurants". 
q REQUIRED. Search by property name.
location The lat/long geo coordinates (&location=42.3455,-71.10767)
lang The desired language locale (ex: &lang=de).
distance This is radius used to create Geo Rectangle from point (parameters "latitude" and "longitude" from the URL). The default value is 1.00 (miles) and cannot be more than 25. You can type in the URL this value bigger then 25 but in the code it will be restricted to 25.0 miles
fields Parameter to specify a comma-separated list of place data types to return from the location endpoint (additional fields to the main fields).  Valid options are: "phone" ," rating", "coordinates". The value for this parameter can be specified through a comma. Example "&fields=phone,rating,coordinates"


Response

{
  "data": [
    {
      "location_id": "258730",
      "name": "Beacon Townhouse Inn 1023",
      "distance": "0.5806475395682301",
      "bearing": "east",
      "address_obj": {
        "street1": "1023 Beacon Street",
        "street2": "",
        "city": "Brookline",
        "state": "Massachusetts",
        "country": "United States",
        "postalcode": "02446",
        "address_string": "1023 Beacon Street, Brookline, MA 02446"
      }
    }
  ]
}
With parameter "fields" (&fields=phone,rating,coordinates)

{ "data": [ { "location_id": "258730", "name": "Beacon Townhouse Inn 1023", "distance": "0.5818983609909812", "bearing": "east", "rating": "3.0", "address_obj": { "street1": "1023 Beacon St", "street2": "", "city": "Brookline", "state": "Massachusetts", "country": "United States", "postalcode": "02446-5609", "phone": "+1 617-232-2422", "latitude": "42.3455", "longitude": "-71.10767", "address_string": "1023 Beacon St, Brookline, MA 02446-5609" } } ] }
 

Properties

Name Description
location_id The Tripadvisor Location ID - to use in any /location API calls.
name Property name.
address_obj Object consisting of various address data.
distance Distance, in miles, this location is from the passed in Lat/Long parameters.
bearing

Direction this location is from the passed in Lat/Long parameters.

 

Filters

In both cases, the results can be filtered by:

address By adding the "address" parameter to the URL. Example: "&address=1023%20Beacon%20St"
phone By adding the "phone" parameter to the URL. Example: &phone=1%20617-232-2422,  &phone=16172322422. You can search in any phone format (with spaces, dashes, but without the "+" sign at the beginning)

 

Example where the required fields are longitude and latitude:
https://api.tripadvisor.com/api/partner/2.0/location_mapper/42.344978,-71.119030?key=<CONTENT API KEY HERE>-mapper&category=hotels&address=1023%20Beacon%20St

An example where the required field is the location name (parameter "q"):
https://api.tripadvisor.com/api/partner/2.0/location_mapper?key=<CONTENT API KEY HERE>-mapper&category=hotels&q=Beacon%20Townhouse%20Inn%201023&address=1023%20Beacon%20St
 

Recommended Practices

Best results may come from using the category parameter (e.g. "hotels") and passing exact property name into the query parameter. Additionally, the API call does not include any auto-correction, so if you are having trouble getting the correct property returned, be sure to check spelling.

If using for mapping purposes, It is recommended that users review all matched Tripadvisor Location IDs with their own list of propery IDs, and store them in a database once confirmed. This allows the user to access a list of confirmed Location IDs instead of relying on the accuracy of the /location_mapper call, which may not always return the desired result, before making a /location call. If you are unable to obtain certain Location IDs using the /location_mapper call, you can also manually check the property's Tripadvisor URL - the Location ID is the number located immediately following the letter "d" in the URL:

http://www.tripadvisor.com/Hotel_Review-g60745-d258705-Reviews-Hotel_Commonwealth-Boston_Massachusetts.html