Interactive API reference
Explore the production API and try synthetic requests in the free sandbox. Existing API endpoints and integrations stay unchanged.
From sandbox to your first real order
Try a safe example first, then connect your own server in five steps.
Try it out works only in the sandbox below. Production reference is read-only; send real API requests from your server.
Try a free test
In the sandbox below, click Create session. Open an operation, then choose Try it out → Execute. Only test data and TEST_USDT are used; no real money is spent.
Create your real API key
Open the API key section in your profile. Create a key and complete the requested password/2FA check. Save the full key when it appears. Keep it only on your server, never in browser code or on this page.
Check access from your server
Use the base URL below and send your key in the X-API-Key header. First call GET /me or GET /balance to check access without creating an order.
Choose a real product
Call GET /catalog, then GET /catalog/{game_key}. Select the correct product and region. Use its returned game_key, variation_id and required inputs, such as player_id or zone_id. Do not send sandbox keys, sandbox_game, sandbox_pack or scenario.
Create the order and check the result
Make sure your real balance covers the price. Send POST /order as JSON with a unique Idempotency-Key for each new order. If the request times out, retry the exact same payload with the same key; do not create a new key for that retry.
HTTP 201 means the order was created, not delivered. Check GET /order/{id}, or verify the signature of its webhook. Only COMPLETED confirms completion; also handle failed or refunded results.
Real API base URL
https://api.ludovex.org/api/v2Set LUDOVEX_API_KEY as an environment variable on your own server. This example is text only; do not paste your real key into this page.
First read-only check: GET /balance
curl --fail-with-body "https://api.ludovex.org/api/v2/balance" \
-H "X-API-Key: $LUDOVEX_API_KEY" \
-H "Accept: application/json"Server code examples
Choose your language, copy the file, and run it on your own server. The default command only reads your balance.
These scripts use the real Ludovex API. Try it out on this page stays in the separate sandbox; sandbox keys, IDs and scenario are not valid in these scripts.
1. Prepare your server
PHP 8.1 or newer with the cURL extension.
Save the code as ludovex.php. No Composer packages are required.
Set LUDOVEX_API_KEY in your server environment. Replace the placeholder below with your real key on your server only.
export LUDOVEX_API_KEY='YOUR_REAL_API_KEY'Never paste your real key into this page or put it in browser code, a public repository, or shared logs.
2. Start with a read-only request
Save the file, then run this command in your server terminal. It calls GET /balance; it does not create an order.
php ludovex.php- List real games and categories
- php ludovex.php catalog
- Get real products and required fields; replace GAME_KEY
- php ludovex.php products GAME_KEY
- Check an existing order; replace ORDER_ID
- php ludovex.php status ORDER_ID
ludovex.php
<?php
declare(strict_types=1);
// PHP 8.1+ with cURL. Run only on your server, never in a public web directory.
const API_BASE = 'https://api.ludovex.org/api/v2';
function requiredEnv(string $name): string {
$value = getenv($name) ?: '';
if (!preg_match('/^[\x21-\x7E]{1,191}$/D', $value)) {
throw new RuntimeException('Set ' . $name . ' in your server environment.');
}
return $value;
}
function requestApi(string $method, string $path, ?object $payload = null): mixed {
$headers = ['Accept: application/json', 'X-API-Key: ' . requiredEnv('LUDOVEX_API_KEY')];
if ($payload !== null) {
$key = requiredEnv('LUDOVEX_ORDER_KEY');
if (isset($payload->idempotency_key) && $payload->idempotency_key !== $key) {
throw new RuntimeException('The saved order key and payload key must match.');
}
$headers[] = 'Content-Type: application/json';
$headers[] = 'Idempotency-Key: ' . $key;
}
$ch = curl_init(API_BASE . $path);
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_HTTPHEADER => $headers, CURLOPT_FOLLOWLOCATION => false,
CURLOPT_CONNECTTIMEOUT => 5, CURLOPT_TIMEOUT => 20]);
if ($payload !== null) curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload, JSON_THROW_ON_ERROR));
$raw = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($raw === false) throw new RuntimeException('Network error or timeout; order outcome may be unknown.');
$body = json_decode($raw, true);
if (!is_array($body)) throw new RuntimeException('Non-JSON API response (HTTP ' . $status . ').');
if ($status < 200 || $status >= 300 || ($body['ok'] ?? null) !== true || !array_key_exists('data', $body)) {
$code = $body['error']['code'] ?? '';
$safeCode = is_string($code) && preg_match('/^[A-Z][A-Z0-9_]{0,63}$/D', $code) ? ': ' . $code : '';
throw new RuntimeException('API request failed (HTTP ' . $status . ')' . $safeCode);
}
return $body['data'];
}
try {
$action = $argv[1] ?? 'balance';
$arg = $argv[2] ?? '';
$payload = null;
if (in_array($action, ['balance', 'catalog'], true) && count($argv) <= 2) {
$path = '/' . $action;
} elseif (in_array($action, ['products', 'status'], true) && $arg !== '' && count($argv) === 3) {
$path = ($action === 'products' ? '/catalog/' : '/order/') . rawurlencode($arg);
} elseif ($action === 'order' && $arg !== '' && count($argv) === 3) {
$raw = @file_get_contents($arg);
$payload = $raw === false ? null : json_decode($raw);
if (!is_object($payload) || !isset($payload->game_key) || !is_string($payload->game_key) || $payload->game_key === '') {
throw new RuntimeException('Provide an order JSON object with a catalog game_key.');
}
$path = '/order';
} else {
throw new RuntimeException('Usage: php ludovex.php [balance|catalog|products GAME_KEY|order order.json|status ORDER_ID]');
}
$data = requestApi($action === 'order' ? 'POST' : 'GET', $path, $payload);
// Never log delivered codes, passwords or the order payload.
if (in_array($action, ['order', 'status'], true)) $data = ['id' => $data['id'] ?? null, 'status' => $data['status'] ?? null];
echo json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR) . PHP_EOL;
} catch (Throwable $error) {
fwrite(STDERR, ($error instanceof RuntimeException ? $error->getMessage() : 'Cannot complete the request.') . PHP_EOL);
fwrite(STDERR, "For an uncertain order, retry only the SAME saved payload and LUDOVEX_ORDER_KEY. HTTP 201 is not delivery.\n");
exit(1);
}
3. Create a real order only when you are ready
- Create order.json from the real catalog. Keep the exact game_key for the chosen region. Standard products use the returned variation_id and required inputs; Steam custom top-ups use the amount and currency fields in the API reference. Check the live price and balance. Do not include sandbox IDs or scenario.
- Set LUDOVEX_ORDER_KEY to a unique value for this order. Generate and save it in your application before the first attempt; keep it with the exact JSON payload.
- Only the following explicit command sends POST /order and can spend real balance:
php ludovex.php order order.json
On a timeout, retry manually with the same order.json and LUDOVEX_ORDER_KEY. Use a new key only for a new order. HTTP 201 means created, not delivered. Check status or a verified webhook: PROCESSING is pending, COMPLETED is successful, and FAILED or REFUNDED need separate handling. The scripts do not retry or poll automatically.
Receive and verify webhooks
Copy a PHP, Python or Node.js receiver. It checks the signature and saves verified events in a durable inbox before acknowledging them.
These are server-side examples for real Ludovex webhooks. The sandbox does not send requests to your server. No secret is entered or code executed on this page.
1. Prepare the receiver
PHP 8.1 or newer with PDO SQLite.
Save as ludovex-webhook.php. No Composer packages are required.
In your dashboard webhook settings, copy the endpoint signing secret into WEBHOOK_SECRET on your server. Use the entire value literally; it is different from your API key.
export WEBHOOK_SECRET='YOUR_WEBHOOK_SECRET'
export WEBHOOK_INBOX_DIR='/absolute/private/ludovex-webhooks'Use a private persistent directory outside the public web root. Keep the database across restarts and deployments. Use one inbox per configured webhook endpoint; never log the secret or raw event data.
2. Run and connect it
Save the selected file, set the environment variables, and start this local development listener:
php -S 127.0.0.1:3001 ludovex-webhook.phpFor production, use a supported application server behind HTTPS and forward POST /webhooks/ludovex to this receiver without changing its body. A localhost address cannot receive Ludovex deliveries.
Save your public HTTPS endpoint in the dashboard and press Test. The signed test event is accepted without fulfilling an order. Use the real endpoint secret, not a sandbox secret.
Open webhook settingsludovex-webhook.php
<?php
declare(strict_types=1);
// PHP 8.1+ with PDO SQLite. Run behind an HTTPS reverse proxy, outside a public document root.
// This receiver only commits an inbox. A separate worker must apply business effects idempotently.
ini_set('display_errors', '0');
ini_set('log_errors', '0');
umask(0077);
const BODY_LIMIT = 1048576;
const KNOWN_EVENTS = ['order.completed', 'order.failed', 'order.refunded', 'payment.succeeded', 'order.action_required'];
function respond(int $status): never {
http_response_code($status);
header('Content-Length: 0');
header('Cache-Control: no-store');
header('Connection: close');
exit;
}
try {
if (($_SERVER['REQUEST_URI'] ?? '') !== '/webhooks/ludovex') respond(404);
if (($_SERVER['REQUEST_METHOD'] ?? '') !== 'POST') respond(405);
$secret = getenv('WEBHOOK_SECRET') ?: '';
// Use the entire whsec_ value from your webhook settings, not an API key or decoded bytes.
if (!preg_match('/^whsec_[A-Za-z0-9]{40}$/D', $secret)) respond(500);
$length = $_SERVER['CONTENT_LENGTH'] ?? '';
if (!preg_match('/^[0-9]{1,10}$/D', $length)) respond(411);
if ((int) $length > BODY_LIMIT) respond(413);
if (($_SERVER['HTTP_CONTENT_ENCODING'] ?? 'identity') !== 'identity') respond(415);
if (!preg_match('/^application\/json(?:\s*;.*)?$/iD', $_SERVER['CONTENT_TYPE'] ?? '')) respond(415);
$raw = file_get_contents('php://input', false, null, 0, BODY_LIMIT + 1);
if ($raw === false || strlen($raw) !== (int) $length) respond(400);
if (strlen($raw) > BODY_LIMIT) respond(413);
$timestamp = $_SERVER['HTTP_X_LUDOVEX_TIMESTAMP'] ?? '';
$signature = $_SERVER['HTTP_X_LUDOVEX_SIGNATURE'] ?? '';
if (!preg_match('/^[0-9]{10}$/D', $timestamp) || abs(time() - (int) $timestamp) > 300
|| !preg_match('/^sha256=[a-f0-9]{64}$/D', $signature)) respond(401);
$expected = hash_hmac('sha256', $timestamp . '.' . $raw, $secret);
if (!hash_equals($expected, substr($signature, 7))) respond(401);
$event = json_decode($raw);
if (!is_object($event) || !isset($event->event) || !is_string($event->event)
|| $event->event === '' || strlen($event->event) > 100 || !isset($event->data) || !is_object($event->data)) respond(400);
$hash = hash('sha256', $raw);
$kind = $event->event === 'test' ? 'test' : (in_array($event->event, KNOWN_EVENTS, true) ? 'known' : 'unknown');
// Dashboard test events are signed but have no delivery ID.
$id = $kind === 'test' ? 'test:' . $hash : ($_SERVER['HTTP_X_LUDOVEX_DELIVERY_ID'] ?? '');
if ($kind !== 'test' && !preg_match('/^[1-9][0-9]{0,19}$/D', $id)) respond(400);
$directory = getenv('WEBHOOK_INBOX_DIR') ?: __DIR__ . '/private-webhooks';
if (is_link($directory) || (!is_dir($directory) && !mkdir($directory, 0700, true))) respond(503);
if ((fileperms($directory) & 0077) !== 0) respond(503);
$file = $directory . '/inbox.sqlite';
if (is_link($file)) respond(503);
$db = new PDO('sqlite:' . $file, null, null, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
if (!chmod($file, 0600)) respond(503);
$db->exec('PRAGMA busy_timeout=1000; PRAGMA synchronous=FULL');
$db->exec('CREATE TABLE IF NOT EXISTS inbox (delivery_id TEXT PRIMARY KEY, payload_hash TEXT NOT NULL UNIQUE,
event TEXT NOT NULL, kind TEXT NOT NULL, payload BLOB NOT NULL, received_at INTEGER NOT NULL, processed_at INTEGER)');
$db->exec('BEGIN IMMEDIATE');
try {
$find = $db->prepare('SELECT payload_hash FROM inbox WHERE delivery_id = ?');
$find->execute([$id]); $stored = $find->fetchColumn();
if ($stored !== false && $stored !== $hash) { $db->exec('ROLLBACK'); respond(409); }
// Delivery ID is not signed: unique body hashes also stop replay with a changed ID.
$insert = $db->prepare('INSERT OR IGNORE INTO inbox (delivery_id,payload_hash,event,kind,payload,received_at) VALUES (?,?,?,?,?,?)');
$insert->bindValue(1, $id); $insert->bindValue(2, $hash); $insert->bindValue(3, $event->event);
$insert->bindValue(4, $kind); $insert->bindValue(5, $raw, PDO::PARAM_LOB); $insert->bindValue(6, time(), PDO::PARAM_INT);
$insert->execute();
$db->exec('COMMIT');
} catch (Throwable $error) {
if ($db->inTransaction()) $db->rollBack();
respond(503);
}
// Never execute business actions here, including for test or unknown events.
respond(204);
} catch (Throwable $error) {
respond(503); // No raw body, signature, database error or secret in the response/log.
}
What is verified
X-Ludovex-Signature must match sha256= plus HMAC-SHA256 of timestamp + a dot + the exact raw request bytes. The receiver uses constant-time comparison and rejects timestamps more than 5 minutes in the past or future. Keep your server clock synchronized.
X-Ludovex-Delivery-Id stays the same on a retry, but is not part of the signature. The inbox checks both the delivery ID and body hash, so the same signed body is not queued again under a changed ID.
Receiving is the first step
HTTP 204 means the verified event is safely stored, not that your business action is finished. Add a background worker for pending inbox rows, make each business action idempotent, and mark it processed in the same database transaction. Test and unknown events must never credit a balance or fulfil an order.
Invalid signatures are rejected; database failures return HTTP 503 so delivery can be retried. Do not return success before durable storage. For multiple servers, use a shared transactional database and a unique event key.
Synthetic catalogue, test balance and simulated orders. These fixtures are not a simulation of every production endpoint. No real money, provider calls or external webhook delivery.
Temporary test session
Use this page’s Create session button to connect the sandbox automatically. It supplies a temporary test key in memory; you do not need to paste a key.
Create a session to try session-protected operations.
Executing POST /sessions below creates a separate session. Use the page button above for automatic connection.
Endpoint names, schema fields and the Swagger viewer’s technical controls use the API’s English terminology.
Open this OpenAPI JSONLoading the API reference…