📘 API Docs
Integrate the Rock · Paper · Scissors engine into your own product.
🔑 Authentication
Every request must carry the API key of an agent. Send it as a bearer token or a custom header:
Authorization: Bearer rk_your_api_key_here X-API-Key: rk_your_api_key_here ?api_key=rk_your_api_key_here (query string, for quick tests only)
Base URL: http://alihub.net
🧩 How the model works
- 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.
💰 Fees
| Item | Who sets it | Charged on |
|---|---|---|
| Platform fee (3.00%) | Administrator | Winner profit |
| Agent commission | Agent (per API key) | Winner profit |
| Withdrawal fee (0.00%) | Administrator | Payout amount |
Winner profit equals the opponent's stake. The winner receives the full pot minus both fees; both stakes are escrowed when the players commit.
🎮 Endpoints
Account
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"}'
| Field | Required | Notes |
|---|---|---|
| username | ✅ | 3-32 characters: letters, numbers and underscore. |
| password | ✅ | At least 6 characters. |
| — | Must be unique when provided. | |
| name | — | Display name, defaults to the username. |
Profile, balance, win/loss record and lifetime wagered volume for one of your players.
Money
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"}'
Gameplay
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.
📡 Realtime & webhooks
- 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).
⚠️ Response format & errors
{"success": true, "data": { ... }}
{"success": false, "error": "invalid_api_key", "message": "The API key is invalid or disabled."}
| HTTP | error | Meaning |
|---|---|---|
| 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. |
🚀 Quick start
- 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.