✊ RockGame

📘 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

ItemWho sets itCharged on
Platform fee (3.00%)AdministratorWinner profit
Agent commissionAgent (per API key)Winner profit
Withdrawal fee (0.00%)AdministratorPayout 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

GET/api/v1/me

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
POST/api/v1/users

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"}'
FieldRequiredNotes
username✅3-32 characters: letters, numbers and underscore.
password✅At least 6 characters.
email—Must be unique when provided.
name—Display name, defaults to the username.
GET/api/v1/users/{id}

Profile, balance, win/loss record and lifetime wagered volume for one of your players.

Money

GET/api/v1/balance?user_id={id}

Current USDT balance. Omit user_id to read the agent's own balance.

POST/api/v1/deposits

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.

POST/api/v1/withdrawals

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

GET/api/v1/rooms

Lists every open table on the network (not just your agent's tables).

POST/api/v1/rooms

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", ...}}}
GET/api/v1/rooms/{id}

Room state including both moves, the pot, fees and the winner. Accepts the numeric id or the room code.

POST/api/v1/rooms/{id}/join

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.

POST/api/v1/rooms/{id}/move

Submits or changes a move (rock / paper / scissors). Returns the refreshed room state.

GET/api/v1/leaderboard

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."}
HTTPerrorMeaning
401missing_api_key / invalid_api_keyThe API key is missing, wrong or disabled.
403forbidden_userThat player does not belong to your API key.
404user_not_found / room_not_foundNo such player or table.
422insufficient_balance / bet_below_minimum / invalid_move / room_not_open …The request was understood but could not be completed.
502 / 503invoice_failed / payments_disabledNowPayments is not configured or unreachable.

🚀 Quick start

  1. Sign in and open the API Keys page to generate a key.
  2. Create a player with POST /api/v1/users.
  3. Fund the player: create an invoice, or credit manually from the admin panel.
  4. Open a table for the player, let an opponent join from anywhere, and read the settled result.