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

  1. Always include error handling - Check the success field in responses
  2. Implement retry logic - For 500 errors, retry with exponential backoff
  3. Cache session IDs - Reuse session IDs within their validity period
  4. Use HTTPS - All API requests must use HTTPS

Was this page helpful?