Skip to main content

Introduction

The Cajas API provides endpoints for managing case openings and provably fair seed management. All API endpoints are built using Next.js API routes and require authentication.

Base URL

https://your-domain.com/api
For local development:
http://localhost:3000/api

Authentication

All API endpoints require authentication using Supabase authentication. Requests must include a valid session cookie or authorization header.
Unauthenticated requests will receive a 401 Unauthorized response.

Authentication Headers

When making API requests, ensure you include the Supabase authentication token:
curl -X GET https://your-domain.com/api/provably-fair/seed \
  -H "Authorization: Bearer YOUR_SUPABASE_TOKEN" \
  -H "Content-Type: application/json"

Response Format

All API responses are returned in JSON format.

Success Response

{
  "data": {
    // Response data
  }
}

Error Response

Error responses follow a consistent format:
{
  "error": "Error message description"
}

Common Status Codes

200
OK
Request was successful
401
Unauthorized
Missing or invalid authentication credentials
404
Not Found
The requested resource was not found (e.g., case doesn’t exist)
400
Bad Request
Invalid request parameters or case is empty
500
Internal Server Error
An error occurred on the server

Rate Limiting

Rate limiting may be implemented in production environments. Contact your administrator for specific rate limits.

Available Endpoints

Case Management

Provably Fair

Data Models

User Seeds

The system uses a provably fair system with server seeds, client seeds, and nonces:
  • Server Seed: Generated server-side, kept secret until revealed
  • Client Seed: User-provided or generated, known to the user
  • Nonce: Incrementing counter for each game round
  • Server Seed Hash: SHA-256 hash of the server seed (publicly visible)

Case Items

Case items include:
  • Item ID and metadata
  • Value (price)
  • Probability (drop chance percentage)
  • Rarity tier (legendary < 1%, epic < 5%, rare < 20%, common >= 20%)

Getting Started

  1. Authenticate with Supabase
  2. Retrieve your current seeds using GET /api/provably-fair/seed
  3. Open a case using POST /api/cases/open
  4. Verify fairness using the returned seed information
For a complete guide on implementing provably fair gaming, see the Provably Fair System documentation.

Build docs developers (and LLMs) love