GET
Extract Location ID API
Parse TripAdvisor hotel URLs to extract the location ID needed for API calls.
Overview
URL Parser Utility
Extract location IDs from any TripAdvisor hotel URL format. Essential for using location-based endpoints.
The Extract Location ID endpoint is a utility function that parses TripAdvisor URLs and extracts the location ID. This ID is required for many other TripAdvisor API endpoints.
Endpoint URL
GET https://api.stayapi.com/v1/tripadvisor/location/extract-id
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| url | string | Required | Any valid TripAdvisor hotel URL |
Understanding Location IDs
URL Structure
TripAdvisor URLs contain location IDs in this format:
https://www.tripadvisor.com/Hotel_Review-g1224250-d305165-Reviews-Hotel_Name.html
- g1224250 - Geographic location ID (city/region)
- d305165 - Property location ID (specific hotel)
- This API extracts the property ID (the number after "d")
Supported URL Formats
Standard URLs
https://www.tripadvisor.com/Hotel_Review-g1224250-d305165-Reviews-The_Siam.html
With Page Numbers
https://www.tripadvisor.com/Hotel_Review-g1224250-d305165-Reviews-or10-The_Siam.html
Different Domains
https://www.tripadvisor.co.uk/Hotel_Review-g1224250-d305165-Reviews-The_Siam.html
https://www.tripadvisor.de/Hotel_Review-g1224250-d305165-Reviews-The_Siam.html
Mobile URLs
https://m.tripadvisor.com/Hotel_Review-g1224250-d305165-Reviews-The_Siam.html
Common Use Cases
- Preprocessing URLs before calling other TripAdvisor endpoints
- Building URL-to-ID mapping databases
- Validating TripAdvisor URLs in user input
- Extracting IDs from retrieved or collected URLs
- Converting between URL formats and location IDs
Batch Processing
When processing multiple URLs, extract all IDs first, then use the location-based endpoints for better performance.
Request
Response