API Documentation

Getting Started

Base URL

https://yourdomain.com/api/v1/

Authentication

All API requests require authentication token in the request header:

Authorization: Bearer {your_api_token}

Generate API Token

Access Admin Panel > API Settings > Generate New Token

  • Set token name for identification
  • Configure permissions (read, write, delete)
  • Add IP whitelist for security (optional)
  • Set expiration date or never expire

Request Format

All requests accept JSON payload with Content-Type header:

Content-Type: application/json

Response Format

All responses return JSON with consistent structure:

{
    "status": "success",
    "data": {},
    "message": "Operation completed successfully",
    "timestamp": 1696089600
}

Error Response

{
    "status": "error",
    "message": "Invalid parameters",
    "errors": [
        {
            "field": "amount",
            "message": "Amount must be greater than 0"
        }
    ],
    "timestamp": 1696089600
}

Authentication Endpoints

POST /auth/register

Create new player account.

Request Body

{
    "username": "player123",
    "email": "player@example.com",
    "password": "SecurePass123!",
    "first_name": "John",
    "last_name": "Smith",
    "birth_date": "1990-05-15",
    "country_code": "US",
    "currency_code": "USD",
    "phone": "+1234567890",
    "accept_terms": true
}

Response

{
    "status": "success",
    "data": {
        "user_id": 12345,
        "username": "player123",
        "email": "player@example.com",
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
        "expires_at": 1696089600
    },
    "message": "Account created successfully"
}

POST /auth/login

Authenticate existing player.

Request Body

{
    "username": "player123",
    "password": "SecurePass123!",
    "remember": true
}

Response

{
    "status": "success",
    "data": {
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
        "expires_at": 1696089600,
        "user": {
            "id": 12345,
            "username": "player123",
            "email": "player@example.com",
            "balance": 1500.50,
            "currency": "USD"
        }
    }
}

POST /auth/logout

Invalidate authentication token.

Headers

Authorization: Bearer {token}

Response

{
    "status": "success",
    "message": "Logged out successfully"
}

POST /auth/refresh

Refresh expired authentication token.

Request Body

{
    "refresh_token": "def50200..."
}

Response

{
    "status": "success",
    "data": {
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
        "expires_at": 1696089600
    }
}

Player Management

GET /players/{id}

Retrieve player account information.

Parameters

  • id (required) – Player ID

Response

{
    "status": "success",
    "data": {
        "id": 12345,
        "username": "player123",
        "email": "player@example.com",
        "first_name": "John",
        "last_name": "Smith",
        "country": "US",
        "currency": "USD",
        "balance": 1500.50,
        "bonus_balance": 250.00,
        "vip_level": "gold",
        "kyc_status": "verified",
        "registered_at": "2024-01-15T10:30:00Z",
        "last_login": "2024-09-30T14:22:00Z"
    }
}

PUT /players/{id}

Update player profile information.

Request Body

{
    "first_name": "John",
    "last_name": "Smith",
    "phone": "+1234567890",
    "date_of_birth": "1990-05-15",
    "address": {
        "street": "123 Main St",
        "city": "New York",
        "postal_code": "10001",
        "country": "US"
    }
}

Response

{
    "status": "success",
    "message": "Profile updated successfully"
}

GET /players/{id}/balance

Get current player balance.

Response

{
    "status": "success",
    "data": {
        "user_id": 12345,
        "main_balance": 1500.50,
        "bonus_balance": 250.00,
        "total_balance": 1750.50,
        "currency": "USD",
        "last_updated": "2024-09-30T14:25:30Z"
    }
}

POST /players/{id}/balance

Adjust player balance (admin only).

Request Body

{
    "type": "credit",
    "amount": 100.00,
    "reason": "Promotional credit",
    "reference": "PROMO2024"
}

Response

{
    "status": "success",
    "data": {
        "transaction_id": 78901,
        "previous_balance": 1500.50,
        "new_balance": 1600.50,
        "amount": 100.00
    }
}

GET /players/{id}/transactions

List player transaction history.

Query Parameters

  • type – Filter by transaction type (deposit, withdrawal, bet, win)
  • status – Filter by status (pending, completed, failed)
  • from – Start date (YYYY-MM-DD)
  • to – End date (YYYY-MM-DD)
  • limit – Results per page (default 50, max 200)
  • offset – Pagination offset

Example Request

GET /api/v1/players/12345/transactions?type=deposit&status=completed&limit=20

Response

