1. By Room
[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 Balance
        • Get Provably-Fair State
      • Lobby Game List
  • Wallet
    • Wallet Status
      GET
  • Game
    • Lotto (หวยเฮงเฮง)
      • Lotto Rules
      • Rooms
        • By Room
          • Join Round
            GET
          • Place Multi-player Bet
            POST
          • Get Round Result
            GET
          • Room Event Stream
            GET
      • 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
      • Get Current Round
        POST
      • Get Pay Table
        GET
  • 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 Room

Room Event Stream

GET
/gapi/v1/g/lotto/rooms/{roomId}/stream
Opens a Server-Sent Events stream of real-time room events (new round, bets, client-seed slots, settlement) for one room + currency. Open it with EventSource when the player enters a room.
Auth: Player session — Authorization: Bearer {token}
Rate limit: 60 requests per 60 s per IP (GAME_ROOM_STREAM)
Games: LOTTO
Rules
System maintenance and Lotto's own maintenance window both answer 503 99915.
See Getting Started → Real-time Events for the frame format, every event and the reconnect playbook.
EventSource cannot send headers: pass the session token as ?token= (URL-encoded).
Frames are data: {"type":…,"data":…} only; handle them in onmessage and switch on .type.
Nothing is replayed on connect: call Join Round (GET …/round) right after the stream opens and after every reconnect.
An error before streaming starts is a normal JSON error response with a non-200 status; EventSource treats it as fatal and stops retrying, so create a new EventSource.
60 connects per 60 s per client IP; every reconnect counts.
The room is not checked: any integer roomId opens a stream, which stays silent if the room does not exist.
One stream per room + currency (+ demo/real). To switch room or currency, close it and open a new one.
The session is checked only at connect; an open stream keeps delivering after the token expires.
Flow
1.
Authenticate from the Authorization header or ?token=; resolve {gameCode}, {roomId} and the currency (query, else session).
2.
Subscribe to the room channel for game + room + currency + demo/real; a failure answers a JSON 500.
3.
Send the SSE headers and forward each room event as one data: frame; round_settled carries only this player's playerResult.
4.
Keep streaming until the client disconnects; there is no server-side time limit and no heartbeat.

Request

Path Params

Query Params

Header Params

Responses

🟢200OK
application/json
Bodyapplication/json

🟠400Bad Request
🟠401Unauthorized
🟠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/g/lotto/rooms/1/stream?token=tok_synthetic_7f3a9c&currency=THB' \
--header 'Authorization: Bearer 3f9a1c7e5b2d4f6081a3c5e7f9b1d3f5a7c9e1b3d5f7a9c1e3b5d7f9a1c3e5b7' \
--header 'Accept-Language: th'
Response Response Example
200 - round_started
One data: line of the text/event-stream — The server opened a new betting round for this room + currency + demo/real: at start-up, at the moment the previous round closes, in the periodic recovery sweep, as a replacement after a cancelled round, or when recovering a stuck round.
{
    "type": "round_started",
    "data": {
        "roundID": "tbq1x0a7c3e91f2",
        "endTime": "2026-09-30T18:45:30.123456789+07:00",
        "seedHash": "9f2c1e7a5b3d8f40c6a1e2d9b7f35c08e4a6d1b9c2f7e3a05d8b6c4e1f2a9d37"
    }
}
Modified at 2026-09-30 13:23:45
Previous
Get Round Result
Next
Create Ticket
Built with