Deal Sharing/Copying
Overview
Deal copying/ copy-trading widget allows users to effortlessly share their deals and copy each other's deals with a simple click.
To share a deal, a user clicks the button on a chat, chooses a deal for sharing, and sends it to the chat, avoiding personal data about the amount of money. Other users on the chat can repeat this deal by clicking on the widget (the deal 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, make a deal, share it or copy someone else’s deal.
Integration
The integration of copy-dealing widget into your application involves several core steps, including both front-end and back-end processes:
Sending Deal Data: once a user shares a deal, your application needs to send relevant data to our backend. This includes details like room ID, user ID, bet type, status, total factor, date, game ID, event ID, and outcome ID among others.
Retrieving User Deals: to facilitate deal 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 Deal Placement (is not running yet): upon successful placement of a copied deal, 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 dealing in a partner app
- While using a chat the user shares one of their previous deals.
- User can click on other users' widgets in the chat to repeat a deal.
Backend-to-Backend Integration
Bet Sharing
To display the user's latest deals in the chat, we will call this API whenever the user opens the "last deals" list.
The API should return an array of the user's most recent deals identified by userId, formatted as shown below and sorted by betDate.
Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
limit | number | Yes | Parameter for a pagination |
offset | number | Yes | Parameter for a pagination |
clientNumber | string | Yes | Parameter to indentify user on partner 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 a deal. The chat sends postMessage with name ‘betRepeat’ by Javascript channel to Partner’s App with payload:
If user copy multi-deals- 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 Deal Data After Successful Placement
To enhance user engagement, the widget can display the number of times the deal 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/repeatPayload:
{
"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 deals by userId in format below sorted by betDate
URL and Bearer token you should provide via Admin panel
Request GET parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
limit | number | Yes | Parameter for a pagination |
offset | number | Yes | Parameter for a pagination |
clientNumber | string | Yes | User id |
Request headers
| Parameter | Type | Required | Description |
|---|---|---|---|
Authorization | string | Yes | Authorization: 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” deal repeatedcurl -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
Deal Sharing
While using the chat, the user can share one of their previous deals. To display the user's latest deals in the chat, a postMessage is sent when the user opens a deal list in the chat
{
"type": "betRepeat",
"body": {
"action": "showList",
"data": {}
}
}postMessage when user clicks on selected order in list in partner’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,
},
],
},
],
},
}Deal Copying
A user can click on other users' widgets in the chat to repeat a deal. 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's | Order Status | Color of Order Statuses | "Copy Bet" button |
|---|---|---|---|
| 1 | Won | Green | Hide |
| 2 | Lost | Red | Hide |
| 3 | New | Orange | Show |
| 4 | Pending | Orange | Show |
| 5 | Cashed Out | Green | Hide |
| 6 | Pending | Orange | Show |
| 7 | Won | Green | Hide |
| 8 | Lost | Red | Hide |
| 9 | Bore Draw | Green | Hide |
| 10 | Cashback | Green | Hide |
| 11 | MegaBet New | Gray | Hide |
| 12 | MegaBet Canceled By Operator | Gray | Hide |
| 13 | MegaBet Canceled By Player | Gray | Hide |
| 14 | MegaBet Canceled By System | Gray | Hide |
| 15 | BetGames Pending | Orange | Hide |
| 16 | BetGames Won | Green | Hide |
| 17 | BetGames Lost | Red | Hide |
| 18 | Paid | Green | Hide |
| 19 | Initial Win | Green | Hide |
| 20 | AutoBet Canceled By System | Gray | Hide |
| 21 | AutoBet Canceled By Player | Gray | Hide |
| 22 | Autobet Pending | Orange | Hide |
| 23 | Goal Ahead | Green | Hide |
| 24 | Canceled | Green | Hide |
| 25 | Return | Green | Hide |
Position Statuses
| Stacke ID’s | Stacke Status | Color of Stacke Statuses | Color of Visual Status Lines |
|---|---|---|---|
| 1 | Pending | Orange | Gray |
| 2 | Won | Green | Green |
| 3 | Lost | Red | Red |
| 4 | Return | Green | Green |
| 5 | Lost | Return | Red | Green | Green |
| 6 | Won | Return | Green | Green | Green |
| 7 | Canceled | Green | Green |
| 8 | Initial Return | Green | Green |
| 9 | Pending | Initial Return | Orange | Green | Green |
| 10 | Won | Initial Return | Green | Green | Green |
Updated 3 days ago