API Reference
Complete technical reference for every class, method, and model in StakeAPI.
Modules
| Module | What it does |
| StakeAPI Client | Main async client — casino, sports, user, and betting methods |
| AuthManager | Token storage, expiry tracking, cURL credential extraction |
| Data Models | Pydantic models: User, Game, SportEvent, Bet, Transaction, Statistics |
| Endpoints & GraphQL | URL constants and pre-built GraphQL query strings |
| Exceptions | Full exception hierarchy with examples and fix guidance |
| Utilities | safe_decimal, format_currency, validate_bet_amount, and more |
Quick Navigation
By task
By class
StakeAPI — get_user_balance(), get_casino_games(), get_sports_events(), place_bet(), get_bet_history(), get_user_profile(), _graphql_request()
AuthManager — set_access_token(), is_token_expired(), extract_access_token_from_curl(), get_cookies()
User — id, username, verified, country, currency
Game — name, category, provider, rtp, min_bet, max_bet
SportEvent — home_team, away_team, odds, live, start_time
Bet — amount, potential_payout, status, placed_at
Transaction — type, amount, currency, status
Statistics — total_bets, win_rate, biggest_win
All Methods at a Glance
StakeAPI — Casino
| Method | Returns | Description |
get_casino_games(category=None) | List[Game] | List available games, optionally filtered |
get_game_details(game_id) | Game | Full details for a single game |
StakeAPI — Sports
| Method | Returns | Description |
get_sports_events(sport=None) | List[SportEvent] | Live and upcoming events |
StakeAPI — User
| Method | Returns | Description |
get_user_profile() | User | Profile: username, country, verified |
get_user_balance() | Dict | Available and vault balances by currency |
StakeAPI — Betting
| Method | Returns | Description |
place_bet(bet_data) | Bet | Submit a bet |
get_bet_history(limit=50) | List[Bet] | Recent bet history |
StakeAPI — Low-level
| Method | Returns | Description |
_graphql_request(query, variables, operation_name) | Dict | Raw GraphQL call |
_request(method, endpoint, params, data) | Dict | Raw HTTP call |
close() | — | Close the HTTP session |
AuthManager
| Method | Returns | Description |
get_auth_headers() | Dict[str, str] | Headers with access token |
get_cookies() | Dict[str, str] | Session cookie dict |
set_access_token(token, expires_in) | — | Store/update the token |
set_session_cookie(cookie) | — | Store/update the session cookie |
is_token_expired() | bool | True if token is stale |
clear_tokens() | — | Wipe all stored credentials |
extract_access_token_from_curl(cmd) (static) | Optional[str] | Parse token from cURL |
extract_session_from_curl(cmd) (static) | Optional[str] | Parse session from cURL |
Utilities
| Function | Returns | Description |
validate_api_key(key) | bool | Format check |
safe_decimal(value) | Optional[Decimal] | Safe type conversion |
parse_datetime(s) | Optional[datetime] | ISO 8601 parsing |
format_currency(amount, currency) | str | Display string |
calculate_win_rate(wins, total) | float | Win % |
validate_bet_amount(amount, min, max) | bool | Range check |
sanitize_game_name(name) | str | Safe string |
All API methods require a valid Stake.com account and a cf_clearance cookie.