{
    "status": "success",
    "data": {
        "transactions": [
            {
                "id": 78901,
                "type": "deposit",
                "amount": 500.00,
                "currency": "USD",
                "status": "completed",
                "payment_method": "credit_card",
                "created_at": "2024-09-30T10:15:00Z",
                "processed_at": "2024-09-30T10:15:32Z"
            }
        ],
        "pagination": {
            "total": 145,
            "limit": 20,
            "offset": 0,
            "has_more": true
        }
    }
}

Game Management

GET /games

List available games with filtering options.

Query Parameters

  • provider – Filter by provider ID
  • category – Filter by category (slots, table, live, other)
  • search – Search by game name
  • limit – Results per page (default 50, max 200)
  • offset – Pagination offset
  • sort – Sort field (name, popularity, rtp)
  • order – Sort order (asc, desc)

Example Request

GET /api/v1/games?category=slots&provider=pragmatic&limit=20&sort=popularity

Response

{
    "status": "success",
    "data": {
        "games": [
            {
                "id": 1001,
                "name": "Gates of Olympus",
                "slug": "gates-of-olympus",
                "provider": {
                    "id": 5,
                    "name": "Pragmatic Play"
                },
                "category": "slots",
                "thumbnail": "https://cdn.example.com/games/gates-olympus.jpg",
                "rtp": 96.50,
                "volatility": "high",
                "min_bet": 0.20,
                "max_bet": 100.00,
                "has_demo": true,
                "features": ["free_spins", "multipliers", "buy_bonus"]
            }
        ],
        "pagination": {
            "total": 1247,
            "limit": 20,
            "offset": 0,
            "has_more": true
        }
    }
}

GET /games/{id}

Get detailed information about specific game.

Response

{
    "status": "success",
    "data": {
        "id": 1001,
        "name": "Gates of Olympus",
        "slug": "gates-of-olympus",
        "provider": {
            "id": 5,
            "name": "Pragmatic Play"
        },
        "category": "slots",
        "subcategory": "video_slots",
        "description": "Enter the realm of Greek gods...",
        "thumbnail": "https://cdn.example.com/games/gates-olympus.jpg",
        "banner": "https://cdn.example.com/games/gates-olympus-banner.jpg",
        "rtp": 96.50,
        "volatility": "high",
        "min_bet": 0.20,
        "max_bet": 100.00,
        "max_win": 5000,
        "paylines": 20,
        "reels": 5,
        "rows": 3,
        "has_demo": true,
        "features": ["free_spins", "multipliers", "buy_bonus"],
        "release_date": "2021-02-13",
        "popularity_score": 9.2
    }
}

POST /games/{id}/launch

Generate game launch URL for player session.

Request Body

{
    "player_id": 12345,
    "mode": "real",
    "return_url": "https://yourdomain.com/lobby",
    "language": "en",
    "device": "desktop"
}

Response

{
    "status": "success",
    "data": {
        "session_id": "sess_abc123def456",
        "launch_url": "https://games.provider.com/launch?token=...",
        "expires_at": 1696089660
    },
    "message": "Game session created"
}

GET /games/providers

List all integrated game providers.

Response

{
    "status": "success",
    "data": {
        "providers": [
            {
                "id": 5,
                "name": "Pragmatic Play",
                "slug": "pragmatic-play",
                "logo": "https://cdn.example.com/providers/pragmatic.png",
                "game_count": 247,
                "status": "active",
                "categories": ["slots", "live", "table"]
            },
            {
                "id": 8,
                "name": "Evolution Gaming",
                "slug": "evolution",
                "logo": "https://cdn.example.com/providers/evolution.png",
                "game_count": 89,
                "status": "active",
                "categories": ["live"]
            }
        ]
    }
}

GET /games/categories

List game categories with counts.

Response

{
    "status": "success",
    "data": {
        "categories": [
            {
                "id": "slots",
                "name": "Slots",
                "game_count": 8423,
                "subcategories": [
                    {"id": "video_slots", "name": "Video Slots", "count": 7892},
                    {"id": "classic_slots", "name": "Classic Slots", "count": 531}
                ]
            },
            {
                "id": "live",
                "name": "Live Casino",
                "game_count": 342
            },
            {
                "id": "table",
                "name": "Table Games",
                "game_count": 156
            }
        ]
    }
}

Transaction Management

POST /transactions/deposit

Process deposit transaction.

Request Body

{
    "player_id": 12345,
    "amount": 100.00,
    "currency": "USD",
    "payment_method": "credit_card",
    "card_token": "tok_1234567890",
    "return_url": "https://yourdomain.com/deposit/complete"
}

Response

{
    "status": "success",
    "data": {
        "transaction_id": 78901,
        "amount": 100.00,
        "currency": "USD",
        "status": "pending",
        "payment_url": "https://payment.gateway.com/process?id=...",
        "created_at": "2024-09-30T14:30:00Z"
    }
}

