Logo Dark Empires Casino API v2.1

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.

ℹ️
Base URL: All API requests go to https://apigamesv2.darkempires.shop — your callback endpoints must be publicly accessible at your own domain.

Architecture

There are 3 parties in every game session:

PartyRole
Your ServerHolds player balance, exposes 2 callback URLs, sends game launch request
Our Aggregatorapigamesv2.darkempires.shop — validates your code, fetches game URL, routes callbacks
Game ProviderRuns the actual game, reports every bet/win to our aggregator

Integration Flow

Every game session follows this exact sequence:

1
Player clicks a game on your site
Your server makes a GET request to our launch endpoint with the player's mobile, your client code, and the game ID.
2
Aggregator calls GetGameBalance on your server
We call https://your-domain.com/apifolder/api/webapi/GetGameBalance?acho=<mobile> to fetch the player's current balance.
3
Aggregator validates your code & GGR credit
Checks that your client code is active, not expired, and you have remaining GGR credit for this billing cycle.
4
Game URL returned to your server
We return { "gameurl": "https://..." }. Your server redirects the player to the game.
5
Player bets — aggregator calls GetGameBalanceCall
On every bet + settle, we call your GetGameBalanceCall endpoint with laga (bet) and hara (win). You deduct/add to player wallet and return new balance.
6
Your server returns new balance
Return { "newmotta": <new_balance> }. The game continues with the updated balance.

Credentials

You receive the following credentials when your account is activated:

FieldDescriptionExample
codeYour unique client code. Sent with every launch request.a7be0c27dba17c958e31
agentIdYour agent identifierrajxavenbo
agentKey / tokenSecret token used to sign requestsrjinqcvuw
referrerUrlYour site's base URL (must end with /). This is how we know which callback URLs to call.https://yoursite.com/
⚠️
Your 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.

GET https://apigamesv2.darkempires.shop/?post

All parameters are passed as query string.

Request Parameters

ParameterRequiredDescription
gameIdRequiredGame ID from our games list (e.g. pp-vs20fruitsw)
mobileRequiredPlayer's unique identifier (mobile number or user ID)
agentIdRequiredYour agent ID
agentKeyRequiredYour secret token
codeRequiredYour client code
referrerUrlRequiredYour 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

ErrorCauseFix
Missing parametersOne or more required params missingCheck all 6 params are present
Invalid API response - 404Your GetGameBalance callback returned 404Ensure the file exists at /apifolder/api/webapi/GetGameBalance.php
Invalid API response - 500Your callback crashedCheck PHP errors in your callback file
Game not approvedGame ID not in our games tableUse a valid game ID from the games list
Error - 352Your code or URL is invalid/expiredVerify referrerUrl exactly matches registered URL
Game not allowed for this clientGame provider not in your allowed listContact support to add the vendor
Balance is much higher than requiredPlayer balance exceeds max_credit limitReduce player balance before launch
GGR has reached/exceeded Total CreditYour GGR billing cycle credit exhaustedPurchase more GGR credit
Invalid game API responseGame provider returned no URLTry 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.

GET https://your-domain.com/apifolder/api/webapi/GetGameBalance?acho=<mobile>

Request Parameter

ParameterDescription
achoPlayer's mobile number / unique ID

Required Response

{
  "balance":  250.50,
  "akshinak": "your-player-token"
}
FieldTypeDescription
balancenumberPlayer's current wallet balance (float)
akshinakstringPlayer 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',
]);
⚠️
This URL must return HTTP 200 with valid JSON. A 404 or 500 will cause the game launch to fail immediately.

Callback #2 — GetGameBalanceCall

Called on every bet and settlement. Your server must deduct the bet, add winnings, and return the new balance.

GET https://your-domain.com/apifolder/api/webapi/GetGameBalanceCall

Request Parameters

ParameterDescription
achoPlayer mobile / ID
lagaBet amount (deduct from balance)
haraWin amount (add to balance)
game_uidGame ID
game_roundRound identifier
serial_numberUnique transaction serial
timestampUnix timestamp of the event
member_accInternal member account string

Required Response

{
  "newmotta": 245.50
}

The balance formula is always:

newBalance = currentBalance - laga (bet) + hara (win)
For a normal loss: laga=10, hara=0 → balance decreases by 10
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.

1
Game Provider → Aggregator
Provider sends encrypted AES-256-ECB payload to apigamesv2.darkempires.shop/?callbacksystem
2
Aggregator decrypts & validates
Checks required fields, looks up player session from user_server_urls table using member_account
3
Aggregator updates GGR stats
Updates tbl_asofts_game_sessions_v2 with new bet/win totals and calculated GGR deduction
4
Aggregator calls your GetGameBalanceCall
Forwards bet/win data to your server. Your server returns newmotta (new balance)
5
Aggregator returns credit to game provider
Returns { "credit_amount": <newmotta>, "timestamp": <ts> } to the provider

Callback Payload Fields

FieldTypeDescription
game_uidstringUnique game identifier
game_roundstringRound/hand ID
bet_amountfloatAmount wagered in this round
win_amountfloatAmount won (0 if lost)
serial_numberstringUnique transaction reference
member_accountstringInternal player account (first 9 chars = session prefix, rest = mobile)
timestampunixEvent 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.

ConceptDetails
GGR %Your negotiated revenue share percentage (e.g. 5%)
Total CreditMaximum GGR usage allowed in your current cycle
CycleCurrent billing cycle number (resets when you top up)
GGR BindIf 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
ℹ️
When GGR is exhausted, players will see the message "GGR has reached/exceeded Total Credit" and cannot launch new games until you top up.

All Error Codes Reference

Code / MessageHTTPCause
Missing parameters400Required query params missing in launch request
404 for callback urls200Your GetGameBalance URL returned 404
500 for callback urls200Your GetGameBalance URL crashed
Invalid API response200Your callback returned invalid JSON
Game not approved200gameId not in aggregator games table
Error - 352200Client code invalid, URL mismatch, or account expired
Game not allowed for this client200Vendor not enabled for your account
Balance is much higher than required200Player balance > max_credit for account
GGR exceeded200GGR credit limit reached for current cycle
DB insert failed200Internal server error — contact support
Game API call failed200Upstream provider unreachable
Invalid game API response200Provider returned no game URL
missing_mobile400acho param missing in balance callback
user_not_found404Player not found in your DB
wallet_not_found404Wallet row missing for player
insufficient_balance400Player balance less than bet amount
update_failed500DB 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.

SettingValue
Demo Player Mobile9999999999
Starting Balance2.00 (auto-created on first launch)
Client Codea7be0c27dba17c958e31
Referrer URLhttps://darkempires.shop/
Callback Basehttps://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.

ℹ️
Extract apifolder.zip and place it in your server root. Update your DB credentials in apifolder/conn.php, then import games_data.sql into your database.

Quick Integration Checklist

#StepStatus
1Receive credentials (code, agentId, token, referrerUrl)
2Create GetGameBalance.php at correct path
3Create GetGameBalanceCall.php at correct path
4Ensure both URLs return HTTP 200 with correct JSON
5Test game launch with a valid gameId
6Verify balance updates on bet/win
7Monitor GGR usage in your cycle
Need help? Contact support at darkempires.shop with your client code and the error message you're seeing.


Dark Empires Casino API — v2.1 — June 2025  |  Lobby  |  Panel