Feed integration
Replication Protocol
For reliable data delivery, a simple replication protocol is implemented. From an API point of view, it consists of two methods:
- getting a
snapshotof all sport events - getting
logs(patches) regarding the version
Snapshot
A snapshot is the current state of a sport event. A snapshot has a version that sequentially progresses as the sport event changes. The version is unique across all sport events and it always ascends. The object of a sport event consists of:
fixture- all data on a sport event: status, type, sport, tournament, participants, venue, links to streams, etc.markets- the list of markets with outcomes, odds, and statusesbet_stop- when it'strueplacing bets on this match is suspended at the momentextensions- describes additional extensions that could be attached to the sport event (e.g. see Widgets)
An example of sport event snapshot
The output is formatted for readability, in the real response it will be a single line1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
Log
A log (patch) is a set of changes to a sport event. Every log has a version (v field) which corresponds to the version of the sport event snapshot at the time when the log was created. It means that the current version of the sport event snapshot is equal to the version of the latest log entry of the corresponding sport event. There are several type of logs: match_new / match_update / bet_rollback
Retention policy
A log(patch) is retained for 3 days. Once the retention period has expired, the log is no longer available. If you try to subscribe with a log version that has already expired, the API will return a 409 HTTP code. It means that log with requested version is unavailable. If API returns 409 HTTP code for your latest processed log version it means that you must to resync all sport events by following steps from usage section.
match_new
A match_new Log contains a snapshot of a sport event (a sport event has been added or the client has requested it)
An example of match_new log entry
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
Markets
- The
match_newevent may or may not contain market data. This means that when you first receive amatch_newevent, the market data could be missing. - Do not assume that the initial
match_newevent will always include markets. - Markets that were missing in the initial
match_newevent could be added in subsequentmatch_updateevents.
match_update
For this type of log, the changes field contains the paths along the nodes of the sport event object (separated by /) and the new value of this node. The protocol implies the impossibility of deleting a part of the object.
An example of match_update log entry
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
The current log means the following:
- market
20has been added - market (
841m2t44_5) status has been updated (new status is3) - market (
349) odd (1) value has changed (new value is13) - market (
349) odd (1) value has changed (new value is3.5)
bet stop flag
bet stop flag is activated when a log with bet_stop equals true is received, placing bets on this match must be suspended until a bet stop is deactivated (a log with bet_stop equals false is received). By default bet_stop is deactivated (or in case of fetching sport event snapshot it equals SportEvent.bet_stop).
An example of log entry when placing bets on this match must be suspended
1 2 3 4 5 6 7 8 9 | |
extensions
The extensions entry appears whether there are any updates for at a single extension at least.
Supported extensions:
app.data.bet/widget- defines which Widgets could be attached to the sport event.
An example of log entry when extensions on the match updated
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
Note
Extensions are optional to implement and their updates could be omited.
bet_rollback
The client must roll back all bets on the specified markets within a given period.
Important: Rolling Back All Bets
If the market_ids field is an empty array, all bets associated with the given sport_event_id must be rolled back. This ensures that no bets remain active when the rollback action is intended to apply to the entire event. The absence of specific market_ids signifies that the rollback is not limited to particular
These are possible reasons for the rollback:
1. 322 ā The bet has been canceled due to suspicion of unfair play or match-fixing.
2. crash_of_the_game ā The game was interrupted due to technical issues (beyond our control), preventing the outcome from being determined.
3. after_goal ā The bet was placed after the decisive event (e.g. goal) had already occurred, making it invalid (commonly referred to as a "late bet").
4. technical_error_in_coefficient ā A technical error caused an incorrect coefficient to be specified in the bet.
5. pre_match_bets_after_match_start ā The pre-match bet was placed after the match had already started, making it invalid.
6. duplicate_bet ā A duplicate bet was detected and canceled.
7. streamsniping ā The bet was canceled due to an unfair advantage (e.g. watching live streams in real-time).
An example of a bet_rollback log entry
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
Heartbeat message
Heartbeat is a message used to notify a consumer that a trading feed is alive. Recommended heartbeat interval is 5 seconds. If the client does not receive 2 messages in a row, it is better to reconnect to the feed.
Message contains 2 fields:
- timestamp - date (unix timestamp) when heartbeat is generated
- type - heartbeat (string constant)
An example of a message:
1 2 3 4 | |
Client specified heartbeat interval in seconds via query param heartbeat_interval. For instance (client requests heartbeat message every 5 seconds):
1 2 3 4 5 6 | |
Received messages
1 2 3 4 5 6 7 8 | |
Usage
The correct way to use the feed API is the following:
-
Request all snapshots via
GET /all. In the response, the latest snapshot version will be indicated in theLast-Versionheader, and the sport events themselves will appear in the body, each in a separate line. Chunked transfer encoding is used for streamingsport eventsin HTTP 1.1 (if thesport eventdoes not fit in one line, it can be split into several lines (according to the encoding)).
Get a snapshot request via curl
`client.crt` and `client.key` will be provided by the DATA.BET integration team.The response:1 2 3 4 5
stdbuf -oL curl --request GET \ --url https://feed.int.databet.cloud/all \ --cert client.crt \ --key client.key \ --verbose \1 2 3 4 5 6 7 8 9 10 11 12
... < Last-Version: 1znkQdjQYSW000004gfKZM < Last-Version-Hex: 174213d5391edf1000000001000050b8 < X-Api-Version: 2 < Date: Thu, 09 Feb 2023 06:28:20 GMT < Transfer-Encoding: chunked < 7576 {"id":"1c43b19f-ba50-4e78-adfd-e347b1605e58","meta":{"bo": 3, "map": 1, "time": "0", "timer_running": false},"markets":{},"fixture":{"id": "1c43b19f-ba50-4e78-adfd-e347b1605e58", "meta": {"bo": 3, "map": 1, "time": "0", "timer_running": false}, "type": 0, "status": 0, "streams": {}, "version": 12, "sport_id": "esports_dota_2", "template": "{$competitor1} vs {$competitor2}","start_time": "2022-12-01T20:20:00Z", "tournament": {"id": "betting:1:sr:simple_tournament:66859", "name": "Indonesia, Pro Circuit, Minor 2018, Playoffs", "master_id": "betting:1:sr:simple_tournament:66859", "country_code": ""}, "updated_at": "2022-12-01T20:16:03Z", "competitors": {"betting:0:2-esports_dota_2": {"id": "betting:0:2-esports_dota_2", "meta": {}, "name": "Liquid", "type": 2, "scores": {"map:1": {"id": "map:1", "type": "map", "number": 1, "points": "0"}, "total": {"id": "total", "type": "total", "number": 0, "points": "0"}}, "home_away": 1, "master_id": "betting:0:2-esports_dota_2", "country_code": "ALB", "template_position": 1}, "betting:0:40-esports_dota_2": {"id": "betting:0:40-esports_dota_2", "meta": {}, "name": "qwerqwer", "type": 2, "scores": {"map:1": {"id": "map:1", "type": "map", "number": 1, "points": "0"}, "total": {"id": "total", "type": "total", "number": 0, "points": "0"}}, "home_away": 2, "master_id": "betting:0:40-esports_dota_2", "country_code": "", "template_position": 2}},"live_coverage": false},"bet_stop":false,"sources":[{"id": "dp:grid:18", "type": "grid"}],"updated_at":"2023-02-04T20:24:21.828841Z"} ... 9cd7 {"id":"4e6f3b19-b5df-4042-99d0-c8fa918be78b","meta":{"bo": 3, "map": 1, "time": "0", "timer_running": false},"markets":{},"fixture":{"id": "4e6f3b19-b5df-4042-99d0-c8fa918be78b", "meta": {"bo": 3, "map": 1, "time": "0", "timer_running": false}, "type": 0, "status": 0, "streams": {}, "version": 12, "sport_id": "esports_dota_2", "template": "{$competitor1} vs {$competitor2}","start_time": "2022-12-01T20:22:00Z", "tournament": {"id": "betting:0:test-esports_dota_2-esports_dota_2", "name": "", "master_id": "betting:0:test-esports_dota_2-esports_dota_2", "country_code": ""}, "updated_at": "2022-12-01T20:22:16Z", "competitors": {"betting:0:40-esports_dota_2": {"id": "betting:0:40-esports_dota_2", "meta": {}, "name": "qwerqwer", "type": 2, "scores": {"map:1": {"id": "map:1", "type": "map", "number": 1, "points": "0"}, "total": {"id": "total", "type": "total", "number": 0, "points": "0"}}, "home_away": 1, "master_id": "betting:0:40-esports_dota_2", "country_code": "", "template_position": 1}, "betting:0:47-esports_dota_2": {"id": "betting:0:47-esports_dota_2", "meta": {}, "name": "CSW", "type": 2, "scores": {"map:1": {"id": "map:1", "type": "map", "number": 1, "points": "0"}, "total": {"id": "total", "type": "total", "number": 0, "points": "0"}}, "home_away": 2, "master_id": "betting:0:47-esports_dota_2", "country_code": "", "template_position": 2}},"live_coverage": false},"bet_stop":false,"sources":[{"id": "dp:steam:00000000-0000-0000-0000-000000000000", "type": "steam"}],"updated_at":"2023-02-04T20:33:01.471877Z"} -
Save the snapshots and
version(Last-Versionheader) from the previous response -
Subscribe to sport events updates using
GET /logspecifying the last savedversionfrom step 1. The version value should be set in theLast-Versionheader. In the response, the server will send a line-by-line log of sports event updates. Chunked transfer encoding is used for streaminglogsin HTTP 1.1 (if thelogdoes not fit in one line, it can be split into several lines (according to the encoding)).
Get a log request (curl)
`client.crt` and `client.key` will be provided by the DATA.BET integration team.The response:1 2 3 4 5 6
stdbuf -oL curl --request GET \ --url https://feed.int.databet.cloud/log \ --cert client.crt \ --key client.key \ --header 'Last-Version: 1znkFqdSqYk000004gfTOF' \ --verbose \1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
... < HTTP/1.1 200 OK < Cache-Control: no-cache, no-store, must-revalidate < Content-Type: text/event-stream; charset=utf-8 < X-Api-Version: 2 < Date: Thu, 09 Feb 2023 06:19:26 GMT < Transfer-Encoding: chunked < 8000 {"v":"1znkLg245Jk000004gfFMU","sport_event_id":"2c33429b-83b2-408a-826f-bd13aa8e005e","type":"match_new","timestamp":1675923535,"sport_event":{"id":"2c33429b-83b2-408a-826f-bd13aa8e005e","meta":{"bo":1,"game_state":"map","match_format":"default","state_number":1,"timer_running":false},"fixture":{"id":"2c33429b-83b2-408a-826f-bd13aa8e005e","meta":{"bo":1,"game_state":"map","match_format":"default","state_number":1,"timer_running":false},"type":0,"status":3,"streams":{},"sport_id":"esports_counter_strike"," 1d1 template":"{$competitor1} vs {$competitor2}","start_time":"2025-09-27T21:00:00Z","tournament":{"id":"betting:0:aaa-esports_battlegrounds-esports_battlegrounds","name":"OLOLOLOв","master_id":"betting:0:aaa-esports_battlegrounds-esports_battlegrounds","country_code":"WW-OCEANIA"},"updated_at":"2023-02-09T06:18:55Z","competitors":{"betting:0:10-esports_counter_strike":{"id":"betting:0:10-esports_counter_strike","meta":{},"name":"team1","type":2,"scores":{"map:1":{"id":"map:1","type":"map","number":1,"points":"0"},"total":{"id":"total","type":"total","number":0,"points":"0"}},"home_away":1,"master_id":"betting:0:10-esports_counter_strike","country_code":"","template_position":1},"betting:0:24-esports_counter_strike":{"id":"betting:0:24-esports_counter_strike","meta":{},"name":"","type":2,"scores":{"map:1":{"id":"map:1","type":"map","number":1,"points":"0"},"total":{"id":"total","type":"total","number":0,"points":"0"}},"home_away":2,"master_id":"betting:0:24-esports_counter_strike","country_code":"","template_position":2}},"live_coverage":false},"markets":{},"updated_at":"2023-02-09T06:18:55Z"}} ... 7434 {"v":"1znkeVDlTrX000004gfQoX","sport_event_id":"1cbfc304-b10f-4c5c-b257-de1bff68de9f","type":"match_update","timestamp":1675924605,"changes":{"updated_at":"2023-02-09T06:36:45Z","fixture/competitors/betting:7:sr:competitor:103141/score/golden_set/points":"4"}}
Most common issues:
1 2 | |
- Every log contains the
version(vfield), after applying changes from the log, theversionshould be saved (similar to step 2) in order to be used for re-subscription (if the client's server restarts, the client has to start from step 3)
Refetch the snapshot for a specific sport event
The client can refetch a snapshot for a specific sport event (due to the logs of the sports being lost or incorrectly applied) by sending the request POST /refetch/sport-event/{sportEventId}, A match_new log entry will be added to the log with the latest version of sport event.
Conditions for accepting bets
In case if our Managed trading services (MTS) is not used some sport event properties should be taken into account when accepting bets.
Fixture status
There are 9 fixture statuses:
0 - not started (prematch sport event)
1 - live (live sport event)
2 - suspended (live sport event, sport event should be visible for bettors but placing bets should be temporarily suspended, sport event could return to Live (1))
3 - ended (sport event is ended)
4 - closed (the acceptance of bets on a sport event is closed, sport event will never become live/prematch)
5 - cancelled (deprecated) (sport event is cancelled, will never become live/prematch)
6 - abandoned (deprecated) (will never become live/prematch)
7 - delayed (sport event postponed to a different time, can become live/prematch)
8 - unknown (status applies when none of the other statuses would be correct, regardless of whether the event is new, can become live/prematch)
Placing bets must be allowed only in not started (0) and live (1) statuses.
Sport event must be visible for bettors in not started (0) and live (1) and suspended (2) statuses.
Market status
There are 5 market statuses:
0 - active (bets are allowed)
1 - suspended (bets are currently not allowed but market could return to the active state)
2 - deactivated (market is not active, bets are not allowed)
3 - resulted (market has settled, bets are not allowed)
4 - cancelled (market is cancelled, bets are not allowed)
Placing bets must be allowed only in active (0) status.
Suspended markets must be visible for bettor but their odds should be hidden(bets are currently not allowed, but market could return to the active state)
Odd status and its active state
There are 7 odd statuses:
0 - not resulted (bets are allowed)
1 - win
2 - loss
3 - half win (asian handicaps)
4 - half loss (asian handicaps)
5 - refunded (all the bets should be refunded because market could not be resulted, for example: market winner for the 5th round could not be resulted if a game ended in the 3rd round)
6 - cancelled (deprecated) (all the bets should be refunded because of the reason that doesn't match refunded)
And Odd has property is_active - if it is false - placing bets should be suspended. Therefore placing bets on Odd must be allowed only if Odd is active (is_active is true) AND odd status is not resulted (0).
Bet stop
If a bet stop flag is activated placing bets on this match must be suspended. Here is a description of the conditions when the flag is activated and deactivated, as well as the event that triggers this changes.
Summary
Placing bets must be allowed if only ALL conditions are met:
Fixture status is not started (0) OR live (1) AND
Market status is active (0) AND
Odd status is not resulted (0) and Odd is_active AND
bet stop flag is deactivated
An example of sport event
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
It's allowed to place bets on market.id 20 and its odds with id 2 and 3 because fixture status is not started (0) AND market status is active AND odd status is not_resulted (0) AND odd is active (is_active=true).
It's forbidden to place bets on market.id 20 and its odd with id 1 because odd is NOT active (is_active=false).
It's forbidden to place bets on any outcome of market.id 21 because market status is suspended (NOT active).