ReelbitDocs

Quick start

After this page you will have played a game in the sandbox and made your first signed call. It takes about 5 minutes.

#What you need

Reelbit sends you a "your sandbox details" message with your operator id and two key ids. The two secrets come separately:

Until your own wallet is ready, your sandbox operator points at Reelbit's wallet simulator, which holds test money for any player id you invent.

#1. Check the sandbox is up

curl https://api.sandbox.reelbit.io/v1/health

You get {"status":"ok","environment":"sandbox",...}. This call needs no signature.

#2. Start a session and open the game

Save this as start-session.mjs. It needs Node 18 or newer and nothing else.

// Reelbit quick start: Node 18+, no dependencies.
//   node start-session.mjs                     starts a session and prints the launch link
//   node start-session.mjs rounds <player_id>  lists that player's latest rounds
import { createHmac } from 'node:crypto';

const API = process.env.REELBIT_API_URL ?? 'https://api.sandbox.reelbit.io';
const KEY_ID = process.env.REELBIT_KEY_ID;
const SECRET = process.env.REELBIT_SECRET;
if (!KEY_ID || !SECRET) throw new Error('Set REELBIT_KEY_ID and REELBIT_SECRET to your inbound key id and secret.');

async function call(method, pathWithQuery, body) {
  const raw = body === undefined ? '' : JSON.stringify(body);
  const ts = String(Math.floor(Date.now() / 1000));
  const signature = createHmac('sha256', SECRET).update(`${method}\n${pathWithQuery}\n${ts}\n${raw}`).digest('hex');
  const res = await fetch(API + pathWithQuery, {
    method,
    headers: { 'content-type': 'application/json', 'x-reelbit-key-id': KEY_ID, 'x-reelbit-timestamp': ts, 'x-reelbit-signature': signature },
    body: method === 'GET' ? undefined : raw,
  });
  const json = await res.json();
  if (!res.ok) throw new Error(`${res.status} ${json.code}: ${json.message}`);
  return json;
}

if (process.argv[2] === 'rounds') {
  const player = process.argv[3] ?? 'quickstart-player';
  const { rounds } = await call('GET', `/v1/rounds?player_id=${encodeURIComponent(player)}&limit=5`);
  for (const r of rounds) console.log(r.round_id, r.status, `played ${r.play_amount}`, `won ${r.win_amount}`, r.replay_url);
  if (rounds.length === 0) console.log('No rounds yet for', player);
} else {
  const session = await call('POST', '/v1/sessions', {
    mode: 'real',
    player_id: 'quickstart-player',
    game_id: 'doink',
    currency: 'SC',
    language: 'en',
    device: 'desktop',
    country: 'US',
    us_state: 'TX',
    lobby_url: 'https://example.com/lobby',
  });
  console.log('session_id:', session.session_id);
  console.log('launch_url:', session.launch_url);
}

Run it with your inbound key id and secret:

REELBIT_KEY_ID=key_yourInboundKeyId REELBIT_SECRET='your inbound secret' node start-session.mjs

It prints a launch_url. Open it in a browser within 60 seconds. You are playing DOINK! with 500.00 test Sweeps Coins.

#3. Find the round you just played

Play one round, then list your player's rounds with the same script's helper:

REELBIT_KEY_ID=key_yourInboundKeyId REELBIT_SECRET='your inbound secret' node start-session.mjs rounds quickstart-player

Each round shows its debit, its credit and a replay_url that shows it again.

#Next