A TypeScript library for creating and managing poker hand histories following the Open Hand History standard.
Installation | Quick Start | API Reference | Development | Contributing
npm install open-hand-tracker
import { OpenHandHistory } from 'open-hand-tracker';
// Initialize hand history
const ohh = new OpenHandHistory({
siteName: 'MyPokerSite',
tableSize: 6
// other properties...
});
// Add a player
ohh.addPlayer({
name: 'Player 1',
id: 1,
startingStack: 1000,
seat: 1
});
// Add a round
ohh.addRound({
id: 1,
street: 'PREFLOP',
actions: []
});
// Add action to round
ohh.addActionToRound(1, {
actionNumber: 1,
playerId: 1,
action: 'RAISE',
amount: 100
});
// Add pot
ohh.addPot({
number: 1,
amount: 50,
player_wins: [{ player_id: 1, win_amount: 50 }],
});
// Calcuatle winnings
ohh.calculateWinningAmount(1); // Pass the player ID
// Save to file
ohh.saveToFile('hand_history.json');
{
specVersion?: string; // Default: '1.4.6'
internalVersion?: string; // Default: '1.4.6'
networkName?: string; // Default: 'CustomGame'
siteName?: string; // Default: 'HomeGame'
gameType?: string; // Default: 'Holdem'
tableName?: string; // Default: 'Sample Table'
tableSize?: number; // Default: 3
gameNumber?: string; // Default: '1'
startDateUTC?: string; // Default: current date
currency?: string; // Default: 'Chips'
anteAmount?: number; // Default: 0
smallBlindAmount?: number; // Default: 1
bigBlindAmount?: number; // Default: 2
betCap?: number; // Default: 0
betType?: string; // Default: 'NL'
dealerSeat?: number; // Default: 1
heroPlayerId?: number; // Default: 0
}
Add a player to the hand history.
interface Player {
name: string;
id: number;
startingStack: number;
seat: number;
cards?: string[];
}
Add a new round to the hand history.
interface Round {
id: number;
cards?: string[];
street: "Preflop" | "Flop" | "Turn" | "River" | "Showdown"
actions: Action[];
}
Add an action to a specific round.
interface Action {
actionNumber: number;
playerId: number;
action: string;
amount?: number;
isAllIn?: boolean;
}
Add a pot to the hand history.
interface Pot {
rake?: number;
number: number;
amount: number;
playerWins: { playerId: number; winAmount: number }[];
}
Calculates the winners winnings
Convert the hand history to JSON string.
Save the hand history to a file.
git clone https://github.com/yourusername/open-hand-history.git
cd open-hand-history
npm install
npm test
npm run build
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
MIT