Skip to main content

Operations APIs — CCU, Rankings, Send Mail

Applies toGames whose live data Alogame shows on its own systems (Alogame Console, game landing page)
EndpointsgetCCU, getRankingTypes, getRanking, sendMail — implement the ones your Alogame Operations Manager asks for
CallerAlogame's backend only, server to server. Never a browser or the game client.
SignatureHMAC-SHA256 — same headers, same secret as your payment APIs
TransportPOST, Content-Type: application/json, UTF-8. The body is always a JSON object ({} when there are no parameters).
ResponseAlways 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 creates items — lock it down

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": { } }
errcodeMeaningUsed by
0Successall
1001Signature invalid, or x-timestamp outside the replay windowall
1002Invalid parameters (missing, wrong type, too long, out of range) — say which in msgall
2001sid does not existgetRanking, sendMail
2002uid does not exist on that sidsendMail
2003An item_id does not exist — list the bad ids in data.item_idssendMail
2004An amount is above what your game allows for that itemsendMail
2005Unknown ranking type, or a scope/period that type does not supportgetRanking
5000Internal 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​

FieldTypeMeaning
sidintegerGame server id — the id your game uses for that server (the one in your character list's server value, if it carries one)
uidstringCharacter (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 }
]
}
FieldTypeRequiredNotes
sidinteger✅
ccuinteger✅Players online right now, ≥ 0
server_namestring—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" }
]
}
]
}
FieldTypeRequiredNotes
typestring✅Your id for the ranking, [a-z0-9_], ≤ 32 chars. Never reuse an id for a different ranking.
namestring✅Display name, in the game's display language
subjectstring✅What is ranked: "role" (a character) or "guild"
value_labelstring✅Label for value, the number the ranking is ordered by
scopesstring[]✅Which scope values getRanking accepts: "all" (all servers merged into one ranking) and/or "server" (one server)
periodsstring[]✅Which period values it accepts: "current", and "previous" if you keep the last closed period
resetstring—"daily", "weekly", "monthly" or "event" if the ranking resets; omit for a ranking that never resets
max_limitinteger✅Largest limit you serve, 1–100
extra_fieldsarray✅The extra keys this ranking's entries carry, in display order; [] when none
extra_fields[].keystring✅Key inside each entry's extra
extra_fields[].labelstring✅Column title, in the game's display language
extra_fields[].typestring✅"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 }
FieldTypeRequiredNotes
typestring✅One of the types from getRankingTypes
scopestring✅"all" = all servers merged; "server" = the server in sid
sidinteger✅The server when scope is "server"; 0 when scope is "all"
periodstring✅"current" or "previous", as allowed by the type's periods
limitinteger✅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 }
}
]
}
}
FieldTypeRequiredNotes
typestring✅Echo of the requested type
updated_atinteger✅Unix seconds when this ranking was computed
period_start, period_endinteger—Unix seconds; send them for a ranking that resets
listarray✅Ordered by rank ascending; [] when nobody qualifies
rankinteger✅1-based, unique, no gaps. Ties are broken by your game's own rule.
valueinteger✅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.
sidinteger✅Server the subject belongs to (useful with scope: "all")
server_namestring—Display name of that server
extraobject✅Exactly the keys declared in the type's extra_fields; {} when none

Subject fields — depend on the type's subject:

subjectFieldsRequired
"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 }
]
}
FieldTypeRequiredNotes
request_idstring✅Unique per mail, ≤ 64 chars. See idempotency.
sidinteger✅Server of the character
uidstring✅Character id
subjectstring✅Mail title shown to the player. 1–50 characters (tell us if your limit differs).
contentstring✅Mail body shown to the player. 1–500 characters (tell us if your limit differs).
reasonstring✅Why the mail was sent, ≤ 200 characters. Not shown to the player — store it in your mail/item log for audits.
itemsarray—0–10 attachments. Absent or [] = text-only mail
items[].item_idstring✅ (per item)Your item id (as a string, even if numeric)
items[].amountinteger✅ (per item)≥ 1

Response data

{ "errcode": 0, "msg": "success", "data": { "mail_id": "M88001234" } }
FieldTypeNotes
mail_idstringYour 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:

  1. Before creating a mail, look up request_id. If a mail was already created for it, do not send again — answer errcode: 0 with the original mail_id.
  2. Keep request_id → mail_id for at least 30 days.
  3. Treat request_id as 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-timestamp exactly as your payment APIs do (Authentication), over the raw body.
  • Every answer is HTTP 200 + {errcode, msg, data}, using the errcode table above.
  • sid and uid are the same ids your character list API returns.
  • getRankingTypes lists every ranking you serve; getRanking accepts exactly the scopes, periods and limit each type declares, and fills extra with exactly its extra_fields.
  • sendMail is all-or-nothing and idempotent on request_id (kept ≥ 30 days).
  • sendMail is IP allow-listed and every call is logged with its reason.
  • 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.