Ball By Ball Detail Push via Webhook
Ball By Ball Detail Push via Webhook
Receive real-time match updates for every ball and critical match events (only for live matches). Use the Match Ball-by-Ball API for comprehensive details on each delivery.
Configuring your Console
Follow these steps to set up automated match updates directly to your Webhook URL:
- Log in to the Roanuz Sports Console and navigate to the Dashboard.
- Go to Push Configuration and select the Webhook option.
- Enter Your Webhook URL in the designated field to receive updates.
- Ensure Webhook Handling: Set up your webhook to process the incoming data effectively. A sample code snippet is available under "Handling Data Received."
Scenarios
Once your console is configured, the API sends notifications for every ball and significant match events. Below are examples of updates you may receive:
Changes in Match Related Data (e.g., Name Change)
This scenario sends an update to indicate changes in the match data (like the name or other metadata). The API captures the timestamp (
ts
), match key, and specific push reason (e.g., a name change).Changes in Match Related Data
{
"sport": "cricket",
"data_kind": "match-detail-update",
"data": {
"matchkey": "match_key",
"ball": null,
"push_reason": "Other",
"match_push_kind": "Info",
"ts": 1733148565
}
}
{
"sport": "cricket",
"data_kind": "match-detail-update",
"data": {
"matchkey": "match_key",
"ball": null,
"push_reason": "Other",
"match_push_kind": "Info",
"ts": 1733148565
}
}
Toss Update
This event indicates that the toss has occurred, and the relevant data about it is being updated. The API doesn't include a specific ball, but it updates the
match_push_kind
as "Toss" to reflect the event.Toss Update
{
"sport": "cricket",
"data_kind": "match-detail-update",
"data": {
"matchkey": "match_key",
"ball": null,
"push_reason": "Other",
"match_push_kind": "Toss",
"ts": 1733148590
}
}
{
"sport": "cricket",
"data_kind": "match-detail-update",
"data": {
"matchkey": "match_key",
"ball": null,
"push_reason": "Other",
"match_push_kind": "Toss",
"ts": 1733148590
}
}
Play Status Update
This API call signals changes in the current play status of the match, such as when a match is in play, a delay occurs, or any other status-related change. It uses the
match_push_kind
of "Play."3. Play Status Update
{
"sport": "cricket",
"data_kind": "match-detail-update",
"data": {
"matchkey": "match_key",
"ball": null,
"push_reason": "Other",
"match_push_kind": "Play",
"ts": 1733148628
}
}
{
"sport": "cricket",
"data_kind": "match-detail-update",
"data": {
"matchkey": "match_key",
"ball": null,
"push_reason": "Other",
"match_push_kind": "Play",
"ts": 1733148628
}
}
Squad Update
This event notifies any changes to the squad of players participating in the match. It sends information about updates in the team lineup or replacements. No ball-related details are provided in this case.
4. Squad Update
{
"sport": "cricket",
"data_kind": "match-detail-update",
"data": {
"matchkey": "match_key",
"ball": null,
"push_reason": "Other",
"match_push_kind": "Squad",
"ts": 1733148670
}
}
{
"sport": "cricket",
"data_kind": "match-detail-update",
"data": {
"matchkey": "match_key",
"ball": null,
"push_reason": "Other",
"match_push_kind": "Squad",
"ts": 1733148670
}
}
Ball Update (Runs Scored)
A ball update occurs when the data for a specific ball bowled is updated, such as the runs scored, whether it's a four or six, and other statistics related to the ball. The
ball_key
, over number, and relevant details are included in this event.5. Ball Update (Runs Scored)
{
"sport": "cricket",
"data_kind": "match-detail-update",
"data": {
"matchkey": "match_key",
"ball": {
"ball_key": 524352,
"over": 0,
"batting_order": 1,
"is_delete": false,
"detail": {
"key": "524352",
"ball_type": "normal",
"batting_team": "b",
"comment": "Vinod Srinivasan to Vyshakh Jagannivasan: <b>FOUR</b>. 4 runs.",
"innings": "b_1",
"overs": [0, 1],
"batsman": {
"player_key": "player_key",
"ball_count": 1,
"runs": 4,
"is_dot_ball": false,
"is_four": true,
"is_six": false},
"bowler": {
"player_key": "player_key",
"ball_count": 1,
"runs": 4,
"extras": 0,
"is_wicket": false},
"team_score": {
"ball_count": 1,
"runs": 4,
"extras": 0,
"is_wicket": false},
"fielders": [],
"wicket": null,
"non_striker_key": "player_key",
"entry_time": 1733148685.812,
"ball_play_status": "played",
"ball_tags": [],
"updated_time": 1733148685.812,
"repr": "b4"
}
},
"push_reason": "NewOrLast",
"match_push_kind": "Ball",
"ts": 1733148686.425609
}
}
{
"sport": "cricket",
"data_kind": "match-detail-update",
"data": {
"matchkey": "match_key",
"ball": {
"ball_key": 524352,
"over": 0,
"batting_order": 1,
"is_delete": false,
"detail": {
"key": "524352",
"ball_type": "normal",
"batting_team": "b",
"comment": "Vinod Srinivasan to Vyshakh Jagannivasan: <b>FOUR</b>. 4 runs.",
"innings": "b_1",
"overs": [0, 1],
"batsman": {
"player_key": "player_key",
"ball_count": 1,
"runs": 4,
"is_dot_ball": false,
"is_four": true,
"is_six": false},
"bowler": {
"player_key": "player_key",
"ball_count": 1,
"runs": 4,
"extras": 0,
"is_wicket": false},
"team_score": {
"ball_count": 1,
"runs": 4,
"extras": 0,
"is_wicket": false},
"fielders": [],
"wicket": null,
"non_striker_key": "player_key",
"entry_time": 1733148685.812,
"ball_play_status": "played",
"ball_tags": [],
"updated_time": 1733148685.812,
"repr": "b4"
}
},
"push_reason": "NewOrLast",
"match_push_kind": "Ball",
"ts": 1733148686.425609
}
}
Review Update (Pre, Post, Match Validation)
This update involves any review decisions or changes during or after the match, such as when the umpire refers to the third umpire for a decision. The
match_push_kind
is set to "Review."6. Review Update (Pre, Post, Match Validation)
{
"sport": "cricket",
"data_kind": "match-detail-update",
"data": {
"matchkey": "match_key",
"ball": null,
"push_reason": "Other",
"match_push_kind": "Review",
"ts": 1733148707
}
}
{
"sport": "cricket",
"data_kind": "match-detail-update",
"data": {
"matchkey": "match_key",
"ball": null,
"push_reason": "Other",
"match_push_kind": "Review",
"ts": 1733148707
}
}
Result Update
This API sends a message when the match result is determined. It doesn't include ball-by-ball data but focuses on the final outcome, whether it's a win, loss, or draw.
7. Result Update
{
"sport": "cricket",
"data_kind": "match-detail-update",
"data": {
"matchkey": "match_key",
"ball": null,
"push_reason": "Other",
"match_push_kind": "Result",
"ts": 1733148721
}
}
{
"sport": "cricket",
"data_kind": "match-detail-update",
"data": {
"matchkey": "match_key",
"ball": null,
"push_reason": "Other",
"match_push_kind": "Result",
"ts": 1733148721
}
}
Reward Update (Player of the Match)
This update provides information on the "Player of the Match" award. It includes the match key and a timestamp for when the award is given.
8. Reward Update (Player of the Match)
{
"sport": "cricket",
"data_kind": "match-detail-update",
"data": {
"matchkey": "match_key",
"ball": null,
"push_reason": "Other",
"match_push_kind": "Reward",
"ts": 1733148725
}
}
{
"sport": "cricket",
"data_kind": "match-detail-update",
"data": {
"matchkey": "match_key",
"ball": null,
"push_reason": "Other",
"match_push_kind": "Reward",
"ts": 1733148725
}
}
Other Changes (Miscellaneous Updates)
This event is a catch-all for any changes that don't fall under the predefined categories. It includes other match details, updates, or corrections that need to be pushed to clients.
9. Other Changes (Miscellaneous Updates)
{
"sport": "cricket",
"data_kind": "match-detail-update",
"data": {
"matchkey": "match_key",
"ball": null,
"push_reason": "Other",
"match_push_kind": "Other",
"ts": 1733148680
}
}
{
"sport": "cricket",
"data_kind": "match-detail-update",
"data": {
"matchkey": "match_key",
"ball": null,
"push_reason": "Other",
"match_push_kind": "Other",
"ts": 1733148680
}
}
Subscription Types
Subscribe to the Update Subscription for confirmed and cached data. Ideal for high-traffic matches, this subscription ensures accurate updates.
Update Subscription
1.Trigger: When the match data is confirmed and cached.
- Notification: You’ll get a notification only after the ball data is confirmed as updated and recached. This is ideal for high-traffic or high-importance matches.
- Data Type:
match-related-update
Ball by Ball Detail Push - Updates Subscribe
TERMINAL
pip install requests
pip install requests
ball_by_ball_detail_updates.py
import requests
project_key = 'YOUR_PROJ_KEY'
token = 'YOUR_ACCESS_TOKEN'
match_key = 'ausind_2020_odi01'
url = "https://api.sports.roanuz.com/v5/cricket/{}/match/{}/detail-updates-subscribe/".format(project_key,match_key)
headers = {
'rs-token': token
}
payload = {
'method': "web_hook"
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
import requests
project_key = 'YOUR_PROJ_KEY'
token = 'YOUR_ACCESS_TOKEN'
match_key = 'ausind_2020_odi01'
url = "https://api.sports.roanuz.com/v5/cricket/{}/match/{}/detail-updates-subscribe/".format(project_key,match_key)
headers = {
'rs-token': token
}
payload = {
'method': "web_hook"
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
Handle the data received
Once configured, updates will automatically push to your system. Use the following sample code to handle incoming data:
TERMINAL
pip install flask
pip install flask
webhook_handle_data.py
from flask import Flask, request
import gzip
import io
import json
app = Flask(__name__)
@app.route('/', methods=['POST'])
def hello():
print("Received")
c_data = io.BytesIO(request.data)
text_data = gzip.GzipFile(fileobj=c_data, mode='r')
byte_str = text_data.read()
dict_str = byte_str.decode("UTF-8")
mydata = json.loads(dict_str)
print(mydata)
print("____")
return 'Hello, World! {}'
from flask import Flask, request
import gzip
import io
import json
app = Flask(__name__)
@app.route('/', methods=['POST'])
def hello():
print("Received")
c_data = io.BytesIO(request.data)
text_data = gzip.GzipFile(fileobj=c_data, mode='r')
byte_str = text_data.read()
dict_str = byte_str.decode("UTF-8")
mydata = json.loads(dict_str)
print(mydata)
print("____")
return 'Hello, World! {}'
Unsubscribe from Ball by Ball Detail Push
If, for any reason, you wish to opt-out of automatic push updates for the Ball by Ball Detail push notifications, you can easily unsubscribe.
Ball by Ball Detail Push - Unsubscribe
TERMINAL
pip install requests
pip install requests
ball_by_ball_detail_updates_unsubscribe.py
import requests
project_key = 'YOUR_PROJ_KEY'
token = 'YOUR_ACCESS_TOKEN'
match_key = 'ausind_2020_odi01'
url = "https://api.sports.roanuz.com/v5/cricket/{}/match/{}/detail-updates-unsubscribe/".format(project_key,match_key)
headers = {
'rs-token': token
}
payload = {
'method': "web_hook"
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
import requests
project_key = 'YOUR_PROJ_KEY'
token = 'YOUR_ACCESS_TOKEN'
match_key = 'ausind_2020_odi01'
url = "https://api.sports.roanuz.com/v5/cricket/{}/match/{}/detail-updates-unsubscribe/".format(project_key,match_key)
headers = {
'rs-token': token
}
payload = {
'method': "web_hook"
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())