Documentation

Bet Sharing/Copying

Overview

Сopy-betting/ copy-trading widget allows users to effortlessly share their bets and deals and copy each other's bets/deals with a simple click.

To share a bet, a user clicks the button on a chat, chooses the bet for sharing, and sends it to the chat (information about the bet, game, odds, avoiding personal data about the amount of money). Other users on the chat can repeat this bet by clicking on the widget (the bet will be put on the cart of the user who clicked it).

Try the experience on our demo stand: https://bet.watchers.io/. Click on the screen, choose a game, place a bet, share it or copy someone else’s bet.

Integration

The integration of CopyBetting into your application involves several core steps, including both front-end and back-end processes:

Sending Bet Data: once a user shares a bet, your application needs to send relevant bet data to our backend. This includes details like room ID, user ID, bet type, status, total factor, bet date, game ID, event ID, and outcome ID among others.

Retrieving User Bets: to facilitate bet sharing in chat, your API needs to be able to fetch an array of a user's past bets, sorted by bet date. This data is then displayed in the chat.

Handling Widget Interactions: when a user clicks on a bet widget in the chat to copy the bet, your application should handle this interaction and post a message with the relevant event ID, event title, outcome ID, and widget ID.

Confirming Successful Bet Placement (is not running yet): upon successful placement of a copied bet, your backend should send a confirmation to our backend, including the repeated widget ID.

In summary, the integration involves handling user interactions, sending and receiving bet data, and ensuring successful communication between your backend and our system. It's a seamless blend of front-end user experience enhancements and robust backend data exchanges.

Use cases for copy betting in a partner app

  1. While using a chat the user shares one of their previous bets.
  2. User can click on other users' widgets in the chat to repeat the bet.

Backend-to-Backend Integration

Bet Sharing

To display the user's latest bets in the chat, we will call this API whenever the user opens the "last bets" list.

The API should return an array of the user's most recent bets identified by userId, formatted as shown below and sorted by betDate.

Request parameters

ParameterTypeRequiredDescription
limitnumberYesParameter for a pagination
offsetnumberYesParameter for a pagination
clientNumberstringYesParameter to indentify user on parner side
[
  {
    "betType": "SINGLE",
    "status": 3,
    "totalFactor": 3.6,
    "orderDate": "2023-05-18T09:29:17.163Z",
    "barcode": "167798842222",
    "position": {
      "positionId": 1,
      "status": "3",
      "factorValue": 3.6,
      "eventId": "17484857",
      "eventTitle": "Man Utd - Southampton",
      "eventDate": "2023-05-18T07:11:01.05Z",
      "outcomeId": "1947496370",
      "outcomeGroupTitle": "WINNER",
      "outcomeTitle": "2",
      "blockTitle": "Main time",
      "additionalValue": null,
      "sportTypeTitle": "FootBall",
      "sportTypeId": 128,
      "iconUrl": "soccer"
    }
  }
]
[
  {
    "betType": "EXPRESS",
    "status": 3,
    "totalFactor": 3.6,
    "orderDate": "2024-02-06T18:29:17.163Z",
    "barcode": "167798842222221111312621221",
    "positions": [
      {
        "positionId": 1,
        "factorValue": 3.6,
        "status": 3,
        "eventId": "174848522722",
        "eventTitle": "Man Utd - Southampton",
        "eventDate": "2024-02-076T18:29:17.163Z",
        "outcomeId": "194749637022",
        "outcomeGroupTitle": "Over/under:",
        "outcomeTitle": "Over",
        "blockTitle": "2.5",
        "additionalValue": null,
        "sportTypeTitle": "FootBall",
        "sportTypeId": 128,
        "iconUrl": "https://cdn-icons-png.flaticon.com/512/1165/1165249.png",
      },
      {
        "positionId": 2,
        "factorValue": 3.6,
        "status": 3,
        "eventId": "174848522722",
        "eventTitle": "Man Utd - Southampton",
        "eventDate": "2024-02-07T18:29:17.163Z",
        "outcomeId": "194749637022",
        "outcomeGroupTitle": "Results:",
        "outcomeTitle": "Win1",
        "blockTitle": null,
        "additionalValue": null,
        "sportTypeTitle": "FootBall",
        "sportTypeId": 128,
        "iconUrl": "https://cdn-icons-png.flaticon.com/512/1165/1165249.png",
      }
    ]
  }
]
[
  {
    "betType": "BETBUILDER",
    "status": 3,
    "totalFactor": 3.6,
    "orderDate": "2024-06-24T09:29:17.163Z",
    "barcode": "1979559627589",
    "positions": [
      {
        "positionId": 1,
        "status": 1,
        "factorValue": 3.6,
        "eventId": "17484857",
        "eventTitle": "Man Utd - Southampton",
        "eventDate": "2023-06-24T07:11:01.05Z",
        "outcomeId": "1947411370",
        "outcomeGroupTitle": "WINNER",
        "outcomeTitle": "4",
        "blockTitle": "Man Utd - Southampton",
        "additionalValue": null,
        "sportTypeTitle": "FootBall",
        "sportTypeId": 128,
        "iconUrl": "https://cdn-icons-png.flaticon.com/512/1165/1165249.png",
        "betBuilderStakes": [
          {
            "periodName": "Full Time",
            "outcomeGroupTitle": "Result:",
            "outcomeTitle": "Win 1",
            "argument": 1.5,
            "status": 1,
            "stakeId": 3294114553
          },
          {
            "periodName": "Full Time",
            "outcomeGroupTitle": "Result:",
            "outcomeTitle": "Win 1",
            "argument": 1.5,
            "status": 2,
            "stakeId": 3294114553
          },
          {
            "periodName": "Full Time",
            "outcomeGroupTitle": "Result:",
            "outcomeTitle": "Win 1",
            "argument": 1.5,
            "status": 1,
            "stakeId": 3294114553
          }
        ]
      },
      {
        "positionId": 2,
        "status": 1,
        "factorValue": 3.6,
        "eventId": "17484857",
        "eventTitle": "Barcelona - Real Sociedad",
        "eventDate": "2023-06-24T07:11:01.05Z",
        "outcomeId": "19474963660",
        "outcomeGroupTitle": "WINNER",
        "outcomeTitle": "4",
        "blockTitle": "Man Utd - Southampton",
        "additionalValue": null,
        "sportTypeTitle": "FootBall",
        "sportTypeId": 128,
        "iconUrl": "https://cdn-icons-png.flaticon.com/512/1165/1165249.png",
        "betBuilderStakes": [
          {
            "periodName": "Full Time",
            "outcomeGroupTitle": "Result:",
            "outcomeTitle": "Win 1",
            "argument": 1.5,
            "status": 1,
            "stakeId": 3294114553
          }
        ]
      }
    ]
  }
]

