API Documentation v2.0

Build with Book & Go

A powerful, secure REST API for integrating court booking data, payments, and live events into your automation systems.

Authentication

All API endpoints (except login) require JWT authentication. Tokens are designed for long-term automation, valid for 10 years.

Base URL: https://docsapi.bookandgo.app/api

Bearer Token

Include your JWT token in the Authorization header of every request.

HTTP Header
Authorization: Bearer YOUR_JWT_TOKEN

Rate Limiting

To ensure system stability, API endpoints have rate limits based on their database load. Limits are applied per JWT token.

Endpoint Limit Period
/locations 60 requests per minute
/bookings 60 requests per minute
/payments/summary 30 requests per minute
/payments/transactions 10 requests per minute
/events/live 30 requests per minute
Exceeding the limit returns a 429 Too Many Requests status code.

Login

POST /login

Authenticate with email and password to receive a long-lived JWT token.

Request Body

JSON
{
  "email": "[email protected]",
  "password": "your-password"
}

Response

JSON
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "club_id": 1,
  "club_name": "Your Club Name",
  "user_name": "Admin User",
  "expires_at": 2073037187
}

Locations

GET /locations

Retrieve all locations for your club. Use this to get location IDs required by other endpoints.

Tip: Call this endpoint first to get valid location IDs for filtering bookings, transactions, and events.

Example Request

BASH
curl -X GET "https://docsapi.bookandgo.app/api/locations" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response Fields

Field Type Description
id integer Unique location identifier (use this for location_id parameter)
location_name string Display name of the location
currency string Currency code (e.g., IDR, SGD)

Bookings

GET /bookings

Retrieve court bookings for your club within a date range.

Query Parameters

Parameter Type Required Description
start_date string No Start date (YYYY-MM-DD)
end_date string No End date (YYYY-MM-DD)
location_id integer No Filter by location

Example Request

BASH
curl -X GET "https://docsapi.bookandgo.app/api/bookings?start_date=2024-03-01&end_date=2024-03-31" \
  -H "Authorization: Bearer YOUR_TOKEN"

Payments Summary

GET /payments/summary

Get aggregated payment data including revenue, refunds, and breakdowns by payment method.

Maximum date range is 31 days to prevent database throttling.

Response Structure

JSON
{
  "date_range": {
    "start": "2024-03-01",
    "end": "2024-03-31"
  },
  "summary": {
    "total_revenue": 150000.00,
    "service_payments": 100000.00,
    "pos_payments": 40000.00,
    "refunds": 5000.00
  },
  "by_status": {
    "paid": 145000.00,
    "pending": 2000.00,
    "cancelled": 3000.00
  },
  "by_method": [
    {
      "method": "Credit Card",
      "amount": 50000.00,
      "count": 25
    }
  ]
}

Payment Transactions

GET /payments/transactions

Retrieve detailed payment transaction records with pagination support.

Rate Limited: 10 requests per minute due to heavy database load.

Query Parameters

Parameter Type Required Description
location_id integer Yes Location ID (required for indexing)
page integer No Page number (default: 1)
limit integer No Items per page (max 100)

Live Events

GET /events/live

Retrieve upcoming and current events with participant counts, details, and images.

Response

JSON
{
  "club_id": 1,
  "club_name": "Example Club",
  "total_count": 5,
  "events": [
    {
      "event_id": 835,
      "event_name": "Morning Americano Tournament",
      "current_participants": 8,
      "maximum_capacity": 12,
      "price": 250000,
      "date": "2025-10-20",
      "location": { "id": 145, "name": "Main Location" }
    }
  ]
}

Quick Start

1. Get your Token

Authenticate using the Login endpoint to receive your JWT.

2. Find Locations

Call /locations to get the IDs needed for other requests.

3. Make Requests

Use the token in the Authorization header for all other calls.

Example: Get Token

BASH
curl -X POST https://docsapi.bookandgo.app/api/login \
  -H "Content-Type: application/json" \
  -d '{"email": "your-email", "password": "your-password"}'

Pagination Pattern

Handle paginated responses in the transactions endpoint.

JAVASCRIPT
async function fetchAllTransactions(locationId) {
  let allTransactions = [];
  let page = 1;
  let hasMore = true;

  while (hasMore) {
    const response = await fetch(
      `.../payments/transactions?location_id=${locationId}&page=${page}`,
      { headers: { 'Authorization': 'Bearer TOKEN' } }
    );
    const data = await response.json();
    allTransactions = allTransactions.concat(data.transactions);
    hasMore = page < data.total_pages;
    page++;
    
    // Wait to respect rate limits
    await new Promise(r => setTimeout(r, 6000));
  }
  return allTransactions;
}

Error Handling

Code Description Action
200 Success Process the response
400 Bad Request Check your parameters
401 Unauthorized Check your JWT token
429 Too Many Requests Wait and retry