Operations APIs — CCU, Rankings, Send Mail
| Applies to | Games whose live data Alogame shows on its own systems (Alogame Console, game landing page) |
| Endpoints | getCCU, getRankingTypes, getRanking, sendMail — implement the ones your Alogame Operations Manager asks for |
| Caller | Alogame's backend only, server to server. Never a browser or the game client. |
| Signature | HMAC-SHA256 — same headers, same secret as your payment APIs |
| Transport | POST, Content-Type: application/json, UTF-8. The body is always a JSON object ({} when there are no parameters). |
| Response | Always HTTP 200 with an {errcode, msg, data} envelope; errcode: 0 is success. |
These APIs are independent of the payment flows: nothing here changes how
Web Payment or Mobile IAP work. They
use the same secret_key and the same signature as your payment APIs, so if
your server already verifies those, reuse that code.
Endpoint Registration
Send your Alogame Operations Manager one URL per API, for production and for dev/staging, as for the payment APIs. Each URL is stored as-is and called directly; the paths do not need to share a prefix.
# Production
getCCU: https://api.yourgame.com/<your-path>
getRankingTypes: https://api.yourgame.com/<your-path>
getRanking: https://api.yourgame.com/<your-path>
sendMail: https://api.yourgame.com/<your-path>
# Dev / Staging
getCCU: http://<dev-host>/<your-path>
getRankingTypes: http://<dev-host>/<your-path>
getRanking: http://<dev-host>/<your-path>
sendMail: http://<dev-host>/<your-path>
sendMail puts real items into a player's mailbox. Besides verifying the
signature on every call:
- Allow-list Alogame's source IPs on this endpoint (your Operations Manager gives you the list), and reject everything else.
- Log every call (
request_id,sid,uid, items, result) on your side. - Never expose this endpoint on the same host/port the game client talks to if you can avoid it.
Response envelope
Every answer is HTTP 200 with this body — the outcome is in errcode, not
in the HTTP status:
{ "errcode": 0, "msg": "success", "data": { } }
errcode | Meaning | Used by |
|---|---|---|
0 | Success | all |
1001 | Signature invalid, or x-timestamp outside the replay window | all |
1002 | Invalid parameters (missing, wrong type, too long, out of range) — say which in msg | all |
2001 | sid does not exist | getRanking, sendMail |
2002 | uid does not exist on that sid | sendMail |
2003 | An item_id does not exist — list the bad ids in data.item_ids | sendMail |
2004 | An amount is above what your game allows for that item | sendMail |
2005 | Unknown ranking type, or a scope/period that type does not support | getRanking |
5000 | Internal error — Alogame may retry (see idempotency) | all |
Use these exact codes so Alogame can show the right message to its operators.
Put a human-readable reason in msg.
Shared field names
| Field | Type | Meaning |
|---|---|---|
sid | integer | Game server id — the id your game uses for that server (the one in your character list's server value, if it carries one) |
uid | string | Character (role) id — the same id your character list returns as uid, so Alogame can pass one API's output straight into another |
API 1 — Get CCU
Current number of players online, per server. Alogame calls it at most once every 30 seconds and caches the answer.
Request body
{}
Response data — one entry per open server:
{
"errcode": 0,
"msg": "success",
"data": [
{ "sid": 1, "server_name": "S1 - Tề Thiên", "ccu": 1532 },
{ "sid": 2, "server_name": "S2 - Ngộ Không", "ccu": 874 }
]
}
| Field | Type | Required | Notes |
|---|---|---|---|
sid | integer | ✅ | |
ccu | integer | ✅ | Players online right now, ≥ 0 |
server_name | string | — | Display name; Alogame shows sid when absent |
For merged servers, return the merged server once, under the sid players
now log in to.
Rankings — how they work
Rankings are defined by your game, not by Alogame. You declare which
rankings exist — combat power, top-up, boss damage, guild, an event's
leaderboard — with getRankingTypes, and Alogame reads
any of them with getRanking by type. Adding a new ranking
later is a change on your side only: add it to getRankingTypes and Alogame's
Console and landing page can show it without any change on Alogame's side.
Every ranking entry has the same core fields (rank, the subject, value).
Anything specific to one ranking goes in extra, and getRankingTypes tells
Alogame how to label and display those fields.
API 2 — Get Ranking Types
The rankings your game offers. Alogame calls it when an operator opens the ranking screen and caches it for an hour.
Request body
{}
Response data
{
"errcode": 0,
"msg": "success",
"data": [
{
"type": "power",
"name": "Lực chiến",
"subject": "role",
"value_label": "Lực chiến",
"scopes": ["all", "server"],
"periods": ["current"],
"max_limit": 100,
"extra_fields": []
},
{
"type": "boss_damage",
"name": "Sát thương Boss Thế Giới",
"subject": "role",
"value_label": "Sát thương",
"scopes": ["server"],
"periods": ["current", "previous"],
"reset": "weekly",
"max_limit": 50,
"extra_fields": [
{ "key": "boss_name", "label": "Boss", "type": "string" },
{ "key": "kill_count", "label": "Số lần hạ", "type": "integer" }
]
},
{
"type": "guild_power",
"name": "Bang hội",
"subject": "guild",
"value_label": "Tổng lực chiến",
"scopes": ["all", "server"],
"periods": ["current"],
"max_limit": 100,
"extra_fields": [
{ "key": "member_count", "label": "Thành viên", "type": "integer" }
]
}
]
}
| Field | Type | Required | Notes |
|---|---|---|---|
type | string | ✅ | Your id for the ranking, [a-z0-9_], ≤ 32 chars. Never reuse an id for a different ranking. |
name | string | ✅ | Display name, in the game's display language |
subject | string | ✅ | What is ranked: "role" (a character) or "guild" |
value_label | string | ✅ | Label for value, the number the ranking is ordered by |
scopes | string[] | ✅ | Which scope values getRanking accepts: "all" (all servers merged into one ranking) and/or "server" (one server) |
periods | string[] | ✅ | Which period values it accepts: "current", and "previous" if you keep the last closed period |
reset | string | — | "daily", "weekly", "monthly" or "event" if the ranking resets; omit for a ranking that never resets |
max_limit | integer | ✅ | Largest limit you serve, 1–100 |
extra_fields | array | ✅ | The extra keys this ranking's entries carry, in display order; [] when none |
extra_fields[].key | string | ✅ | Key inside each entry's extra |
extra_fields[].label | string | ✅ | Column title, in the game's display language |
extra_fields[].type | string | ✅ | "string", "integer" or "number" |
API 3 — Get Ranking
One ranking, top limit entries. Alogame calls it at most once every 5
minutes per combination of parameters and caches the answer, so you may serve
it from your own periodically refreshed ranking.
Request body
{ "type": "power", "scope": "all", "sid": 0, "period": "current", "limit": 100 }
| Field | Type | Required | Notes |
|---|---|---|---|
type | string | ✅ | One of the types from getRankingTypes |
scope | string | ✅ | "all" = all servers merged; "server" = the server in sid |
sid | integer | ✅ | The server when scope is "server"; 0 when scope is "all" |
period | string | ✅ | "current" or "previous", as allowed by the type's periods |
limit | integer | ✅ | 1 to the type's max_limit. Return fewer if fewer entries exist. |
Response data
{
"errcode": 0,
"msg": "success",
"data": {
"type": "boss_damage",
"updated_at": 1793000000,
"period_start": 1792800000,
"period_end": 1793404800,
"list": [
{
"rank": 1,
"uid": "100234",
"role_name": "TềThiênĐạiThánh",
"sid": 2,
"server_name": "S2 - Ngộ Không",
"level": 120,
"faction_id": 3,
"faction_name": "Phương Thốn Sơn",
"value": 98765432,
"extra": { "boss_name": "Ngưu Ma Vương", "kill_count": 7 }
}
]
}
}
| Field | Type | Required | Notes |
|---|---|---|---|
type | string | ✅ | Echo of the requested type |
updated_at | integer | ✅ | Unix seconds when this ranking was computed |
period_start, period_end | integer | — | Unix seconds; send them for a ranking that resets |
list | array | ✅ | Ordered by rank ascending; [] when nobody qualifies |
rank | integer | ✅ | 1-based, unique, no gaps. Ties are broken by your game's own rule. |
value | integer | ✅ | The number the ranking is ordered by (combat power, amount, damage…). Must not exceed 9007199254740991 (2⁵³−1); if it can, tell us and send it as a decimal string instead. |
sid | integer | ✅ | Server the subject belongs to (useful with scope: "all") |
server_name | string | — | Display name of that server |
extra | object | ✅ | Exactly the keys declared in the type's extra_fields; {} when none |
Subject fields — depend on the type's subject:
subject | Fields | Required |
|---|---|---|
"role" | uid (string), role_name (string) | ✅ |
"role" | level (integer), faction_id (integer), faction_name (string) — the character's level and faction (môn phái) | send them whenever your game has them |
"guild" | guild_id (string), guild_name (string) | ✅ |
"guild" | leader_uid (string), leader_name (string) | — |
Example — the personal combat-power ranking across all servers is
{"type": "power", "scope": "all", "sid": 0, "period": "current", "limit": 100},
and each entry carries rank, role_name, faction_name, level, value
(the combat power) and server_name.
A type you do not offer, or a scope/period it does not support, is
errcode: 2005. An unknown sid is 2001. A limit outside 1–max_limit
is 1002.
API 4 — Send Mail
Sends an in-game mail, optionally with item attachments, to one character. Alogame's operators use it for compensation, event rewards and support cases; Alogame sends one call per character.
Request body
{
"request_id": "ops-20261026-000123",
"sid": 2,
"uid": "100234",
"subject": "Bồi thường bảo trì",
"content": "Cảm ơn bạn đã kiên nhẫn chờ trong thời gian bảo trì.",
"reason": "Maintenance compensation 26/10 — ticket #4521",
"items": [
{ "item_id": "200101", "amount": 100 },
{ "item_id": "300512", "amount": 2 }
]
}
| Field | Type | Required | Notes |
|---|---|---|---|
request_id | string | ✅ | Unique per mail, ≤ 64 chars. See idempotency. |
sid | integer | ✅ | Server of the character |
uid | string | ✅ | Character id |
subject | string | ✅ | Mail title shown to the player. 1–50 characters (tell us if your limit differs). |
content | string | ✅ | Mail body shown to the player. 1–500 characters (tell us if your limit differs). |
reason | string | ✅ | Why the mail was sent, ≤ 200 characters. Not shown to the player — store it in your mail/item log for audits. |
items | array | — | 0–10 attachments. Absent or [] = text-only mail |
items[].item_id | string | ✅ (per item) | Your item id (as a string, even if numeric) |
items[].amount | integer | ✅ (per item) | ≥ 1 |
Response data
{ "errcode": 0, "msg": "success", "data": { "mail_id": "M88001234" } }
| Field | Type | Notes |
|---|---|---|
mail_id | string | Your id for the mail that was created |
All or nothing. If anything is wrong — unknown sid/uid, an unknown
item_id, an amount over your limit, text too long — send nothing and
answer the matching errcode. Never deliver part of the attachments.
Idempotency
Alogame retries a call that timed out or answered 5000, with the same
request_id and the same body. Your server must:
- Before creating a mail, look up
request_id. If a mail was already created for it, do not send again — answererrcode: 0with the originalmail_id. - Keep
request_id→mail_idfor at least 30 days. - Treat
request_idas opaque; it is unique across all servers of your game.
Answer within 10 seconds. A slower answer counts as a timeout and is retried, which is safe only if step 1 is in place.
Implementation checklist
- All endpoints verify
x-signature/x-timestampexactly as your payment APIs do (Authentication), over the raw body. - Every answer is HTTP
200+{errcode, msg, data}, using theerrcodetable above. -
sidanduidare the same ids your character list API returns. -
getRankingTypeslists every ranking you serve;getRankingaccepts exactly thescopes,periods andlimiteach type declares, and fillsextrawith exactly itsextra_fields. -
sendMailis all-or-nothing and idempotent onrequest_id(kept ≥ 30 days). -
sendMailis IP allow-listed and every call is logged with itsreason. - Dev/staging URLs registered first; Alogame tests against them before production.
Please confirm with your Alogame Operations Manager: which ranking types
you will offer at launch (at least power); your real limits for
subject/content length, attachments per mail and maximum amount per
item; how often each ranking is refreshed; and whether attached items are
bound to the character.