Skip to main content

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โ€‹

  1. Sign in to your TrendGate dashboard
  2. Navigate to Settings โ†’ API Keys
  3. Click Generate New Key
  4. 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 instructor
  • member_id (string) - Filter by member
  • status (enum) - scheduled, completed, cancelled
  • date_from (ISO 8601) - Start date filter
  • date_to (ISO 8601) - End date filter
  • limit (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 email
  • certification (string) - Filter by certification type
  • available_date (ISO 8601) - Find available instructors
  • location (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 date
  • date_to (ISO 8601) - End date
  • timezone (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 hour
    • X-RateLimit-Remaining: Requests remaining
    • X-RateLimit-Reset: Unix timestamp when limit resets

๐Ÿšจ Error Codesโ€‹

CodeDescription
AUTHENTICATION_ERRORInvalid or missing API key
AUTHORIZATION_ERRORInsufficient permissions
VALIDATION_ERRORInvalid request parameters
NOT_FOUNDResource not found
CONFLICTResource conflict (e.g., double booking)
RATE_LIMIT_EXCEEDEDToo many requests
SERVER_ERRORInternal 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,
},
],
});