SDK Libraries
Use these libraries to integrate Travelmode into your applications.
Official SDKs
Coming soon! In the meantime, use the REST API directly with your preferred HTTP client.
Community Libraries
Python
# Example wrapper class
import requests
class TravelmodeClient:
def __init__(self, api_key):
self.api_key = api_key
self.base_url = "https://travelmode2.replit.app"
self.headers = {"Authorization": f"Bearer {api_key}"}
def get_trips(self):
response = requests.get(
f"{self.base_url}/api/trips",
headers=self.headers
)
response.raise_for_status()
return response.json()
def get_trip(self, trip_id):
response = requests.get(
f"{self.base_url}/api/trips/{trip_id}",
headers=self.headers
)
response.raise_for_status()
return response.json()
def create_trip(self, name, description=None):
response = requests.post(
f"{self.base_url}/api/trips",
headers={**self.headers, "Content-Type": "application/json"},
json={"name": name, "description": description}
)
response.raise_for_status()
return response.json()
# Usage
client = TravelmodeClient("tm_your_api_key")
trips = client.get_trips()
JavaScript / TypeScript
// Example TypeScript client
class TravelmodeClient {
private apiKey: string;
private baseUrl: string;
constructor(apiKey: string) {
this.apiKey = apiKey;
this.baseUrl = 'https://travelmode2.replit.app';
}
private async request<T>(path: string, options?: RequestInit): Promise<T> {
const response = await fetch(`${this.baseUrl}${path}`, {
...options,
headers: {
'Authorization': `Bearer ${this.apiKey}`,
'Content-Type': 'application/json',
...options?.headers,
},
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.error || 'API request failed');
}
return response.json();
}
async getTrips() {
return this.request('/api/trips');
}
async getTrip(tripId: number) {
return this.request(`/api/trips/${tripId}`);
}
async createTrip(name: string, description?: string) {
return this.request('/api/trips', {
method: 'POST',
body: JSON.stringify({ name, description }),
});
}
}
// Usage
const client = new TravelmodeClient('tm_your_api_key');
const trips = await client.getTrips();
HTTP Clients
Any HTTP client works with the Travelmode API:
Python
requests- Simple and popularhttpx- Async supportaiohttp- Async-first
JavaScript
fetch- Built-inaxios- Feature-richky- Lightweight fetch wrapper
Other Languages
- Ruby:
httparty,faraday - Go:
net/http,resty - Java:
OkHttp,HttpClient - PHP:
Guzzle
Contribute
Building an SDK? Let us know and we'll feature it here!