REST API Reference
The TrendGate REST API provides programmatic access to all platform features. This reference describes the available endpoints, request/response formats, and authentication requirements.
๐ Authenticationโ
All API requests require authentication using a Bearer token:
curl https://api.trendgate.ai/v1/sessions \
-H "Authorization: Bearer YOUR_API_KEY"
Getting an API Keyโ
- Sign in to your TrendGate dashboard
- Navigate to Settings โ API Keys
- Click Generate New Key
- Copy your key immediately (it won't be shown again)
๐ Base URLโ
https://api.trendgate.ai/v1
๐ Request Formatโ
- All requests must include
Content-Type: application/json - Request bodies should be valid JSON
- Dates should be in ISO 8601 format
- All timestamps are in UTC
๐ Response Formatโ
All responses follow a consistent format:
{
"success": true,
"data": {
// Response data
},
"meta": {
"timestamp": "2024-01-20T10:30:00Z",
"request_id": "req_abc123"
}
}
Error responses:
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid session date",
"details": {
"field": "date",
"reason": "Date must be in the future"
}
},
"meta": {
"timestamp": "2024-01-20T10:30:00Z",
"request_id": "req_abc123"
}
}
๐ Core Endpointsโ
Sessionsโ
List Sessionsโ
GET /sessions
Query parameters:
instructor_id(string) - Filter by instructormember_id(string) - Filter by memberstatus(enum) -scheduled,completed,cancelleddate_from(ISO 8601) - Start date filterdate_to(ISO 8601) - End date filterlimit(integer) - Results per page (default: 20, max: 100)offset(integer) - Pagination offset
Example:
curl "https://api.trendgate.ai/v1/sessions?instructor_id=inst_123&status=scheduled" \
-H "Authorization: Bearer YOUR_API_KEY"
Create Sessionโ
POST /sessions
Request body:
{
"instructor_id": "inst_123",
"member_id": "mem_456",
"date": "2024-02-01T10:00:00Z",
"duration_minutes": 30,
"location": {
"type": "pool",
"pool_id": "pool_789"
},
"notes": "First lesson - water safety basics"
}
Get Sessionโ
GET /sessions/{session_id}
Update Sessionโ
PATCH /sessions/{session_id}
Request body (partial update):
{
"date": "2024-02-01T11:00:00Z",
"notes": "Rescheduled due to weather"
}
Cancel Sessionโ
POST /sessions/{session_id}/cancel
Request body:
{
"reason": "Weather conditions",
"notify_participants": true
}
Instructorsโ
List Instructorsโ
GET /instructors
Query parameters:
search(string) - Search by name or emailcertification(string) - Filter by certification typeavailable_date(ISO 8601) - Find available instructorslocation(object) - Filter by location (lat/lng/radius)
Get Instructor Profileโ
GET /instructors/{instructor_id}
Response includes:
- Profile information
- Certifications
- Availability schedule
- Rating and reviews
- Service areas
Update Instructor Profileโ
PATCH /instructors/{instructor_id}
Get Instructor Availabilityโ
GET /instructors/{instructor_id}/availability
Query parameters:
date_from(ISO 8601) - Start datedate_to(ISO 8601) - End datetimezone(string) - Timezone for results (default: UTC)
Membersโ
List Account Membersโ
GET /accounts/{account_id}/members
Create Memberโ
POST /accounts/{account_id}/members
Request body:
{
"name": "Sarah Johnson",
"date_of_birth": "2015-03-15",
"swimming_level": "beginner",
"medical_notes": "Mild asthma",
"emergency_contact": {
"name": "John Johnson",
"phone": "+1234567890",
"relationship": "parent"
}
}
Update Memberโ
PATCH /members/{member_id}
Get Member Progressโ
GET /members/{member_id}/progress
Bookingsโ
Create Bookingโ
POST /bookings
Request body:
{
"instructor_id": "inst_123",
"member_ids": ["mem_456", "mem_789"],
"sessions": [
{
"date": "2024-02-01T10:00:00Z",
"duration_minutes": 30
},
{
"date": "2024-02-08T10:00:00Z",
"duration_minutes": 30
}
],
"payment_method_id": "pm_abc123",
"notes": "Package of 2 lessons"
}
Get Bookingโ
GET /bookings/{booking_id}
List Account Bookingsโ
GET /accounts/{account_id}/bookings
Paymentsโ
List Payment Methodsโ
GET /accounts/{account_id}/payment-methods
Add Payment Methodโ
POST /accounts/{account_id}/payment-methods
Request body:
{
"stripe_payment_method_id": "pm_1234567890",
"is_default": true
}
Process Paymentโ
POST /payments
Request body:
{
"booking_id": "book_123",
"payment_method_id": "pm_abc123",
"amount_cents": 5000,
"currency": "USD"
}
Get Payment Historyโ
GET /accounts/{account_id}/payments
๐ Paginationโ
List endpoints support cursor-based pagination:
{
"data": [...],
"pagination": {
"has_more": true,
"next_cursor": "eyJvZmZzZXQiOjIwfQ==",
"total": 145
}
}
Use the cursor parameter for subsequent requests:
curl "https://api.trendgate.ai/v1/sessions?cursor=eyJvZmZzZXQiOjIwfQ==" \
-H "Authorization: Bearer YOUR_API_KEY"
โก Rate Limitingโ
- Rate limit: 1000 requests per hour
- Burst limit: 100 requests per minute
- Headers included in responses:
X-RateLimit-Limit: Maximum requests per hourX-RateLimit-Remaining: Requests remainingX-RateLimit-Reset: Unix timestamp when limit resets
๐จ Error Codesโ
| Code | Description |
|---|---|
AUTHENTICATION_ERROR | Invalid or missing API key |
AUTHORIZATION_ERROR | Insufficient permissions |
VALIDATION_ERROR | Invalid request parameters |
NOT_FOUND | Resource not found |
CONFLICT | Resource conflict (e.g., double booking) |
RATE_LIMIT_EXCEEDED | Too many requests |
SERVER_ERROR | Internal server error |
๐งช Testingโ
Use our sandbox environment for testing:
https://api-sandbox.trendgate.ai/v1
Test API keys can be generated in your dashboard under Settings โ API Keys โ Sandbox Keys.
๐ SDKsโ
Official SDKs are available for:
JavaScript Exampleโ
import { TrendGate } from "@trendgate/sdk";
const client = new TrendGate({
apiKey: process.env.TRENDGATE_API_KEY,
});
// List upcoming sessions
const sessions = await client.sessions.list({
status: "scheduled",
dateFrom: new Date(),
});
// Create a booking
const booking = await client.bookings.create({
instructorId: "inst_123",
memberIds: ["mem_456"],
sessions: [
{
date: new Date("2024-02-01T10:00:00Z"),
durationMinutes: 30,
},
],
});