Catalog
The catalog endpoint allows you to download the complete hotel inventory from TripEdge. This is useful for building local databases, search indexes, or pre-caching hotel data for faster availability searches.
The catalog response model
CatalogResponse
- Name
data- Type
- array of CatalogHotel
- Description
Array of hotels for the current page.
- Name
success- Type
- boolean
- Description
Whether the request was successful.
- Name
message- Type
- string
- Description
Error message if unsuccessful, null otherwise.
CatalogHotel object
- Name
id- Type
- integer
- Description
Unique hotel identifier. Use this ID for availability and hotel detail requests.
- Name
name- Type
- string
- Description
Hotel name.
- Name
stars- Type
- number
- Description
Star rating (1.0-5.0).
- Name
rating- Type
- integer
- Description
Guest rating score.
- Name
review_count- Type
- integer
- Description
Number of guest reviews.
- Name
coordinates- Type
- Coordinates
- Description
Geographic coordinates.
- Name
address- Type
- HotelAddress
- Description
Hotel address details.
- Name
images- Type
- array of strings
- Description
Array of image URLs.
- Name
amenities- Type
- array of HotelAmenity
- Description
List of hotel amenities.
- Name
type- Type
- string
- Description
Property type (e.g., "hotel", "resort", "apartment").
Coordinates object
- Name
lat- Type
- number
- Description
Latitude.
- Name
lng- Type
- number
- Description
Longitude.
HotelAddress object
- Name
address- Type
- string
- Description
Street address.
- Name
city- Type
- string
- Description
City name.
- Name
country- Type
- string
- Description
Country code or name.
- Name
postal_code- Type
- string
- Description
Postal/ZIP code.
- Name
region- Type
- string
- Description
State/province/region.
Download catalog
Downloads a paginated list of all hotels in the TripEdge catalog. Iterate through pages until an empty data array is returned.
Request body
- Name
page- Type
- integer
- Description
The page number to retrieve (1-indexed). Start with page 1 and increment until no more results are returned.
Request
curl --location 'https://api.tripedge.com/data/hotels' \
--header 'Authorization: {your_api_key}' \
--header 'Content-Type: application/json' \
--data '{
"page": 1
}'
Response
{
"data": [
{
"id": 1234,
"name": "Grand Hotel New York",
"stars": 5.0,
"rating": 45,
"review_count": 1200,
"coordinates": {
"lat": 40.7128,
"lng": -74.0060
},
"address": {
"address": "123 Main Street",
"city": "New York",
"country": "US",
"postal_code": "10001",
"region": "NY"
},
"images": [
"https://images.tripedge.com/hotels/1234/main.jpg"
],
"amenities": ["pool", "spa", "wifi", "gym"],
"type": "hotel"
},
{
"id": 1235,
"name": "Seaside Resort Miami",
"stars": 4.0,
"rating": 42,
"review_count": 850,
"coordinates": {
"lat": 25.7617,
"lng": -80.1918
},
"address": {
"address": "456 Ocean Drive",
"city": "Miami",
"country": "US",
"postal_code": "33139",
"region": "FL"
},
"images": [
"https://images.tripedge.com/hotels/1235/main.jpg"
],
"amenities": ["pool", "restaurant", "wifi", "parking"],
"type": "resort"
}
],
"success": true,
"message": null
}
Downloading the full catalog
To download the complete hotel catalog, iterate through pages until the data array is empty.
Pagination strategy
- Start with
page: 1 - Process the returned hotels
- Increment the page number
- Repeat until
datais an empty array
Best practices
- Rate limiting: Add a small delay between requests to avoid overwhelming the server
- Error handling: Implement retry logic for transient failures
- Incremental updates: Store the last download timestamp to track catalog freshness
- Storage: Consider using a database or search index for efficient querying
Full catalog download
async function downloadCatalog(apiKey) {
const hotels = []
let page = 1
let hasMore = true
while (hasMore) {
const response = await fetch(
'https://api.tripedge.com/data/hotels',
{
method: 'POST',
headers: {
'Authorization': apiKey,
'Content-Type': 'application/json',
},
body: JSON.stringify({ page }),
}
)
const result = await response.json()
if (!result.success) {
throw new Error(result.message || 'Failed to fetch catalog')
}
if (result.data.length === 0) {
hasMore = false
} else {
hotels.push(...result.data)
page++
}
// Optional: Add delay between requests
await new Promise(resolve => setTimeout(resolve, 100))
}
return hotels
}
// Usage
const catalog = await downloadCatalog('{your_api_key}')
console.log(`Downloaded ${catalog.length} hotels`)
Python example
import requests
import time
def download_catalog(api_key):
hotels = []
page = 1
while True:
response = requests.post(
'https://api.tripedge.com/data/hotels',
headers={
'Authorization': api_key,
'Content-Type': 'application/json',
},
json={'page': page}
)
result = response.json()
if not result['success']:
raise Exception(result.get('message', 'Failed to fetch catalog'))
if not result['data']:
break
hotels.extend(result['data'])
page += 1
# Optional: Add delay between requests
time.sleep(0.1)
return hotels
# Usage
catalog = download_catalog('{your_api_key}')
print(f'Downloaded {len(catalog)} hotels')