Pokai
WebSocket API

Build a Poker Bot

Connect to Pokai via WebSocket, receive game state in real-time, and compete your bot in Texas No-Limit Hold'em matches.

Quick Start

getting-started
1

Connect via WebSocket

ws://localhost:3001
2

Register your bot with API key

{ "type": "bot:register", "botId": "my-bot", "apiKey": "pk_..." }
3

Receive game state

{ "type": "action:required", "validActions": [...] }
4

Send your action

{ "type": "bot:action", "action": { "type": "CALL" } }

Example Bot

A minimal TypeScript bot to get you started. Connects, registers, and responds to actions.

bot.ts
import WebSocket from 'ws';

const ws = new WebSocket('ws://localhost:3001');
const botId = 'my-bot-' + Date.now();
const apiKey = process.env.POKAI_API_KEY;

ws.on('open', () => {
  ws.send(JSON.stringify({
    type: 'bot:register',
    botId,
    name: 'SimpleBot',
    apiKey,
    timestamp: Date.now()
  }));
});

ws.on('message', (data) => {
  const msg = JSON.parse(data.toString());

  switch (msg.type) {
    case 'action:required':
      const { validActions, gameState } = msg;

      let action;
      const checkAction = validActions.find(a => a.type === 'CHECK');
      const callAction = validActions.find(a => a.type === 'CALL');

      if (checkAction) {
        action = { type: 'CHECK' };
      } else if (callAction && callAction.amount < gameState.myChips * 0.2) {
        action = { type: 'CALL', amount: callAction.amount };
      } else {
        action = { type: 'FOLD' };
      }

      ws.send(JSON.stringify({
        type: 'bot:action',
        matchId: msg.matchId,
        action,
        timestamp: Date.now()
      }));
      break;

    case 'round:ended':
      console.log('Round ended:', msg.winners);
      break;

    case 'match:ended':
      console.log('Match ended! Winner:', msg.winner);
      break;
  }
});

Built for Bot Developers

Real-time WebSocket

JSON-based protocol with event-driven architecture. Receive game state updates instantly.

30s Action Timeout

Generous timeouts with automatic fallback. Your bot gets check-or-fold if it times out.

Side Pot Support

Full Texas Hold'em rules including side pots for all-in scenarios. No shortcuts.

Hand Replay

Review every hand your bot played. Analyze decisions action-by-action to improve strategy.