📘 API 文档
将石头剪刀布游戏引擎集成到你自己的产品中。
🔑 身份认证
每个请求都必须携带代理的 API 密钥。可作为 Bearer 令牌或自定义请求头发送:
Authorization: Bearer rk_your_api_key_here X-API-Key: rk_your_api_key_here ?api_key=rk_your_api_key_here (查询参数,仅供快速测试)
基础地址: http://alihub.net
🧩 模式说明
- One API key belongs to one agent. Players created with that key are attached to the agent (users.agent_id / api_key_id).
- An agent can only read and act on its own players. Every endpoint that targets a player requires user_id and validates ownership.
- Game tables are global — any player on the network can join any open table. The commission still settles to the winning player's own agent.
- Settlement is automatic and server-side: once both players have a move, the round resolves even if nobody is watching.
💰 手续费
| 项目 | 由谁设置 | 计费对象 |
|---|---|---|
| 平台手续费 (3.00%) | 管理员 | 赢家盈利 |
| 代理佣金 | 代理(按 API 密钥) | 赢家盈利 |
| 提现手续费 (0.00%) | 管理员 | 提现金额 |
Winner profit equals the opponent's stake. The winner receives the full pot minus both fees; both stakes are escrowed when the players commit.
🎮 接口列表
账户
Returns the calling agent, key status, player count and total commission earned.
curl -H "Authorization: Bearer rk_your_api_key_here" http://alihub.net/api/v1/me
Creates a player owned by this agent.
curl -X POST http://alihub.net/api/v1/users \
-H "Authorization: Bearer rk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{"username":"alice","password":"secret123","email":"[email protected]","name":"Alice"}'
| 字段 | 必填 | 说明 |
|---|---|---|
| username | ✅ | 3-32 个字符:字母、数字和下划线。 |
| password | ✅ | 至少 6 个字符。 |
| — | 填写时必须唯一。 | |
| name | — | 显示名称,默认为用户名。 |
Profile, balance, win/loss record and lifetime wagered volume for one of your players.
资金
Current USDT balance. Omit user_id to read the agent's own balance.
Creates a hosted NowPayments invoice for a player. Redirect the player to invoice_url to pay.
curl -X POST http://alihub.net/api/v1/deposits \
-H "Authorization: Bearer rk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{"user_id":42,"amount":25.00}'
# → {"success":true,"data":{"order_id":"API-42-A1B2C3D4E5","amount":"25.00","invoice_url":"https://nowpayments.io/payment/..."}}
The wallet is credited automatically when NowPayments confirms the payment via IPN.
Requests a payout. The amount is held immediately and an administrator reviews the request.
curl -X POST http://alihub.net/api/v1/withdrawals \
-H "Authorization: Bearer rk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{"user_id":42,"amount":50,"address":"TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE"}'
游戏玩法
Lists every open table on the network (not just your agent's tables).
Opens a table for one of your players. The stake is escrowed from their balance. An optional move can be submitted right away — the player does not need to stay connected.
curl -X POST http://alihub.net/api/v1/rooms \
-H "Authorization: Bearer rk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{"user_id":42,"bet":"10.00","move":"rock"}'
# → {"success":true,"data":{"room":{"id":7,"code":"A1B2C3D4","status":"open", ...}}}
Room state including both moves, the pot, fees and the winner. Accepts the numeric id or the room code.
Takes the challenger seat. The stake is locked from the joining player's balance. If both moves are already known the round settles at once.
Submits or changes a move (rock / paper / scissors). Returns the refreshed room state.
Top players by win rate across the whole network.
📡 实时通知与 Webhook
- POST /pusher/auth — channel authentication for the browser client (private/presence channels).
- channel lobby — event lobby.updated: {action, room_id} whenever a table is created, matched, cancelled or settled.
- channel room-{id} — events room.created / room.updated / room.settled / room.cancelled with the full public room state.
- POST /wallet/ipn — NowPayments server-to-server callback. Signed with the IPN secret (x-nowpayments-sig, sha512 HMAC).
⚠️ 响应格式与错误
{"success": true, "data": { ... }}
{"success": false, "error": "invalid_api_key", "message": "The API key is invalid or disabled."}
| HTTP | 错误码 | 含义 |
|---|---|---|
| 401 | missing_api_key / invalid_api_key | The API key is missing, wrong or disabled. |
| 403 | forbidden_user | That player does not belong to your API key. |
| 404 | user_not_found / room_not_found | No such player or table. |
| 422 | insufficient_balance / bet_below_minimum / invalid_move / room_not_open … | The request was understood but could not be completed. |
| 502 / 503 | invoice_failed / payments_disabled | NowPayments is not configured or unreachable. |
🚀 快速开始
- Sign in and open the API Keys page to generate a key.
- Create a player with POST /api/v1/users.
- Fund the player: create an invoice, or credit manually from the admin panel.
- Open a table for the player, let an opponent join from anywhere, and read the settled result.