Skip to main content

API Reference

Welcome to the BlockBet API Reference documentation. This guide provides detailed information about all available GraphQL APIs, their parameters, and responses.

Getting Started​

The BlockBet API is built using GraphQL, providing a flexible and powerful way to interact with our services. To get started:

  1. Authentication: Authentication is handled automatically via HTTP cookies
  2. Base URL: All API requests should be made to our GraphQL endpoint
  3. Schema: Our API follows a strongly-typed schema for better development experience

API Structure​

Our API is organized into several main services:

  • GraphQL Main (gql-main): Core API for user-facing operations

    • Authentication: User registration, login, and MFA management
    • User Management: Profile, settings, and wallet operations
    • Betting: Place bets, view history, and manage betting operations
    • Blockchain: Smart contract interactions and transaction management
  • GraphQL CRM (gql-crm): Admin-facing API for platform management

    • Admin authentication and authorization
    • User management and reporting
    • System configuration and monitoring
  • Hooks: Event-based services for integrations and automated processes

    • External system integrations
    • Task management and scheduling
    • Notification handling
  • WebSocket: Real-time communication for live updates

Authentication​

Authentication is handled automatically via HTTP cookies. The system manages both accessToken and refreshToken cookies, so there's no need to manually set the Authorization header.

When you successfully authenticate, the tokens will be set in cookies and automatically included in subsequent requests. The system handles token refreshing and session management without requiring manual header setup.

Rate Limiting​

To ensure fair usage, we implement rate limiting on our API endpoints:

  • Short-term: 2 requests per second
  • Medium-term: 7 requests per 10 seconds
  • Long-term: 15 requests per minute

Error Handling​

Our API uses standard GraphQL error handling with detailed error messages and codes. Common error types include:

  • Authentication errors
  • Validation errors
  • Rate limiting errors
  • Business logic errors

Business Logic Errors​

CategoryError CodeDescription
User Account & Authentication
USER_NOT_FOUNDThe requested user account does not exist
USER_LOCKED/USER_BLOCKED/USER_DELETEDAccount is unavailable due to security measures, violation of terms, or deletion
USER_MFA_LOCKEDAccount locked due to multiple failed multi-factor authentication attempts
USER_KYC_LOCKEDAccount locked pending Know Your Customer verification
EMAIL_ALREADY_EXISTS/USERNAME_EXISTSRegistration failed due to duplicate credentials
ALREADY_LINKED/ALREADY_LINKED_TO_OTHER_USERSocial account linking conflict
Verification & Security
WRONG_CODE/WRONG_2FA_CODEIncorrect verification or 2FA code provided
INVALID_TOKEN/TOKEN_EXPIREDAuthentication token is invalid or has expired
MFA_NOT_ENABLED/MFA_ALREADY_ENABLEDMulti-factor authentication status conflict
KYC_REQUIREDThis operation requires completed identity verification
EMAIL_NOT_VERIFIED/PHONE_ALREADY_VERIFIEDAccount verification status conflict
Financial Operations
INSUFFICIENT_BALANCEAccount lacks funds to complete the requested transaction
LESS_THAN_MINIMUM_WITHDRAWAL_AMOUNTWithdrawal amount below minimum threshold
CLAIM_REWARDS_LOCKED/WITHDRAWAL_BLOCKS_LOCKEDFinancial operations temporarily restricted
NO_REWARDS_TO_CLAIMNo pending rewards available for claiming
WAGERING_NOT_REACHEDBetting requirements not fulfilled for reward eligibility
Events & Predictions
EVENT_NOT_FOUND/PREDICTION_NOT_FOUNDRequested event or prediction does not exist
RESOLVED_EVENT/EVENT_ENDEDOperation not allowed on completed events
PUBLISHED_EVENTCannot modify an event that has been made public
PREDICTION_ALREADY_EXISTSDuplicate prediction creation attempt
EVENT_NOT_FOR_THIS_COUNTRYEvent restricted in user's geographical location
Wallet & Blockchain
INVALID_ADDRESSProvided blockchain address is not valid
WALLET_NOT_FOUNDReferenced wallet does not exist in the system
IN_USED_WALLETWallet is already associated with another operation
DEPOSIT_ADDRESS_NOT_FOUNDNo valid deposit address found for transaction
TOKEN_WITHDRAWAL_DISABLED/TOKEN_DEPOSIT_DISABLEDOperations with specified token temporarily unavailable

Security Considerations​

  • Cookies are set with HttpOnly flag to prevent JavaScript access
  • Secure flag ensures cookies are only sent over HTTPS connections
  • SameSite policy protects against CSRF attacks
  • Automatic token refresh mechanism maintains session validity

Best Practices​

  1. Always validate input data before sending requests
  2. Implement proper error handling
  3. Use appropriate caching strategies
  4. Follow rate limiting guidelines
  5. Leverage GraphQL's ability to request only the data you need

Support​

If you need help or encounter issues: