Skip to main content

Tutorial: build a casino on SlotBattle

You will build Bonanza Bay, a minimal casino that reads the game catalog, opens a battle, fills it, watches it live, and settles the result from a signed webhook.

The finished project lives in GambaLabs/slotbattle-demo-casino, roughly 600 lines of commented TypeScript. Every snippet in this tutorial comes from that project.

What you will build

The browser never sends the API key to SlotBattle. It receives a viewer token instead, scoped to one battle and valid for 15 minutes.

What you need

  • Node 22+
  • A SlotBattle instance from the platform: a base URL and a tenant id (what you receive)
  • A tenant API key with games:read, battles:read, battles:write, bots:write and viewer:mint, plus demo:mint unless you are bringing your own game session URL for the creator's seat. A key issued before that scope existed does not carry it
  • At least one allowed game for your tenant

Read Battle lifecycle first. Two facts from it decide the shape of everything here: a battle starts itself when every seat is READY, and there is no start endpoint.

The five steps

SetupProject, environment, and the one rule about the API key
First battleCatalog, open a lobby, fill it with bots
Watch it liveViewer tokens, the WebSocket feed, HLS video
WebhooksVerify the signature, settle the result
Going to productionWhat this demo skips, and what you must not

What this tutorial does not cover

Player accounts, wallets, entry debits and payouts. Those are on your side of the boundary. SlotBattle emits raw multipliers and has no concept of winning; translating multiplier: 138.4 into money is your job, and it is the part that differs per casino and per jurisdiction.

See What SlotBattle does not do.

One step needs real provider credentials

Seating bots mints demo sessions through the provider's backend, and there is no sandbox. That step cannot be completed without real game-provider credentials.

Everything else, including the catalog, lobby, seats, viewer tokens, the live feed and the webhook, works against any instance you can reach.

Setup