Bet Copying

User can click on other users' widgets in the chat to repeat the bet. The chat sends postMessage with name ‘betRepeat’ by Javascript channel to Partner’s App with payload:

If user copy multi-bets - array should have many objects of bets

{
    "type": "betRepeat",
    "body": {
        "action": "share",
        "data": {
            "betParams": [
                {
                    "eventId": "17490124",
                    "eventTitle": "Man Utd - Southampton",
                    "outcomeId": "2147764145"
                },
                {
                    "eventId": "17490125",
                    "eventTitle": "Real M - Liverpool",
                    "outcomeId": "2147764743"
                }
            ],
          "barcode": "123456789", // Bet id
          "userid": "encrypted_external_id" // Encrypted userid
        }
    }
}

Optional: Sending Bet Data After Successful Placement

To enhance user engagement, the widget can display the number of times a bet has been repeated by other users. This feature is optional and requires additional backend communication.

API Request:

curl \
	--header "Authorization: Bearer <token>"
  --request POST \
  --data '<payload>' \
  http://chatbackend.watchers.io/bet/repeat

Payload:

{
	"barcode" : "12345678", // Bet ID - which successfully repeated
	"apiKey": "{API KEY}"
}

Response:

{
  "id": 1,
  "barcode": "122607993041",
  "timesRepeated": 7,
  "data": null
}

Requirements to Partners App and Provided API

Receiving postMessage from the chat by the application is required. The chat sends a postMessage named “copyBet” to the partner's application via the JavaScript channel with the following payload:

If the user copies multiple bets, the array should contain multiple bet objects.

{
    "type": "betRepeat",
    "body": {
        "action": "share",
        "data": {
            "betParams": [
                {
                    "eventId": "17490124",
                    "eventTitle": "Man Utd - Southampton",
                    "outcomeId": "2147764145"
                },
                {
                    "eventId": "17490125",
                    "eventTitle": "Real M - Liverpool",
                    "outcomeId": "2147764743"
                }
            ],
          "barcode": "123456789", // Bet id
          "userid": "encrypted_external_id" // Encrypted userid
        }
    }
}

API to retrieve last placed bets is required. It should be an array of the last placed bets by userId in format below sorted by betDate

URL and Bearer token you should provide via Admin panel

Request GET parameters

ParameterTypeRequiredDescription
limitnumberYesParameter for a pagination
offsetnumberYesParameter for a pagination
clientNumberstringYesUser id

Request headers

ParameterTypeRequiredDescription
AuthorizationstringYesAuthorization: Bearer ${token}

CURL Example

curl 'https://${URL}/getBets?clientNumber=123&limit=10&offset=0' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ${YOUR BEARER TOKEN}'

Required response

