Skip to main content

UserBet API Reference

The UserBet API provides a comprehensive GraphQL interface for querying betting data across both sports and casino games. This API enables clients to retrieve real-time information about active players, latest wins, high rollers, personal betting history, and detailed betting statistics.

Overview​

The UserBet API is designed to handle high-volume betting data efficiently while providing real-time insights into betting activities. It supports both public queries (no authentication required) and authenticated queries with different levels of data access based on user permissions.

Authentication​

Authentication is automatically managed through HTTP cookies, with the system handling both the accessToken and the refreshToken. The API implements three authentication levels:

Public Queries​

No authentication required. These queries provide general betting statistics and activity:

  • allSportsField
  • totalActivePlayers

Optional Authentication​

Enhanced data when authenticated, but also accessible to anonymous users:

  • totalLatestWin (and variants)
  • latestBets (and variants)
  • highRollers (and variants)
  • othersArePlaying
  • totalWinForPast24Hours

Required Authentication​

User-specific data that requires authentication:

  • myBets (and variants)
  • topCasinoWins
  • casinoBetInfo

Common Parameters​

Bet Type Filtering​

Most endpoints support the type parameter to filter by bet category:

enum QueryUserBetType {
SPORT // Sport bets only
CASINO // Casino bets only
// Omit parameter for both types
}

Pagination Parameters​

Many endpoints support pagination for large result sets:

  • limit: Maximum number of results to return
  • offset: Number of results to skip
  • needTotalCount: Whether to return total count (for pagination UI)

Filtering Parameters​

Advanced filtering options available on many endpoints:

  • providerSlug: Filter by specific game provider
  • gameSlug: Filter by specific casino game
  • casinoPageSlug: Filter by casino page category

Sorting Parameters​

Personal betting history supports custom sorting:

  • orderBy: Field to sort by (settledAt, betAmount, wonAmount, etc.)
  • order: Sort direction (ASC, DESC)

Response Formats​

Currency Handling​

  • Monetary values are automatically converted to the user's preferred currency
  • Both original and converted amounts may be provided
  • Exchange rates are applied in real-time

Data Structure​

All responses follow consistent patterns:

Paginated Responses​

{
data: T[], // Array of results
count: number, // Total count (if requested)
limit: number, // Applied limit
offset: number // Applied offset
}

Statistical Responses​

{
count: number, // Numeric count
formattedCount: string // Human-readable format (e.g., "1.2K")
}

Available Endpoint Categories​

1. Sports Information​

  • Sports Fields: Get all available sports categories for betting

2. Active Players​

  • Total Active Players: Count of players active in the last hour
  • Provider-Specific: Active players for specific game providers
  • Game-Specific: Active players for specific games
  • Casino Page: Active players for casino page categories

3. Latest Wins​

  • Total Latest Wins: Recent winning bets across all games
  • Provider-Specific: Recent wins for specific providers
  • Game-Specific: Recent wins for specific games
  • Casino Page: Recent wins for casino page categories

4. Latest Bets​

  • Total Latest Bets: Most recent betting activity
  • Provider-Specific: Recent bets for specific providers
  • Game-Specific: Recent bets for specific games
  • Casino Page: Recent bets for casino page categories

5. High Rollers​

  • Total High Rollers: Largest bets across all games
  • Provider-Specific: High roller bets for specific providers
  • Game-Specific: High roller bets for specific games
  • Casino Page: High roller bets for casino page categories

6. Personal Betting History​

  • My Bets: Complete personal betting history with advanced filtering
  • Provider-Specific: Personal bets for specific providers
  • Game-Specific: Personal bets for specific games
  • Casino Page: Personal bets for casino page categories

7. Social Gaming​

  • Others Are Playing: Games currently being played by other users

8. Win Statistics​

  • 24-Hour Win Statistics: Aggregated win data for the past 24 hours

9. Specialized Casino Features​

  • Top Casino Wins: User's best casino wins with multipliers
  • Casino Bet Info: Detailed information about specific casino bets

Performance Features​

Caching Strategy​

  • Active Players: 5-minute cache
  • Latest Wins: 1-minute cache for real-time feel
  • Latest Bets: 30-second cache
  • High Rollers: 2-minute cache
  • Sports Fields: 24-hour cache (rarely changes)

Rate Limiting​

  • Public endpoints have generous rate limits
  • Authenticated endpoints have higher limits
  • Pagination prevents excessive data transfer

Real-time Updates​

  • Frequent cache refreshes for live data
  • Event-driven cache invalidation
  • Optimistic updates for better user experience

Error Handling​

Common Error Types​

  • Authentication Errors: 401 Unauthorized for protected endpoints
  • Validation Errors: 400 Bad Request for invalid parameters
  • Not Found Errors: 404 Not Found for non-existent resources
  • Rate Limit Errors: 429 Too Many Requests when limits exceeded

Error Response Format​

{
"errors": [
{
"message": "Error description",
"extensions": {
"code": "ERROR_CODE",
"field": "fieldName"
}
}
]
}

Data Models​

Core Betting Data​

  • BetsTableData: Standard bet information with user and game details
  • UserBetUserModel: User information within betting context
  • UserBetCasinoGameModel: Casino game information for bets

Specialized Models​

  • CasinoBetInfoModel: Detailed casino bet information
  • TopCasinoWinsModel: Top wins with multiplier calculations

Usage Examples​

Basic Query​

query GetActivePlayers {
totalActivePlayers(type: CASINO) {
count
formattedCount
}
}

Filtered Query​

query GetLatestBetsByProvider {
latestBetsByProvider(providerSlug: "pragmatic-play", type: CASINO) {
data {
betAmount
wonAmount
time
user {
username
avatarUrl
}
market {
... on UserBetCasinoGameModel {
name
thumbnailUrl
}
}
}
}
}

Personal History with Filtering​

query GetMyBets($filter: MyBetFilterInput) {
myBets(
type: CASINO,
limit: 20,
offset: 0,
orderBy: SETTLED_AT,
order: DESC,
needTotalCount: true,
filter: $filter
) {
data {
betAmount
wonAmount
time
status
market {
... on UserBetCasinoGameModel {
name
provider
}
}
}
count
limit
offset
}
}

Best Practices​

Query Optimization​

  • Use pagination for large result sets
  • Request only needed fields to reduce payload
  • Leverage caching by avoiding unnecessary parameters

Authentication​

  • Include authentication cookies for personalized data
  • Handle authentication errors gracefully
  • Use optional authentication for enhanced public data

Error Handling​

  • Implement proper error handling for all query types
  • Provide user-friendly error messages
  • Handle network failures with retry logic

This API provides a robust, scalable, and user-friendly interface for accessing comprehensive betting data while maintaining high performance and security standards.