Casino API
The Casino API is the core interface powering Predictu’s prediction market trading experience. It provides everything needed for a complete trading lifecycle: executing trades, fetching price quotes, managing user balances, tracking positions, reviewing trade history, discovering markets, and resolving outcomes.
Trade Execution
The trade execution engine is the heart of the Casino API. When a user places a buy or sell order, it passes through a comprehensive multi-step pipeline that validates inputs, assesses risk across multiple defense layers, calculates spread-adjusted pricing, verifies sufficient funds, executes the balance change, records the trade, updates positions, and recalculates exposure, all in a single atomic operation.
Buying Positions
Users buy positions by specifying a market, an outcome, and a dollar amount. The engine calculates the spread-adjusted execution price and determines how many shares the user receives. The user’s balance is debited, the trade is recorded, and the position is created or averaged into an existing one.
Selling Positions
Users sell positions by specifying the number of shares to liquidate. The engine calculates the bid price, credits the proceeds to the user’s balance, and updates the position accordingly. Realized profit and loss is computed and returned with the response.
Transaction Safety
If any step in the execution pipeline fails after the balance has been changed, the system automatically performs a compensating transaction to reverse the balance adjustment. This ensures users are never left in an inconsistent state.
Price Quotes
Get real-time price quotes for potential trades without committing to execution. Quotes include the spread-adjusted execution price, the number of shares the user would receive, the total cost, and the potential payout. This allows users to preview exactly what they’ll get before placing a trade.
Balance Management
The balance system provides real-time access to user account balances, synchronized through the operator’s wallet system via server-to-server callbacks. Users can check their current balance at any time, with optional access to recent transaction history for transparency.
Deposits
Users can deposit funds into their trading account, subject to configurable balance limits. Deposits are processed immediately and reflected in the user’s available balance.
Withdrawals
Users can withdraw funds from their trading balance, provided they have sufficient available funds. Withdrawals are processed immediately and the updated balance is confirmed in the response.
Administrative Adjustments
Authorized administrators can make manual balance adjustments for use cases like promotional credits, refunds, or corrections. Every adjustment is logged with a reason and recorded in the full audit trail.
Position Tracking
Retrieve all positions for a user, filtered by status. Open positions show the user’s current market exposure with entry prices and share quantities. Resolved, closed, and voided positions provide a complete historical record of outcomes. Results are ordered by most recent activity for easy scanning.
Trade History
Access a user’s complete trade history with full execution details. Each trade record includes the market, side, outcome, share quantity, execution price, spread applied, cost, and balance impact. Results can be filtered by market and are paginated for efficient retrieval.
Market Discovery
The market discovery endpoint provides the configuration that governs which prediction markets are available for trading. This includes blocked categories, individually disabled markets, market selection criteria, and any custom spread overrides. The trading UI uses this configuration to filter and display the appropriate markets for each operator’s audience.
Market Resolution
When a prediction market reaches its outcome, the resolution process settles all open positions. Winning positions are credited automatically, losing positions are closed, and the house profit or loss is calculated. Markets can also be voided in exceptional circumstances, which refunds all positions at their original cost basis with zero house impact.
Reliability & Performance
The Casino API is engineered for the demands of real-time trading:
- Atomic transactions: Every trade either completes fully or rolls back cleanly
- Compensating transactions: Automatic balance reversal on partial failures
- Rate limiting: Per-user, per-endpoint rate limits protect against abuse while ensuring fair access
- Bearer token authentication: Secure, stateless authentication on every request
- Consistent error handling: Standardized error responses across all endpoints for predictable integration behavior