[
  {
    "betType": "SINGLE",
    "status": "WIN",
    "totalFactor": 3.6,
    "orderDate": "2023-05-18T09:29:17.163Z",
    "barcode": "167798842222",
    "positions": [
      {
        "positionId": 1,
        "factorValue": 3.6,
        "status": "WIN",
        "eventId": "17484857",
        "eventTitle": "Man Utd - Southampton",
        "eventDate": "2023-05-18T07:11:01.05Z",
        "outcomeId": "1947496370",
        "outcomeGroupTitle": "WINNER",
        "outcomeTitle": "2",
        "blockTitle": "Main time",
        "additionalValue": null,
        "sportTypeTitle": "FootBall",
        "sportTypeId": 128,
        "iconUrl": "https://cdn-icons-png.flaticon.com/512/1165/1165249.png",
      }
    ]
  }
]

Partner’s Backend (Not Required, not running yet)

  • Send POST requests
    After bet repeated, you can send POST request to us This is needed to show users “how much times” bet repeated
    curl -X 'POST' \
      'https://chatbackend.watchers.io/bet/repeat' \
      -H 'accept: application/json' \
      -H 'Authorization: Bearer <Bearer from admin panel>' \
      -H 'Content-Type: application/json' \
      -d '{	"barcode" : "12345678",	"apiKey": "{API KEY}"}'

Frontend to Frontend Integration

Bet Sharing

While using the chat, the user can share one of their previous bets. To display the user's latest bets in the chat, a postMessage is sent when the user opens a bet list in the chat

{
  "type": "betRepeat",
  "body": {
    "action": "showList",
    "data": {}
  }
}

postMessage when user clicks on selected order in list in parner’s app

{
  type: "betRepeat",
    body: {
    action: "sendToChat",
      data: [
      {
          betType: "MULTI", //SINGLE, MULTI, SYSTEM
          status: 3,
          totalFactor: 3.6,
          orderDate: "2024-02-06T18:29:17.163Z",
          barcode: "167798842222221111312621221",
          positions: [
          {
              positionId: 1,
              factorValue: 3.6,
              status: 3,
              eventId: "174848522722",
              eventTitle: "Man Utd - Southampton",
              eventDate: "2024-02-076T18:29:17.163Z",
              outcomeId: "194749637022",
              outcomeGroupTitle: "Over/under:",
              outcomeTitle: "Over",
              blockTitle: "2.5",
              additionalValue: null,
              sportTypeTitle: "FootBall",
              sportTypeId: 128,
          },
          {
              positionId: 2,
              factorValue: 3.6,
              status: 3,
              eventId: "174848522722",
              eventTitle: "Man Utd - Southampton",
              eventDate: "2024-02-07T18:29:17.163Z",
              outcomeId: "194749637022",
              outcomeGroupTitle: "Results:",
              outcomeTitle: "Win1",
              blockTitle: null,
              additionalValue: null,
              sportTypeTitle: "FootBall",
              sportTypeId: 128,
          },
        ],
      },
    ],
  },
}

Bet Copying

A user can click on other users' widgets in the chat to repeat a bet. The application then receives a postMessage like

{
    "type": "betRepeat",
    "body": {
        "action": "share",
        "data": {
            "betParams": [
                {
                    "eventId": "17490124",
                    "eventTitle": "Man Utd - Southampton",
                    "outcomeId": "2147764145"
                },
                {
                    "eventId": "17490125",
                    "eventTitle": "Real M - Liverpool",
                    "outcomeId": "2147764743"
                }
            ],
					"barcode": "123456789", // Bet id
          "userid": "encrypted_external_id" // Encrypted userid
        }
    }
}

Statuses

Order Statuses

Order ID'sOrder StatusColor of Order Statuses"Copy Bet" button
1WonGreenHide
2LostRedHide
3NewOrangeShow
4PendingOrangeShow
5Cashed OutGreenHide
6PendingOrangeShow
7WonGreenHide
8LostRedHide
9Bore DrawGreenHide
10CashbackGreenHide
11MegaBet NewGrayHide
12MegaBet Canceled By OperatorGrayHide
13MegaBet Canceled By PlayerGrayHide
14MegaBet Canceled By SystemGrayHide
15BetGames PendingOrangeHide
16BetGames WonGreenHide
17BetGames LostRedHide
18PaidGreenHide
19Initial WinGreenHide
20AutoBet Canceled By SystemGrayHide
21AutoBet Canceled By PlayerGrayHide
22Autobet PendingOrangeHide
23Goal AheadGreenHide
24CanceledGreenHide
25ReturnGreenHide

Position Statuses

Stacke ID’sStacke StatusColor of Stacke StatusesColor of Visual Status Lines
1PendingOrangeGray
2WonGreenGreen
3LostRedRed
4ReturnGreenGreen
5Lost | ReturnRed | GreenGreen
6Won | ReturnGreen | GreenGreen
7CanceledGreenGreen
8Initial ReturnGreenGreen
9Pending | Initial ReturnOrange | GreenGreen
10Won | Initial ReturnGreen | GreenGreen