POST /transactions/withdrawal

Process withdrawal request.

Request Body

{
    "player_id": 12345,
    "amount": 500.00,
    "currency": "USD",
    "payment_method": "bank_transfer",
    "bank_details": {
        "account_number": "1234567890",
        "routing_number": "123456789",
        "account_holder": "John Smith"
    }
}

Response

{
    "status": "success",
    "data": {
        "transaction_id": 78902,
        "amount": 500.00,
        "currency": "USD",
        "status": "pending",
        "estimated_completion": "2024-10-02T14:30:00Z",
        "created_at": "2024-09-30T14:30:00Z"
    }
}

GET /transactions/{id}

Get transaction details.

Response

{
    "status": "success",
    "data": {
        "id": 78901,
        "type": "deposit",
        "amount": 100.00,
        "currency": "USD",
        "status": "completed",
        "payment_method": "credit_card",
        "player": {
            "id": 12345,
            "username": "player123"
        },
        "balance_before": 1500.50,
        "balance_after": 1600.50,
        "created_at": "2024-09-30T14:30:00Z",
        "processed_at": "2024-09-30T14:30:32Z",
        "reference_id": "TXN_ABC123"
    }
}

PUT /transactions/{id}/status

Update transaction status (admin only).

Request Body

{
    "status": "completed",
    "note": "Manually verified and approved"
}

Response

{
    "status": "success",
    "message": "Transaction status updated"
}

Bonus Management

GET /bonuses

List available bonuses.

Query Parameters

  • type – Filter by bonus type
  • active – Filter by active status (true/false)

Response

{
    "status": "success",
    "data": {
        "bonuses": [
            {
                "id": 101,
                "code": "WELCOME100",
                "name": "Welcome Bonus",
                "type": "deposit_match",
                "percentage": 100,
                "max_bonus": 500.00,
                "min_deposit": 20.00,
                "wagering_requirement": 35,
                "valid_from": "2024-01-01T00:00:00Z",
                "valid_until": "2024-12-31T23:59:59Z",
                "terms": "New players only. Max bet $5..."
            }
        ]
    }
}

POST /bonuses/claim

Claim bonus for player.

Request Body

{
    "player_id": 12345,
    "bonus_code": "WELCOME100",
    "deposit_amount": 100.00
}

Response

{
    "status": "success",
    "data": {
        "bonus_id": 101,
        "player_bonus_id": 5001,
        "bonus_amount": 100.00,
        "wagering_required": 3500.00,
        "expires_at": "2024-10-07T14:30:00Z"
    },
    "message": "Bonus claimed successfully"
}

GET /bonuses/player/{player_id}

Get player active bonuses.

Response

{
    "status": "success",
    "data": {
        "active_bonuses": [
            {
                "id": 5001,
                "bonus": {
                    "id": 101,
                    "name": "Welcome Bonus",
                    "type": "deposit_match"
                },
                "bonus_amount": 100.00,
                "wagering_required": 3500.00,
                "wagering_completed": 1250.00,
                "remaining_wagering": 2250.00,
                "progress_percentage": 35.71,
                "expires_at": "2024-10-07T14:30:00Z",
                "claimed_at": "2024-09-30T14:30:00Z"
            }
        ]
    }
}

DELETE /bonuses/player/{player_id}/{bonus_id}

Cancel active bonus.

Response

{
    "status": "success",
    "message": "Bonus cancelled successfully"
}

Reporting Endpoints

GET /reports/revenue

Financial revenue report.

Query Parameters

  • date_from (required) – Start date (YYYY-MM-DD)
  • date_to (required) – End date (YYYY-MM-DD)
  • currency – Filter by currency
  • breakdown – Grouping (daily, weekly, monthly)

Response

{
    "status": "success",
    "data": {
        "period": {
            "from": "2024-09-01",
            "to": "2024-09-30"
        },
        "summary": {
            "total_deposits": 125000.00,
            "total_withdrawals": 87500.00,
            "total_bets": 450000.00,
            "total_wins": 423000.00,
            "ggr": 27000.00,
            "ngr": 37500.00,
            "active_players": 1247
        },
        "daily_breakdown": [
            {
                "date": "2024-09-30",
                "deposits": 4200.00,
                "withdrawals": 2900.00,
                "bets": 15000.00,
                "wins": 14100.00,
                "ggr": 900.00
            }
        ]
    }
}

GET /reports/games

Game performance statistics.

Query Parameters

  • date_from – Start date
  • date_to – End date
  • game_id – Specific game filter
  • provider_id – Provider filter

Response

