API Reference

Complete technical reference for every class, method, and model in StakeAPI.

Modules

ModuleWhat it does
StakeAPI ClientMain async client — casino, sports, user, and betting methods
AuthManagerToken storage, expiry tracking, cURL credential extraction
Data ModelsPydantic models: User, Game, SportEvent, Bet, Transaction, Statistics
Endpoints & GraphQLURL constants and pre-built GraphQL query strings
ExceptionsFull exception hierarchy with examples and fix guidance
Utilitiessafe_decimal, format_currency, validate_bet_amount, and more

Quick Navigation

By task

I want to…Go to…
Make my first API callGetting Started → Quick Start
Authenticate with Stake.comGetting Started → Authentication
Get my account balanceClient → get_user_balance()
Browse casino gamesClient → get_casino_games()
Place a betClient → place_bet()
Write a raw GraphQL queryEndpoints → GraphQL Queries
Handle errors properlyExceptions
Validate / format amountsUtilities

By class

  • StakeAPIget_user_balance(), get_casino_games(), get_sports_events(), place_bet(), get_bet_history(), get_user_profile(), _graphql_request()
  • AuthManagerset_access_token(), is_token_expired(), extract_access_token_from_curl(), get_cookies()
  • Userid, username, verified, country, currency
  • Gamename, category, provider, rtp, min_bet, max_bet
  • SportEventhome_team, away_team, odds, live, start_time
  • Betamount, potential_payout, status, placed_at
  • Transactiontype, amount, currency, status
  • Statisticstotal_bets, win_rate, biggest_win

All Methods at a Glance

StakeAPI — Casino

MethodReturnsDescription
get_casino_games(category=None)List[Game]List available games, optionally filtered
get_game_details(game_id)GameFull details for a single game

StakeAPI — Sports

MethodReturnsDescription
get_sports_events(sport=None)List[SportEvent]Live and upcoming events

StakeAPI — User

MethodReturnsDescription
get_user_profile()UserProfile: username, country, verified
get_user_balance()DictAvailable and vault balances by currency

StakeAPI — Betting

MethodReturnsDescription
place_bet(bet_data)BetSubmit a bet
get_bet_history(limit=50)List[Bet]Recent bet history

StakeAPI — Low-level

MethodReturnsDescription
_graphql_request(query, variables, operation_name)DictRaw GraphQL call
_request(method, endpoint, params, data)DictRaw HTTP call
close()Close the HTTP session

AuthManager

MethodReturnsDescription
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()boolTrue 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

FunctionReturnsDescription
validate_api_key(key)boolFormat check
safe_decimal(value)Optional[Decimal]Safe type conversion
parse_datetime(s)Optional[datetime]ISO 8601 parsing
format_currency(amount, currency)strDisplay string
calculate_win_rate(wins, total)floatWin %
validate_bet_amount(amount, min, max)boolRange check
sanitize_game_name(name)strSafe string

All API methods require a valid Stake.com account and a cf_clearance cookie.