Skip to main content

2.2 Data Flow

This is how MollyBet interacts with your API.

2.2.1 The sequence

  1. MollyBet calls your /account endpoint to verify the account is active.
  2. MollyBet starts continuously calling your/events endpoint to get the current list of events and odds.
  3. MollyBet POSTs to your /bets endpoint when it wants to place a bet. Your response determines whether the bet is accepted.
  4. MollyBet calls your single-bet endpoint, GET /bets/{bet_id}, to get the status of a single bet (this is used to track bets reported as "danger").
  5. MollyBet calls your /bets endpoint to get a list of bets filtered by date range and status.
  6. MollyBet periodically calls your /balance & /keep_alive endpoints to get the current balance of the account and check if your API is still alive.
  7. MollyBet calls your /price_and_stake endpoint to get the latest price & liquidity for a selection each time a betslip is opened.

The steps in this sequence are not necessarily in order. However, step 1 is always called first since it does a "login".

Step 5 has two distinct uses: retrieving recent placements in order to recover from network errors, and checking how you have settled bets.

2.2.2 Polling rates

The /events endpoint is polled separately for each value of the type parameter, and each type is polled at a different rate:

TypeMeaningRelative polling rate
liveEvents currently in-play.Fastest (every 5 seconds)
todayEvents happening today but not in-play.Moderate (every 60 seconds)
earlyEvents happening tomorrow onwards.Slowest (every 5 minutes)

If you implement the offers WebSocket, you can push events, price and liquidity changes as they happen.

2.2.3 Recovering from errors

If a POST /bets call fails at the network level, MollyBet does not know whether you received it. The recovery path is the bets list: query /bets/ over the relevant date range and reconcile against the bet_id values we sent.

This is why the bet_id we supply at placement must be stored and echoed back. It is our identifier, not yours, and it is the only reliable way to match a bet across a failed request.