{
    "status": "success",
    "data": {
        "games": [
            {
                "game_id": 1001,
                "game_name": "Gates of Olympus",
                "provider": "Pragmatic Play",
                "rounds_played": 15782,
                "total_bet": 47346.00,
                "total_win": 44879.10,
                "ggr": 2466.90,
                "rtp_actual": 94.79,
                "rtp_theoretical": 96.50,
                "unique_players": 423
            }
        ]
    }
}

GET /reports/players

Player activity statistics.

Response

{
    "status": "success",
    "data": {
        "total_registered": 15423,
        "active_today": 342,
        "active_week": 1247,
        "active_month": 3891,
        "new_registrations_today": 23,
        "verified_accounts": 8912,
        "vip_players": 156
    }
}

Webhooks

Configure Webhooks

Set webhook URLs in Admin Panel > API Settings > Webhooks

Webhook Events

player.registered

Triggered when new player creates account.

{
    "event": "player.registered",
    "timestamp": 1696089600,
    "data": {
        "player_id": 12345,
        "username": "player123",
        "email": "player@example.com",
        "country": "US",
        "registered_at": "2024-09-30T14:30:00Z"
    }
}

transaction.completed

Triggered when transaction processing completes.

{
    "event": "transaction.completed",
    "timestamp": 1696089600,
    "data": {
        "transaction_id": 78901,
        "type": "deposit",
        "player_id": 12345,
        "amount": 100.00,
        "currency": "USD",
        "processed_at": "2024-09-30T14:30:32Z"
    }
}

bonus.awarded

Triggered when bonus awarded to player.

{
    "event": "bonus.awarded",
    "timestamp": 1696089600,
    "data": {
        "player_id": 12345,
        "bonus_id": 101,
        "bonus_amount": 100.00,
        "wagering_requirement": 3500.00,
        "awarded_at": "2024-09-30T14:30:00Z"
    }
}

game.bigwin

Triggered when player wins above threshold.

{
    "event": "game.bigwin",
    "timestamp": 1696089600,
    "data": {
        "player_id": 12345,
        "game_id": 1001,
        "bet_amount": 5.00,
        "win_amount": 2500.00,
        "multiplier": 500,
        "session_id": "sess_abc123"
    }
}

Webhook Security

All webhooks include signature header for verification:

X-Webhook-Signature: sha256=...

Verify Signature

$payload = file_get_contents('php://input');
$signature = hash_hmac('sha256', $payload, $webhook_secret);
$expected = $_SERVER['HTTP_X_WEBHOOK_SIGNATURE'];
if (hash_equals('sha256=' . $signature, $expected)) {
// Valid webhook
}

Rate Limits

Tier Limits

  • Standard: 1000 requests per hour per IP
  • Premium: 10000 requests per hour per IP
  • Enterprise: Unlimited requests

Rate Limit Headers

X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 847
X-RateLimit-Reset: 1696093200

Exceeded Limit Response

HTTP/1.1 429 Too Many Requests
Retry-After: 3600
{
"status": "error",
"message": "Rate limit exceeded",
"retry_after": 3600
}

Error Codes

Code Description
400 Bad Request – Invalid parameters
401 Unauthorized – Authentication failed
403 Forbidden – Insufficient permissions
404 Not Found – Resource does not exist
409 Conflict – Resource already exists
422 Unprocessable Entity – Validation failed
429 Too Many Requests – Rate limit exceeded
500 Internal Server Error – System error
503 Service Unavailable – Maintenance mode

Testing

Sandbox Environment

https://sandbox.yourdomain.com/api/v1/

Test Credentials

  • Username: test_player
  • Password: TestPass123!
  • API Token: test_token_abc123def456

Test Cards

  • Success: 4242 4242 4242 4242
  • Declined: 4000 0000 0000 0002
  • Insufficient Funds: 4000 0000 0000 9995

SDK Libraries

PHP SDK

composer require casino-api/php-sdk
$client = new CasinoAPI\Client([
'api_key' => 'your_api_token',
'base_url' => 'https://yourdomain.com/api/v1'
]);
$games = $client->games()->list(['category' => 'slots']);

JavaScript SDK

npm install @casino-api/js-sdk
import CasinoAPI from '@casino-api/js-sdk';
const client = new CasinoAPI({
apiKey: 'your_api_token',
baseUrl: 'https://yourdomain.com/api/v1'
});
const games = await client.games.list({ category: 'slots' });

Python SDK

pip install casino-api
from casino_api import Client
client = Client(
api_key='your_api_token',
base_url='https://yourdomain.com/api/v1'
)
games = client.games.list(category='slots')
Casino Clone