SDKs
The TripEdge API is a REST API that can be consumed using any HTTP client. We recommend using the native fetch API or popular libraries like axios for JavaScript applications.
HTTP Client Examples
JavaScript / TypeScript
// Using fetch
const response = await fetch('https://api.tripedge.com/v1/availability', {
method: 'POST',
headers: {
'Authorization': 'Bearer {your_api_key}',
'Content-Type': 'application/json'
},
body: JSON.stringify({
place_id: 'ChIJOwg_06VPwokRYv534QaPC8g',
check_in: '2024-03-15',
check_out: '2024-03-18',
rooms: [{ adults: 2, children: 0, children_ages: [] }]
})
})
const data = await response.json()
Python
import requests
response = requests.post(
'https://api.tripedge.com/v1/availability',
headers={
'Authorization': 'Bearer {your_api_key}',
'Content-Type': 'application/json'
},
json={
'place_id': 'ChIJOwg_06VPwokRYv534QaPC8g',
'check_in': '2024-03-15',
'check_out': '2024-03-18',
'rooms': [{'adults': 2, 'children': 0, 'children_ages': []}]
}
)
data = response.json()
cURL
curl -X POST https://api.tripedge.com/v1/availability \
-H "Authorization: Bearer {your_api_key}" \
-H "Content-Type: application/json" \
-d '{
"place_id": "ChIJOwg_06VPwokRYv534QaPC8g",
"check_in": "2024-03-15",
"check_out": "2024-03-18",
"rooms": [{"adults": 2, "children": 0, "children_ages": []}]
}'
Best Practices
- Always include error handling - Check the
successfield in responses - Implement retry logic - For 500 errors, retry with exponential backoff
- Cache session IDs - Reuse session IDs within their validity period
- Use HTTPS - All API requests must use HTTPS