Betvision Integration
User-Bets
API

API

requestUserBets

Event that is sent by BetVision and signals that it is ready to receive a customer's BetVisionUI.

Points to keep in mind:

  • If the setUserBets is called before the player_ready or the first requestUserBets is received the BetVisionUI will not be populated as it has not finished loading.

Contract

type MessageBusEvent = {
  correlationId: string
  routingKey: {}
  type: string
  body: any
}
 
type requestUserBets = MessageBusEvent & {
  body: null
}

Example

Given this code

window.addEventListener('geniussportsmessagebus', (event) => {
  if (event.type === 'requestBetVisionUIEvent') {
    console.log(event)
  }
})

It will print the following code.

{
    "correlationId": "f5bff2be-4cf2-4068-31fd-2d1ec482b086",
    "routingKey": {},
    "type": "requestBetVisionUIEvent",
    "body": null
}

You don't need to print it, you can attach any function as the addEventListener callback. We encourage you to call the setUserBets when receiving this event automatically. An example will be shown in the Guide section.

setUserBets

Event that updates the state of the Watchlist in the BetVision UI.

Points to keep in mind:

  • The BetVision UI does not store state.
  • The setUserBets body completely overwrites the state of the Watchlist in the BetVision UI. This means that if a market is sent on one event dispatch but it is not sent on another, the UI will remove it from the Watchlist.

Contract

type CustomerMarket = {
  id: string,
  type: 'Single' | 'Multi'
  status: 'Open' | 'Settled'
  selections: Selection[]
  currency: string
  payout: number
  stakePerUnit: number
  cashOutAvailable: true
  cashOutPrice: number
  addedAt: number // Timestamp
}
 
type Selection = {
   sport: string
   competitionName: string
   selectionId: string
   status: 'Won' | 'Lost' | 'Open'
   selectionName: string
   marketId: string
   marketType: string
   fixtureId: string
   fixtureName: string
   fixtureStartTime: number // Timestamp
   price: {
    numerator: number,
    denominator: number,
    decimal: number,
    american: string,
    outcome?: string, // it is used for overunder bets and its value can be Under or Over.
    handicap?: string // it is used for overunder bets and its value is the number tied to the overunder bet
   }
}

An example would look like this:

const exampleBody: Array<CustomerMarket> = [
  {
    "id": "qwerty",
    "type": "Single",
    "status": "Settled",  
    "selections": [{
      "sport": "Bookmaker sport name",
      "competitionName": "Bookmaker Competition Name",
      "selectionId": "1-123",
      "status": "Lost",
      "selectionName": "Polonia Swidnica",
      "marketId": "12345",
      "marketType": "Match Result",
      "fixtureId": "1234",
      "fixtureName": "Polonia Swidnica vs FC Barcelona",
      "fixtureStartTime": 1560253796,
      "price": {
        "numerator": 1,
        "denominator": 4,
        "decimal": 2.5,
        "american": "1/4",
        "outcome": "Under"
        "handicap": "2.5"
      }
    }],
    "currency":"USD",
    "payout": 5,
    "stakePerUnit": 2,
    "cashOutAvailable": true,
    "cashOutPrice":2.1, 
    "addedAt": 1560253796
  }
]
 
const eventName = 'setUserBets'
window.dispatchEvent(
  new CustomEvent('geniussportsmessagebus', {
    detail: {
      correlationId: 'guid',
      routingKey: {},
      type: eventName,
      body: exampleBody,
    },
  })
)