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¶
Input parameters for retrieving location details. |
|
Input parameters for retrieving location photos. |
|
Input parameters for retrieving location reviews. |
|
Input parameters for searching locations. |
|
Input parameters for searching nearby locations. |
Functions¶
|
Get details about a location by ID. |
|
Get high-quality photos for a location. |
|
Get recent reviews for a location. |
|
Search for nearby locations using a lat/long pair. |
|
Search for TripAdvisor locations by name, address, lat/long, etc. |
|
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.
- class tools.tools.toolkits.trip_advisor_toolkit.LocationPhotosInput(/, **data: Any)¶
Bases:
pydantic.BaseModel
Input parameters for retrieving location photos.
- class tools.tools.toolkits.trip_advisor_toolkit.LocationReviewsInput(/, **data: Any)¶
Bases:
pydantic.BaseModel
Input parameters for retrieving location reviews.
- class tools.tools.toolkits.trip_advisor_toolkit.LocationSearchInput(/, **data: Any)¶
Bases:
pydantic.BaseModel
Input parameters for searching locations.
- class tools.tools.toolkits.trip_advisor_toolkit.NearbySearchInput(/, **data: Any)¶
Bases:
pydantic.BaseModel
Input parameters for searching nearby locations.
- 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:
- 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:
- 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:
- tools.tools.toolkits.trip_advisor_toolkit.nearby_search(**kwargs)¶
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:
- 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:
- 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:
- 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¶