tools.tools.toolkits.trip_advisor_toolkit

TripAdvisor Toolkit.

This module provides tools to interact with the TripAdvisor Content API. It allows querying for location details, photos, reviews, and searching for locations by various criteria.

Requires a TripAdvisor API key set as TRIPADVISOR_API_KEY in environment variables or .env file.

Attributes

Classes

LocationDetailsInput

Input parameters for retrieving location details.

LocationPhotosInput

Input parameters for retrieving location photos.

LocationReviewsInput

Input parameters for retrieving location reviews.

LocationSearchInput

Input parameters for searching locations.

NearbySearchInput

Input parameters for searching nearby locations.

Functions

get_location_details(location_id[, language, currency])

Get details about a location by ID.

get_location_photos(location_id[, language, limit, ...])

Get high-quality photos for a location.

get_location_reviews(location_id[, language, limit, ...])

Get recent reviews for a location.

nearby_search(**kwargs)

Search for nearby locations using a lat/long pair.

search_locations(**kwargs)

Search for TripAdvisor locations by name, address, lat/long, etc.

tripadvisor_get(endpoint, params)

Make a GET request to the TripAdvisor API.

Module Contents

class tools.tools.toolkits.trip_advisor_toolkit.LocationDetailsInput(/, **data: Any)

Bases: pydantic.BaseModel

Input parameters for retrieving location details.

currency: str | None = None
language: str | None = None
location_id: int = None
class tools.tools.toolkits.trip_advisor_toolkit.LocationPhotosInput(/, **data: Any)

Bases: pydantic.BaseModel

Input parameters for retrieving location photos.

language: str | None = None
limit: int | None = None
location_id: int = None
offset: int | None = None
source: str | None = None
class tools.tools.toolkits.trip_advisor_toolkit.LocationReviewsInput(/, **data: Any)

Bases: pydantic.BaseModel

Input parameters for retrieving location reviews.

language: str | None = None
limit: int | None = None
location_id: int = None
offset: int | None = None
class tools.tools.toolkits.trip_advisor_toolkit.LocationSearchInput(/, **data: Any)

Bases: pydantic.BaseModel

Input parameters for searching locations.

address: str | None = None
category: str | None = None
language: str | None = None
lat_long: str | None = None
phone: str | None = None
radius: int | None = None
radius_unit: str | None = None
search_query: str = None
class tools.tools.toolkits.trip_advisor_toolkit.NearbySearchInput(/, **data: Any)

Bases: pydantic.BaseModel

Input parameters for searching nearby locations.

address: str | None = None
category: str | None = None
language: str | None = None
lat_long: str = None
phone: str | None = None
radius: int | None = None
radius_unit: str | None = None
tools.tools.toolkits.trip_advisor_toolkit.get_location_details(location_id: int, language: str = 'en', currency: str = 'USD')

Get details about a location by ID.

Retrieves comprehensive information about a specific TripAdvisor location such as a hotel, restaurant, or attraction.

Parameters:
  • location_id – The unique identifier for a TripAdvisor location.

  • language – The language code for the response content (ISO 639-1).

  • currency – The currency code for price values (ISO 4217).

Returns:

Location details including name, address, rating, etc.

Return type:

dict

tools.tools.toolkits.trip_advisor_toolkit.get_location_photos(location_id: int, language: str = 'en', limit: int = 5, offset: int = 0, source: str | None = None)

Get high-quality photos for a location.

Retrieves photos from TripAdvisor for a specific location.

Parameters:
  • location_id – The unique identifier for a TripAdvisor location.

  • language – The language code for the response content (ISO 639-1).

  • limit – Maximum number of photos to return (1-100).

  • offset – Number of photos to skip for pagination.

  • source – Filter photos by source (tripadvisor, management).

Returns:

Collection of photo objects with URLs and metadata.

Return type:

dict

tools.tools.toolkits.trip_advisor_toolkit.get_location_reviews(location_id: int, language: str = 'en', limit: int = 5, offset: int = 0)

Get recent reviews for a location.

Retrieves user reviews for a specific TripAdvisor location.

Parameters:
  • location_id – The unique identifier for a TripAdvisor location.

  • language – The language code for the response content (ISO 639-1).

  • limit – Maximum number of reviews to return (1-50).

  • offset – Number of reviews to skip for pagination.

Returns:

Collection of review objects with ratings, text, and metadata.

Return type:

dict

Search for nearby locations using a lat/long pair.

Finds TripAdvisor locations near a specific geographical point.

Parameters:

**kwargs – Key arguments matching the NearbySearchInput model. latLong: Latitude,longitude pair (e.g., ‘42.3455,-71.0983’). category: Filter by category (hotels, attractions, restaurants). phone: Filter by phone number. address: Filter by street address. radius: Search radius from the specified coordinates. radius_unit: Unit for radius (km, mi, m). language: The language code for the response content (ISO 639-1).

Returns:

Search results with nearby location data.

Return type:

dict

tools.tools.toolkits.trip_advisor_toolkit.search_locations(**kwargs)

Search for TripAdvisor locations by name, address, lat/long, etc.

Performs a general search for TripAdvisor locations using various filters.

Parameters:

**kwargs – Key arguments matching the LocationSearchInput model. searchQuery: Text to search for (e.g., hotel name, restaurant name). category: Filter by category (hotels, attractions, restaurants). phone: Search by phone number. address: Search by street address. latLong: Latitude,longitude pair (e.g., ‘42.3455,-71.0983’). radius: Search radius from the specified coordinates. radius_unit: Unit for radius (km, mi, m). language: The language code for the response content (ISO 639-1).

Returns:

Search results with location data.

Return type:

dict

tools.tools.toolkits.trip_advisor_toolkit.tripadvisor_get(endpoint: str, params: dict)

Make a GET request to the TripAdvisor API.

Parameters:
  • endpoint – The API endpoint to call.

  • params – Query parameters for the request.

Returns:

JSON response from the API.

Return type:

dict

Raises:

requests.HTTPError – If the request fails.

tools.tools.toolkits.trip_advisor_toolkit.BASE_URL = 'https://api.content.tripadvisor.com/api/v1'
tools.tools.toolkits.trip_advisor_toolkit.TRIPADVISOR_API_KEY