1. By Game Code
[Game] FairPlay API
  • Getting Started
    • Introduction
    • Session and Token
    • Request and Response
    • Real-time Events (SSE)
    • Lotto Rules — หวยเฮงเฮง
    • Provably Fair
  • Player
    • Demo
      • Demo Login
    • Player Bet History
      GET
  • Common
    • Game
      • By Game Code
        • Provably Fair
          • Set Client Seed
          • Verify Result
          • Get Revealed Server Seed
        • Check Session
          GET
        • Get Balance
          GET
        • Get Provably-Fair State
          GET
      • Lobby Game List
        GET
  • Wallet
    • Wallet Status
      GET
  • Game
    • Lotto (หวยเฮงเฮง)
      • Lotto Rules
      • Rooms
        • By Room
          • Join Round
          • Place Multi-player Bet
          • Get Round Result
          • Room Event Stream
      • Tickets
        • Create Ticket
        • Inquiry My Tickets
        • Get Ticket
      • Round
        • Get My Bets
        • Get My Result
        • Get Round Provably Fair
      • Results
        • Inquiry Results
      • Get Rooms
      • Get Current Round
      • Get Pay Table
  • Appendix
    • Game List
    • Error Codes
    • Rate Limits
  • Language List
    GET
  • Ping
    GET
  • Schemas
    • DemoLoginRequest
    • DemoLoginResponse
    • DemoProfileResponse
    • ProfileResponse
    • GetHistoryResponse
    • BetRecord
    • GameInfo
    • Room
    • GetGameResponse
    • BetRequest
    • Bet
    • BetResponse
    • BetResult
    • GetProvablyFairResponse
    • SetClientSeedRequest
    • SetClientSeedResponse
    • RotateServerSeedResponse
    • VerifyResultRequest
    • VerifyResultResponse
    • GetServerSeedResponse
    • GetStatusResponse
    • JoinRoundResponse
    • PlaceMultiPlayerBetRequest
    • PlaceBetResponse
    • RoundResultResponse
    • SuccessResponse
    • ErrorResponse
  1. By Game Code

Get Provably-Fair State

GET
/gapi/v1/c/g/{gameCode}/provably-fair
Returns the server seed hash, client seed and nonce that the player's next bet will use. FE calls it to show the provably-fair panel before the player bets.
Auth: Player session — Authorization: Bearer {token}
Rate limit: 300 requests per 60 s per IP (GAME_GET_PROVABLY_FAIR)
Games: THAI-HILO, LOTTO
How it works
THAI-HILO single-player (SINGLE rooms, POST /g/thai-hilo/bet): each player has one state per game and per demo/real mode — a secret server seed (64-character lower-case hex), its hash, a client seed and a nonce. It is created on the first provably-fair call or bet with clientSeed "default" and nonce 1.
Commitment: serverSeedHash = lower-case hex SHA-256 of the server seed text. Show it before the player bets; the active server seed itself is never returned.
Client seed: POST /provably-fair/client-seed replaces the client seed and resets the nonce to 0; the server seed and its hash do not change.
Nonce: each single-player bet uses the current nonce, then the nonce goes up by 1.
Roll: bytes = HMAC-SHA256(key = the server seed as text — the 64 hex characters as-is, NOT hex-decoded; message = clientSeed + ":" + nonce in decimal). Die i (i = 0, 1, 2) = floor(uint32 big-endian of bytes[4i..4i+3] / 2^32 × 6) + 1.
Rotation: POST /provably-fair/rotate reveals the current server seed (revealedServerSeed with oldServerSeedHash), replaces it with a new one and resets the nonce to 1; the client seed is kept. Bets made under a seed can only be verified after that seed has been rotated out. GET /provably-fair/server-seed returns a rotated-out seed again by its hash.
Verify: POST /provably-fair/verify-result recomputes from what FE sends (serverSeed, clientSeed, nonce) and returns the dice and the SHA-256 of the seed. FE checks the hash equals the commitment shown before the bets and the dice equal the recorded roll; nothing is looked up on the server.
LOTTO, and THAI-HILO MULTI / MULTI_CSEED rooms, have no per-player server seed: each round publishes its own seedHash when it opens and reveals the seed at settlement. A MULTI round seed is the text "{brand}{gameCode}{roomID}{unixNano}{result}_{64-hex nonce}" (the drawn result is embedded; hash = SHA-256 of that text). A MULTI_CSEED round seed combines the room server seed with the round's client-seed slots.
In MULTI_CSEED rooms of both games, the player's clientSeed and nonce are what a bet contributes when it claims a client-seed slot.
Rules
THAI-HILO: serverSeedHash is the player's own current commitment for single-player bets; the state is created on the first call.
LOTTO: serverSeedHash is the seed hash of the open (betting or rolling) round of one active room that serves the session currency — not necessarily the room the player is in. For a specific room use the room round calls.
LOTTO answers 404 99941 between rounds (no open round) and 404 99934 when no active room serves the currency.
LOTTO always uses the session currency; there is no currency parameter.
clientSeed is "default" until the player sets one.
nonce — THAI-HILO: the nonce the next single-player bet will use (1 on a new or rotated seed, 0 right after a client-seed change). LOTTO: the nonce a MULTI_CSEED bet contributes.
Demo and real play keep separate states.
Flow
1.
Validates the token, checks system maintenance and resolves gameCode.
2.
THAI-HILO: loads the player's state, creating it on first access (new server seed, clientSeed "default", nonce 1), and returns its hash, clientSeed and nonce.
3.
LOTTO: checks the game is active, takes the first active room for the session currency and its open round, and returns that round's seed hash with the player's clientSeed and nonce.

Request

Path Params

Header Params

Responses

🟢200OK
application/json
Bodyapplication/json

🟠400Bad Request
🟠401Unauthorized
🟠404Not Found
🟠429Too Many Requests
🔴500Internal Server Error
🔴503Service Unavailable
Request Request Example
Shell
JavaScript
Java
Swift
curl --location 'https://dev-api.ambfairgame.com/gapi/v1/gapi/v1/c/g/THAI-HILO/provably-fair' \
--header 'Authorization: Bearer 3f9a1c7e5b2d4f6081a3c5e7f9b1d3f5a7c9e1b3d5f7a9c1e3b5d7f9a1c3e5b7' \
--header 'Accept-Language: th'
Response Response Example
200 - THAI-HILO
Player with a custom client seed after three bets.
{
    "code": "0",
    "description": "Success.",
    "traceID": "0f8e2c1a-6b3d-4e5f-9a7b-1c2d3e4f5a6b",
    "data": {
        "serverSeedHash": "cecfc34e5de06b8028c4cadba0675e8afc6c4f4bf531327c5697c6f3cfa943c0",
        "clientSeed": "my-lucky-seed",
        "nonce": 4
    }
}
Modified at 2026-09-30 13:23:45
Previous
Get Balance
Next
Lobby Game List
Built with