Partner API
Top up ROS LD diamonds to any Player ID from your own server. Diamonds arrive in the player's in-game Mail at once (the player taps Claim). Every top-up is added to what you owe; pay it from the dashboard with ABA KHQR whenever you like, and before you reach your credit limit.
ភាសាខ្មែរ៖ API នេះសម្រាប់ម៉ាស៊ីនមេរបស់អ្នក។ ផ្ញើ Player ID កញ្ចប់ និង ref (លេខបញ្ជាទិញរបស់អ្នក) ហើយពេជ្រនឹងចូលប្រអប់សំបុត្ររបស់អ្នកលេងភ្លាមៗ។
- Base URL:
https://platform.banteaystudio.com/api/v1 - JSON in, JSON out (
Content-Type: application/json), UTF-8. - Money is always in US cents (integers):
80= $0.80. - Times are unix seconds.
Authentication
Create an API key in the dashboard (API keys → Create key). It is shown once; we only keep a fingerprint. Send it in every request:
Authorization: Bearer rldp_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
- Keep keys on your server. Never put a key in a mobile app, a web page or a public repository.
- Up to 5 active keys (for example one per server). Revoke a key in the dashboard and it stops at once.
- Optional IP allow-list in the dashboard: when set, keys only work from those addresses.
- Keys work only while your partner account is approved. A suspended account gets
403 partner_suspended.
Money and credit
- Every pack has a store price; your price (
cost_cents) is the store price minus your partner discount.GET /packsshows both. - owed = all your top-up costs − all your payments. Payments are made in the dashboard with ABA KHQR (or recorded by us when you pay another way).
- A top-up is refused with
402 credit_limitwhenowed + costwould go over your credit limit. Nothing is sent and nothing is charged. Pay, then send the same request again. - If you pay more than you owe, the rest is credit for later top-ups.
Idempotency: ref
Every top-up carries ref: your own order id, 1–64 characters A-Z a-z 0-9 . _ : -,
unique within your account. It makes retries safe:
- Same
ref, same player and pack again →200with the first top-up and"duplicate": true. Diamonds are not sent twice. - Same
refwith another player or pack →409 ref_used. - On a timeout or
502, callGET /topups/{ref}:200= it was sent,404= it was not; then retry with the same ref.
Endpoints
GET/api/v1/packs
The diamond packs and what each costs you.
{"packs": [
{"id": "d10000", "diamonds": 10000, "price_cents": 100, "cost_cents": 80},
{"id": "d100000", "diamonds": 100000, "price_cents": 900, "cost_cents": 720},
{"id": "d1000000", "diamonds": 1000000, "price_cents": 8000, "cost_cents": 6400}
]}
GET/api/v1/players/{player_id}
Check a Player ID and get the in-game name, to show your customer before they pay you. Always do this first: a wrong ID is the most common mistake.
GET /api/v1/players/100003
→ 200 {"id": 100003, "nickname": "Carol"}
→ 404 {"error": "player_not_found", "message": "No player has this ID."}
POST/api/v1/topups
Send a pack to a player. The diamonds are mailed at once.
| Field | Type | Meaning |
|---|---|---|
player_id | number | The player's Player ID (in game: profile). |
pack | string | A pack id from GET /packs, e.g. d10000. |
ref | string | Your own order id, unique per top-up (see ref). |
POST /api/v1/topups
{"player_id": 100003, "pack": "d10000", "ref": "order-1001"}
→ 201 Created
{"order_id": 512, "ref": "order-1001", "player_id": 100003, "nickname": "Carol",
"pack": "d10000", "diamonds": 10000, "price_cents": 100, "cost_cents": 80,
"status": "sent", "duplicate": false, "created": 1764651000}
GET/api/v1/topups/{ref}
One top-up by your ref (same fields as above). 404 not_found = no top-up was sent with this ref.
GET/api/v1/topups?limit=50&before={order_id}
Your top-ups, newest first. limit 1–200 (default 50). For the next page pass
before = the next_before of the answer.
{"topups": [ {...}, {...} ], "next_before": 498}
GET/api/v1/balance
{"owed_cents": 2400, "credit_limit_cents": 10000, "available_cents": 7600, "share": 20}
share is your discount in percent. owed_cents below zero means you have credit.
Errors
Every error is JSON: {"error": "code", "message": "words for people"}. Act on error; show message.
| HTTP | error | What to do |
|---|---|---|
| 400 | bad_request, bad_ref, bad_pack, bad_player_id | Fix the request. |
| 401 | unauthorized | Key missing, wrong or revoked. |
| 402 | credit_limit | Over your credit limit (owed_cents, limit_cents in the answer). Pay with KHQR, then retry. |
| 403 | partner_suspended, not_approved, ip_not_allowed | Contact us / check your IP allow-list. |
| 404 | player_not_found, not_found | Wrong Player ID / no such top-up. |
| 409 | ref_used | This ref belongs to another top-up: use a new ref. |
| 429 | slow_down | Too many calls; wait (Retry-After header). |
| 502 | game_unavailable, game_error | Check GET /topups/{ref}, then retry with the same ref. |
Rate limits
- 120 requests a minute per key, of which at most 30 top-ups.
- Over the limit:
429 slow_downwithRetry-After: 60. - Top-ups of one account run one at a time; send them in order rather than all at once.
Full examples
KEY="rldp_…" # from the dashboard, keep it secret
BASE=https://platform.banteaystudio.com/api/v1
# 1. check the player
curl -s -H "Authorization: Bearer $KEY" $BASE/players/100003
# 2. top up (same ref = safe to retry)
curl -s -X POST $BASE/topups \
-H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
-d '{"player_id":100003,"pack":"d10000","ref":"order-1001"}'
# 3. after a timeout: was it sent?
curl -s -H "Authorization: Bearer $KEY" $BASE/topups/order-1001
// Node.js 18+ (built-in fetch)
const BASE = 'https://platform.banteaystudio.com/api/v1';
const KEY = process.env.RLDP_KEY;
async function call(method, path, body) {
const res = await fetch(BASE + path, {
method,
headers: { Authorization: `Bearer ${KEY}`, 'Content-Type': 'application/json' },
body: body ? JSON.stringify(body) : undefined,
});
const data = await res.json();
return { status: res.status, data };
}
async function topUp(playerId, pack, ref) {
const player = await call('GET', `/players/${playerId}`);
if (player.status !== 200) throw new Error(player.data.message);
try {
const r = await call('POST', '/topups', { player_id: playerId, pack, ref });
if (r.status === 201 || r.status === 200) return r.data; // sent (200 = sent before)
if (r.status !== 502) throw new Error(`${r.data.error}: ${r.data.message}`);
} catch (e) {
if (!(e instanceof TypeError)) throw e; // TypeError = network problem
}
const check = await call('GET', `/topups/${encodeURIComponent(ref)}`);
if (check.status === 200) return check.data; // it was sent
throw new Error('Not sent, safe to retry with the same ref');
}
topUp(100003, 'd10000', 'order-1001').then(console.log, console.error);
<?php
// PHP 7.4+ with curl
const BASE = 'https://platform.banteaystudio.com/api/v1';
$key = getenv('RLDP_KEY');
function rldp($method, $path, $body = null) {
global $key;
$ch = curl_init(BASE . $path);
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => ["Authorization: Bearer $key", 'Content-Type: application/json'],
]);
if ($body !== null) curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
$raw = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return [$status, json_decode($raw ?: '{}', true)];
}
[$s, $player] = rldp('GET', '/players/100003');
if ($s !== 200) exit($player['message']);
echo "Top up for {$player['nickname']}\n";
[$s, $r] = rldp('POST', '/topups', ['player_id' => 100003, 'pack' => 'd10000', 'ref' => 'order-1001']);
if ($s === 201 || $s === 200) {
echo "Sent {$r['diamonds']} diamonds, cost {$r['cost_cents']} cents\n";
} elseif ($s === 402) {
echo "Credit limit reached: pay with KHQR in the dashboard\n";
} else {
[$s2, $check] = rldp('GET', '/topups/order-1001'); // was it sent?
echo $s2 === 200 ? "Sent\n" : "Not sent: {$r['message']}\n";
}
Go-live checklist
- Look up the Player ID and show the nickname to your customer before taking their money.
- Use a unique
refper order (your own order number) and keep it. - On timeouts / 502, check
GET /topups/{ref}before retrying; retry with the same ref. - Watch
GET /balanceand pay with KHQR before you reach your limit. - Set the IP allow-list to your server's address.
- Questions: Telegram.