Casino API Documentation
Seamless wallet integration guide for casino game providers
This API allows you to integrate casino games from multiple providers into your platform using a seamless wallet system. Your server holds the player balance — our aggregator calls your endpoints to fetch and update balances on every bet/win.
https://apigamesv2.darkempires.shop — your callback endpoints must be publicly accessible at your own domain.Architecture
There are 3 parties in every game session:
| Party | Role |
|---|---|
| Your Server | Holds player balance, exposes 2 callback URLs, sends game launch request |
| Our Aggregator | apigamesv2.darkempires.shop — validates your code, fetches game URL, routes callbacks |
| Game Provider | Runs the actual game, reports every bet/win to our aggregator |
Integration Flow
Every game session follows this exact sequence:
https://your-domain.com/apifolder/api/webapi/GetGameBalance?acho=<mobile> to fetch the player's current balance.{ "gameurl": "https://..." }. Your server redirects the player to the game.GetGameBalanceCall endpoint with laga (bet) and hara (win). You deduct/add to player wallet and return new balance.{ "newmotta": <new_balance> }. The game continues with the updated balance.Credentials
You receive the following credentials when your account is activated:
| Field | Description | Example |
|---|---|---|
| code | Your unique client code. Sent with every launch request. | a7be0c27dba17c958e31 |
| agentId | Your agent identifier | rajxavenbo |
| agentKey / token | Secret token used to sign requests | rjinqcvuw |
| referrerUrl | Your site's base URL (must end with /). This is how we know which callback URLs to call. | https://yoursite.com/ |
referrerUrl must exactly match what was registered. If it doesn't match, you'll get Error 352 (Invalid or expired client code). Also ensure the domain is whitelisted and has not expired.Game Launch API
Send a GET request to our aggregator to start a game session.
All parameters are passed as query string.
Request Parameters
| Parameter | Required | Description |
|---|---|---|
| gameId | Required | Game ID from our games list (e.g. pp-vs20fruitsw) |
| mobile | Required | Player's unique identifier (mobile number or user ID) |
| agentId | Required | Your agent ID |
| agentKey | Required | Your secret token |
| code | Required | Your client code |
| referrerUrl | Required | Your site base URL (must end with /) |
Example Request:
https://apigamesv2.darkempires.shop/?post
&gameId=pp-vs20fruitsw
&mobile=01712345678
&agentId=rajxavenbo
&agentKey=rjinqcvuw
&code=a7be0c27dba17c958e31
&referrerUrl=https://yoursite.com/
Success Response
{
"gameurl": "https://apigamesv2.darkempires.shop/premiumgames/gamesUrl?token=..."
}
Redirect the player to the returned gameurl in an iframe or new page.
Error Responses
| Error | Cause | Fix |
|---|---|---|
Missing parameters | One or more required params missing | Check all 6 params are present |
Invalid API response - 404 | Your GetGameBalance callback returned 404 | Ensure the file exists at /apifolder/api/webapi/GetGameBalance.php |
Invalid API response - 500 | Your callback crashed | Check PHP errors in your callback file |
Game not approved | Game ID not in our games table | Use a valid game ID from the games list |
Error - 352 | Your code or URL is invalid/expired | Verify referrerUrl exactly matches registered URL |
Game not allowed for this client | Game provider not in your allowed list | Contact support to add the vendor |
Balance is much higher than required | Player balance exceeds max_credit limit | Reduce player balance before launch |
GGR has reached/exceeded Total Credit | Your GGR billing cycle credit exhausted | Purchase more GGR credit |
Invalid game API response | Game provider returned no URL | Try a different game, contact support |
Callback #1 — GetGameBalance
Our aggregator calls this on your server before every game launch to fetch the player's current balance.
Request Parameter
| Parameter | Description |
|---|---|
| acho | Player's mobile number / unique ID |
Required Response
{
"balance": 250.50,
"akshinak": "your-player-token"
}
| Field | Type | Description |
|---|---|---|
| balance | number | Player's current wallet balance (float) |
| akshinak | string | Player session token (any unique string per player) |
Example PHP Implementation
// /apifolder/api/webapi/GetGameBalance.php
require_once __DIR__ . '/../../conn.php';
header('Content-Type: application/json');
$mobile = trim($_REQUEST['acho'] ?? '');
// Look up player in your DB...
// Return:
echo json_encode([
'balance' => 250.50,
'akshinak' => 'player-token-123',
]);
Callback #2 — GetGameBalanceCall
Called on every bet and settlement. Your server must deduct the bet, add winnings, and return the new balance.
Request Parameters
| Parameter | Description |
|---|---|
| acho | Player mobile / ID |
| laga | Bet amount (deduct from balance) |
| hara | Win amount (add to balance) |
| game_uid | Game ID |
| game_round | Round identifier |
| serial_number | Unique transaction serial |
| timestamp | Unix timestamp of the event |
| member_acc | Internal member account string |
Required Response
{
"newmotta": 245.50
}
The balance formula is always:
newBalance = currentBalance - laga (bet) + hara (win)
For a win: laga=10, hara=25 → balance increases by 15
For a push/refund: laga=10, hara=10 → balance unchanged
Insufficient Balance Handling
If the player's balance is less than the bet amount (laga > balance), return HTTP 400:
{
"error": "insufficient_balance",
"balance": 1.50
}
Callback System
The aggregator also maintains an internal callback pipeline from the game provider → aggregator → your server.
apigamesv2.darkempires.shop/?callbacksystemuser_server_urls table using member_accounttbl_asofts_game_sessions_v2 with new bet/win totals and calculated GGR deductionnewmotta (new balance){ "credit_amount": <newmotta>, "timestamp": <ts> } to the providerCallback Payload Fields
| Field | Type | Description |
|---|---|---|
| game_uid | string | Unique game identifier |
| game_round | string | Round/hand ID |
| bet_amount | float | Amount wagered in this round |
| win_amount | float | Amount won (0 if lost) |
| serial_number | string | Unique transaction reference |
| member_account | string | Internal player account (first 9 chars = session prefix, rest = mobile) |
| timestamp | unix | Event timestamp |
GGR System
Gross Gaming Revenue (GGR) is calculated as player losses × your GGR percentage. Your account has a total credit limit per billing cycle.
| Concept | Details |
|---|---|
| GGR % | Your negotiated revenue share percentage (e.g. 5%) |
| Total Credit | Maximum GGR usage allowed in your current cycle |
| Cycle | Current billing cycle number (resets when you top up) |
| GGR Bind | If is_ggr_bind = yes, game launches are blocked when GGR reaches Total Credit |
// GGR deduction per game session
player_loss = total_bet - total_win // if positive
ggr_used = player_loss × (ggr_percentage / 100)
// Blocked when:
SUM(ggr_used in current cycle) >= total_credit
All Error Codes Reference
| Code / Message | HTTP | Cause |
|---|---|---|
Missing parameters | 400 | Required query params missing in launch request |
404 for callback urls | 200 | Your GetGameBalance URL returned 404 |
500 for callback urls | 200 | Your GetGameBalance URL crashed |
Invalid API response | 200 | Your callback returned invalid JSON |
Game not approved | 200 | gameId not in aggregator games table |
Error - 352 | 200 | Client code invalid, URL mismatch, or account expired |
Game not allowed for this client | 200 | Vendor not enabled for your account |
Balance is much higher than required | 200 | Player balance > max_credit for account |
GGR exceeded | 200 | GGR credit limit reached for current cycle |
DB insert failed | 200 | Internal server error — contact support |
Game API call failed | 200 | Upstream provider unreachable |
Invalid game API response | 200 | Provider returned no game URL |
missing_mobile | 400 | acho param missing in balance callback |
user_not_found | 404 | Player not found in your DB |
wallet_not_found | 404 | Wallet row missing for player |
insufficient_balance | 400 | Player balance less than bet amount |
update_failed | 500 | DB write failed during balance update |
Demo / Testing Setup
This demo site runs with a pre-configured demo player so you can test games without a real wallet.
| Setting | Value |
|---|---|
| Demo Player Mobile | 9999999999 |
| Starting Balance | 2.00 (auto-created on first launch) |
| Client Code | a7be0c27dba17c958e31 |
| Referrer URL | https://darkempires.shop/ |
| Callback Base | https://darkempires.shop/apifolder/api/webapi/ |
Required Database Tables
-- Players
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
mobile VARCHAR(20) UNIQUE NOT NULL,
token VARCHAR(100) NOT NULL
);
-- Wallets
CREATE TABLE wallets (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
balance DECIMAL(12,2) DEFAULT 2.00
);
-- Transaction log
CREATE TABLE game_transactions (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT,
bet DECIMAL(12,2),
win DECIMAL(12,2),
balance_after DECIMAL(12,2),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
Downloads
Download the required files below to get started with your integration.
apifolder/conn.php, then import games_data.sql into your database.Quick Integration Checklist
| # | Step | Status |
|---|---|---|
| 1 | Receive credentials (code, agentId, token, referrerUrl) | ☐ |
| 2 | Create GetGameBalance.php at correct path | ☐ |
| 3 | Create GetGameBalanceCall.php at correct path | ☐ |
| 4 | Ensure both URLs return HTTP 200 with correct JSON | ☐ |
| 5 | Test game launch with a valid gameId | ☐ |
| 6 | Verify balance updates on bet/win | ☐ |
| 7 | Monitor GGR usage in your cycle | ☐ |