Match - via Webhook

Match - via Webhook

Match information available through the Match API endpoint, automatically updated and delivered to your Webhook URL in real-time.

Configuring your Console

Follow the instructions below to receive automated cricket match updates in your Webhook URL.
  1. Login to your Roanuz Sports Console and from the Dashboard, click on Push Configuration and select the Webhook Option.
  2. Now, in the text boxes, paste your Webhook URLs to which you want the data to be delivered automatically.
  3. Make sure to set up your webhook URL to handle the data correctly. A sample code has been provided under the “Handling the data received” section.

Send a Subscription Request

Once your console is set up, you will have to subscribe to the matches individually for receiving automatic updates. The sample snippet below demonstrates how to send a subscription request from the Match Subscribe API. Please note that subscribing twice to the same match does not mean that you will be charged twice, or you will receive the same update twice.

Match Subscribe - Webhook

terminal
pip install requests
pip install requests
icon copy
Python
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/{}/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/{}/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())
icon copy

Handle the data received

Once successfully set up, Roanuz Cricket API servers will automatically start pushing data to your systems as the match progresses. There could be situations where your server accepts the event but fails to respond within 3 seconds; in such cases, the session is marked as a timeout. Below are sample snippets demonstrating how to handle the data once it is pushed by the server in both Python and Node.js.

Handle the data received- Webhook

TERMINAL
pip install flask
pip install flask
icon copy
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! {}'
icon copy

Unsubscribe from a Match

For any reasons, if you wish to opt-out of automatic updates for a match, you can do so by placing an unsubscribe request from the Match Unsubscribe API.

Match Unsubscribe - Webhook

TERMINAL
pip install requests
pip install requests
icon copy
match_unsubscribe_webhook.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/{}/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/{}/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())
icon copy

Scenarios

We recommend you to go through the following scenarios and keep them in mind while developing your application. A sound knowledge of these scenarios should help you in maintaining the quality of your app.

Live Match Updates

Use Case: Reflect every run, wicket, or ball update in a fantasy app. Webhook Behavior: When a ball is bowled or a wicket falls in MG100 matches, webhook events deliver updated data including live.recent_overs, partnership, score, and batsman details. This ensures real-time updates without polling.

Live Score Widgets

Use Case: Maintain a live scoreboard widget on a match center. Webhook Behavior: Webhook events push updated values for live.score, recent_overs_repr (available in MG100 matches), and players, enabling real-time updates to the scoreboard, batting cards, and bowling cards.

Match Notifications

Use Case: Detect player milestones such as half-centuries, centuries, or five-wicket hauls. Webhook Behavior: Events are triggered when player statistics or live.player_of_the_match are updated. The webhook provides the latest values that can be used to flag milestones.

Live Commentary and Ball-by-Ball Tracking

Use Case: Show the outcome of each ball on a live commentary dashboard. Webhook Behavior: In MG100 matches, related_balls provides full detail for every delivery, including batsman, bowler, outcome, dismissal type, and commentary. The data can be used to maintain ball-by-ball feeds.

Handling Super Overs and Special Innings

Use Case: Accurately display innings data when super overs occur. Webhook Behavior: During a super over, additional innings such as a_superover and b_superover are added to the innings object — representing the first super over’s innings for each side. If the first super over ends in a tie, new keys like a_superover1, b_superover1 are added for the next super over. Webhook events reflect these additions, allowing the UI to update innings flow without delay.

Match Abandonment or Draw Detection

Use Case: Mark a match as void or issue refunds on fantasy platforms. Webhook Behavior: When status_overview is updated to values like "drawn", "abandoned", or "no_result", a webhook event is triggered with the updated match state.

Upcoming Match Alerts

Use Case: Trigger pre-match alerts or display toss updates. Webhook Behavior: Webhook triggers can be set based on time proximity (e.g., 10 hours before start_time) or when toss information becomes available. These can be used to activate banners, notifications, or pre-match states.

Recent Balls Widget on Homepage

Use Case: Display the last three overs in a visual widget. Webhook Behavior: The live.recent_overs_repr and related_balls objects are pushed via webhook during live MG100 matches. These objects include data for the last three overs of the current innings, including balls that resulted in dismissals.