๐ฎ Player Test Access
Test Account Credentials (Ready to Use)
Endpoint
http://SERVER_IP:5018/api/loginPlayer
Username
player01
Password
Player@123
Balance
1500 points
Token will auto-fill in all test forms below
๐ Overview
FairDealPlus Go Server runs on port
All protected routes require a JWT token in the
5018. It provides REST HTTP APIs and a WebSocket endpoint.All protected routes require a JWT token in the
Authorization: Bearer <token> header.
Base URL:
WebSocket:
Content-Type:
http://SERVER_IP:5018WebSocket:
ws://SERVER_IP:5018/wsContent-Type:
application/json
โ ๏ธ Unity tip: Use
UnityWebRequest for REST APIs and WebSocket or NativeWebSocket package for real-time game events.
๐ Authentication
POST
/api/login
Public
Admin / Agent login
| Field | Type | Note |
|---|---|---|
| userName | string | required |
| password | string | required |
Response
{ "success": true, "token": "eyJhbGci..." }
โก Live Test
POST
/api/loginPlayer
Public
Player login (Unity uses this)
| Field | Type | Note |
|---|---|---|
| userName | string | required |
| password | string | required |
| devicename | string | optional Android / iOS / PC |
Response
{ "success": true, "token": "eyJhbGci..." }
โ
Use this token in all subsequent requests as
Authorization: Bearer TOKENโก Live Test
POST
/api/register
๐ Auth Required
Create new user (Admin only)
| Field | Type | Note |
|---|---|---|
| userName | string | required unique |
| password | string | required |
| referralId | UUID | required parent user UUID |
| role | string | optional player/agent/distributor/superAdmin |
| creditPoint | number | optional starting balance |
| commissionPercentage | number | optional |
โก Live Test
POST
/api/setForgetPassword
Public
Reset password via OTP
| Field | Type | Note |
|---|---|---|
| userName | string | required |
| mobile | string | required |
| newPassword | string | required |
| otp | string | optional |
{ "success": true, "message": "Password updated" }
๐ค Player APIs
All routes under /api/player/* require JWT token. Send as: Authorization: Bearer TOKEN
GET
/api/player/me
๐ Auth
Get my profile + balance
Response Fields
| Field | Type | Description |
|---|---|---|
| id | UUID | Player UUID |
| userName | string | Username |
| role | string | player / agent / superAdmin |
| creditPoint | number | ๐ฐ Current balance |
| isActive | bool | Account active status |
| type | string | RV or TN (commission mode) |
{
"success": true,
"data": {
"id": "035e2653-50a1-4c68-977b-ffc25badcede",
"userName": "player01",
"role": "player",
"creditPoint": 1500,
"isActive": true,
"isLogin": true,
"type": "RV"
}
}
โก Live Test
GET
/api/player/bets?page=1&limit=20
๐ Auth
Player bet history
| Query Param | Type | Default |
|---|---|---|
| page | int | 1 |
| limit | int | 20 (max 100) |
{
"bets": [
{ "id": "uuid", "game": "rouletteTimer40", "betAmount": 100,
"wonAmount": 3600, "winPosition": "7", "createdAt": "..." }
],
"page": 1, "limit": 20
}
โก Live Test
GET
/api/player/wins?game=rouletteTimer40&limit=15
๐ Auth
Last game results (hot/cold data)
| Query Param | Type | Note |
|---|---|---|
| game | string | required game name |
| limit | int | default 15 |
{
"game": "rouletteTimer40",
"results": ["26", "3", "11", "0", "36"],
"x": [1, 1, 1, 1, 1]
}
โก Live Test
POST
/api/player/point-request
๐ Auth
Request points (deposit/withdraw)
| Field | Type | Note |
|---|---|---|
| point | number | required |
| comment | string | optional reason |
| fromId | UUID | optional agent UUID |
{ "message": "Point request submitted", "requestId": "uuid" }
โก Live Test
POST
/api/player/updatePassword
๐ Auth
Change password
| Field | Type | |
|---|---|---|
| oldPassword | string | required |
| newPassword | string | required |
POST
/api/player/logout
๐ Auth
Logout player
{ "success": true, "message": "Logged out" }
๐ก๏ธ Admin APIs
Requires admin/agent/distributor/superAdmin JWT token.
GET
/api/admin/online
๐ Admin
Get online players list
{ "count": 5, "players": [{ "id":"...", "userName":"player01", "creditPoint": 1500 }] }
โก Live Test
GET
/api/admin/stats?game=spinToWin
๐ Admin
Game stats โ collection vs payment
{
"gameName": "spinToWin",
"totalCollection": 50000,
"totalPayment": 43200,
"lastResults": ["3","7","1"],
"xs": [1,1,1]
}
โก Live Test
GET
/api/admin/users?role=player&page=1
๐ Admin
List all users
| Param | Type | Note |
|---|---|---|
| role | string | player/agent/distributor (optional filter) |
| page | int | default 1, 50 per page |
โก Live Test
POST
/api/admin/user/:id/balance
๐ Admin
Update player balance
| Field | Type | Note |
|---|---|---|
| amount | number | required |
| op | string | "add" (default) or "set" |
POST
/api/admin/user/:id/toggle
๐ Admin
Block/unblock player account
{ "isActive": false }
โก WebSocket Connection
URL:
All WebSocket messages are JSON in this format:
Client โ Server:
Server โ Client:
ws://SERVER_IP:5018/wsAll WebSocket messages are JSON in this format:
Client โ Server:
{ "event": "eventName", "data": { ... } }Server โ Client:
{ "event": "eventName", "data": { ... }, "status": 1 }
Unity Package: Use NativeWebSocket โ
WebSocket ws = new WebSocket("ws://SERVER_IP:5018/ws");
Unity Connection Code Example
// 1. Connect
WebSocket ws = new WebSocket("ws://SERVER_IP:5018/ws");
await ws.Connect();
// 2. Send event
string msg = JsonConvert.SerializeObject(new {
@event = "join",
data = new { token = playerToken, gameName = "rouletteTimer40" }
});
await ws.SendText(msg);
// 3. Receive
ws.OnMessage += (bytes) => {
var text = System.Text.Encoding.UTF8.GetString(bytes);
var msg = JsonConvert.DeserializeObject<SocketMsg>(text);
Debug.Log($"Event: {msg.@event}, Data: {msg.data}");
};
๐ค Client โ Server Events
WS
join
Join a game room โ FIRST event to send
| Field | Type | Note |
|---|---|---|
| token | string | required JWT token from login |
| gameName | string | required see game list below |
// Send:
{ "event": "join", "data": { "token": "eyJ...", "gameName": "rouletteTimer40" } }
// Response event: "join"
{
"event": "join",
"data": {
"creditPoint": 1500,
"gameName": "rouletteTimer40",
"gamelastdata": ["26","3","11","7","0"],
"x": [1,1,1,1,1],
"gameState": { "positions": {}, "adminBalance": 0 }
},
"status": 1
}
WS
checkLogin
Verify token without joining room
{ "event": "checkLogin", "data": { "token": "eyJ..." } }
WS
placeBet
Place bet on timer games (roulette40/60, spinToWin, etc.)
| Field | Type | Note |
|---|---|---|
| playerId | UUID | required |
| gameName | string | required |
| betPoint | number | required total bet amount |
| position | object | required { "7": 100, "red": 50 } |
// Send:
{
"event": "placeBet",
"data": {
"playerId": "035e2653-50a1-4c68-977b-ffc25badcede",
"gameName": "rouletteTimer40",
"betPoint": 150,
"position": { "7": 100, "red": 50 }
}
}
// Response event: "placeBet"
{ "event": "placeBet", "data": { "handId": "bet-uuid", "gameName": "rouletteTimer40", "result": "Bet placed successfully" }, "status": 1 }
WS
placeBetAB
Andar Bahar bet
| Field | Type | Note |
|---|---|---|
| playerId | UUID | required |
| gameName | string | "andarBahar" |
| betPoint | number | required |
| position | object | { "side": "A" } or { "side": "B" } |
| round | int | 1 or 2 |
{ "event": "placeBetAB", "data": { "playerId": "...", "gameName": "andarBahar", "betPoint": 100, "position": { "side": "A" }, "round": 1 } }
WS
placeBetRoulette
Manual roulette โ instant result
// Send:
{ "event": "placeBetRoulette", "data": { "playerId": "...", "betPoint": 200, "position": { "7": 100, "red": 50, "even": 50 } } }
// Instant Response:
{ "event": "result", "data": { "handId": "uuid", "gameName": "roulette", "data": "7", "winAmount": 3600 } }
WS
placeBetManualSpin
Manual spin (1-9) โ instant result, 9x pay
{ "event": "placeBetManualSpin", "data": { "playerId": "...", "betPoint": 100, "position": { "5": 100 } } }
// Instant:
{ "event": "result", "data": { "handId": "uuid", "gameName": "manualSpin", "data": "5", "winAmount": 900 } }
WS
joinAdmin
Admin joins game admin room
{ "event": "joinAdmin", "data": { "adminId": "admin-uuid", "gameName": "rouletteTimer40" } }
// Response:
{ "event": "resAdmin", "data": { "numbers": [...], "totalCollection": 5000, "totalPayment": 4200 } }
WS
winByAdmin
Admin force sets winner number
{ "event": "winByAdmin", "data": { "gameName": "rouletteTimer40", "cardNumber": 7, "y": 1.0 } }
WS
balanceupdate
Request latest balance for a user
{ "event": "balanceupdate", "data": { "userid": "player-uuid" } }
// Response: "UPDATED_WALLET" event with new balance number
๐ฅ Server โ Client Events
These events are pushed by the server. Unity should listen for all of them.
| Event | When | Key Data Fields |
|---|---|---|
| join | After successful join | creditPoint, gameName, gamelastdata[], x[], gameState |
| newRound | New round starts (timer games) | gameName, gamelastdata[], x[], state |
| betClosed | Betting window closed | gameName |
| round2 | Andar Bahar round 2 starts | gameName, round: 2 |
| result | Round result announced | gameName, data (winning number), x, gamelastdata[] |
| placeBet | Bet placed confirmation | handId (betID), gameName, result (message) |
| UPDATED_WALLET | Balance changed | new balance (number) |
| logout | Account blocked | message |
| error | Any error | message |
| resAdmin | Admin join response | numbers[], totalCollection, totalPayment |
| resAdminResult | Round result (admin room) | gameName, result |
| resAdminBetData | Bet placed (admin room) | gameName, totalCollection, totalPayment |
| version | App version info | android (url), exe (url), version |
Timer Game Round Flow (rouletteTimer40 example)
[0s] Server โ "newRound" { gameName, gamelastdata, state }
[0-45s] Player โ "placeBet" { position, betPoint }
[45s] Server โ "betClosed" { gameName }
[53s] Server โ "result" { data: "7", x: 1, gamelastdata: ["7","26",...] }
Server โ "UPDATED_WALLET" 1400 (only to winner)
[53s] Next round begins โ "newRound" again
Andar Bahar Round Flow
[0s] Server โ "newRound" { gameName: "andarBahar", round: 1 }
[0-30s] Player โ "placeBetAB" { side: "A", betPoint: 100 }
[30s] Server โ "betClosed" { round: 1 }
[30s] Server โ "round2" { gameName, round: 2 }
[30-45s] Player โ "placeBetAB" { side: "B", betPoint: 50 }
[45s] Server โ "betClosed" { round: 2 }
[45s] Server โ "result" { data: "A" or "B" } pays 2x
๐งช WebSocket Live Tester
Disconnected
Quick Events
Custom JSON
Place Bet
Click to send pre-built events:
version
join room
checkLogin
leaveRoom
balanceupdate
beep (ping)
Token:
Game:
Message Log
โ WebSocket log will appear here โ
๐ฒ Game List
| Game Name | Type | Timer | Positions | Payout |
|---|---|---|---|---|
| rouletteTimer40 | Timer | 53s round | 0-36 (37 nums) + colors/dozens | 36x single, 2x color |
| rouletteTimer60 | Timer | 73s round | 0-36 (37 nums) + colors/dozens | 36x single, 2x color |
| spinToWin | Timer | 60s round | 1-9 | 9x |
| funTarget | Timer | 60s round | 1-9 | 9x |
| funRoulette | Timer | 60s round | 0-36 | 36x / 2x |
| andarBahar | Timer | 30s+15s | side: "A" or "B" | 2x |
| roulette | Manual | Instant | 0-36 + red/black/even/odd/dozens/cols | 36x / 2x / 3x |
| manualSpin | Manual | Instant | 1-9 | 9x |
๐ฐ Roulette Position Reference
Position keys for roulette bets โ combine any of these in one bet object.
| Key | Description | Payout |
|---|---|---|
| "0" to "36" | Single number | 36x |
| "red" | Red numbers | 2x |
| "black" | Black numbers | 2x |
| "even" | Even numbers (2,4,6...) | 2x |
| "odd" | Odd numbers | 2x |
| "low" | 1-18 | 2x |
| "high" | 19-36 | 2x |
| "dozen1" | 1-12 | 3x |
| "dozen2" | 13-24 | 3x |
| "dozen3" | 25-36 | 3x |
| "col1" | Column 1 (1,4,7...) | 3x |
| "col2" | Column 2 (2,5,8...) | 3x |
| "col3" | Column 3 (3,6,9...) | 3x |
Example Multi-position Bet
{
"event": "placeBet",
"data": {
"playerId": "035e2653-50a1-4c68-977b-ffc25badcede",
"gameName": "rouletteTimer40",
"betPoint": 350,
"position": {
"7": 100, // 100 on number 7 โ wins 3600 if 7 hits
"red": 100, // 100 on red โ wins 200 if red hits
"odd": 100, // 100 on odd โ wins 200 if odd hits
"dozen1": 50 // 50 on 1-12 โ wins 150 if 1-12 hits
}
}
}