Blog

Cricket APIs: Match Ball-by-Ball API

Oct. 18, 2023

Are you looking to supercharge your cricket-related applications and provide an immersive experience to cricket applications and businesses? The Match Ball-by-Ball API is your gateway to real-time, detailed cricket match updates. Whether you're a cricket app developer, a sports news platform, or any cricket-related service, this API offers valuable insights into the world of cricket. Let's explore what you can achieve with this powerful API.

Match Ball-by-Ball API

What is the Match Ball-by-Ball API?

The Match Ball-by-Ball API is a powerful API that delivers detailed ball-by-ball updates for every over in a cricket innings. It also provides comprehensive information, including ball type, batsman details, bowler information, wicket status, and the live ball scores, for the requested over of an innings.

How Does It Work?

Imagine you have a cricket application that is displaying the match score, and you want to know exactly what's happening in each over. The Match Ball-by-Ball API has you covered. By making simple HTTP REST API calls, you can fetch real-time ball-by-ball data for any match, over, or innings. Let's dive into the details of how it all comes together.

What you get?

1. In-Depth Match Insights
  • Over-by-Over Updates: Access ball-by-ball commentary on an over-by-over basis, allowing your users to stay updated with every moment of the game.
2. Seamless Integration
  • Easy Access: Make HTTP REST calls to the API with straightforward URL structures and parameters. Integration is a breeze, allowing you to focus on providing valuable content to your users.
3. User Engagement
  • Real-Time Updates: Keep your users engaged with real-time cricket updates. Whether it's live scores, wicket details, or player performance, the Match Ball-by-Ball API enriches your app with exciting content.

Making Your First API Call

To get started, you need the following information:
  • URL Syntax: The API's base URL is https://api.sports.roanuz.com. To access ball-by-ball data, you'll use the following endpoints:
    • /v5/cricket/proj_key/match/key/ball-by-ball/ for retrieving ball-by-ball updates for a specific match.
    • /v5/cricket/proj_key/match/key/ball-by-ball/over_key/ for fetching ball-by-ball data for a specific over.
    • /v5/cricket/proj_key/match/key/ball-by-ball/FIRST-OVER/ to access data for the first over.
  • URL Parameters:
    • proj_key (String, Required): Your Production or Sandbox Project Key.
    • key (String, Required): The match key for which you need ball-by-ball information.
    • over_key (Optional): The key of the over for specific over details.
    • first_over (Optional): Include this parameter to fetch ball-by-ball information for the first over of the match.
  • Header Parameters:
    • rs-token (String, Required): This token is needed to access the API. You can generate a new token using the Auth API.
Match Ball-by-Ball API Sample Request (Python):
pythonCopy code
import requests

project_key = 'YOUR_PROJ_KEY'
token = 'YOUR_ACCESS_TOKEN'
key = 'rsaeng_2020_t20_03'
url = "https://api.sports.roanuz.com/v5/cricket/<span class="highlight highlight-object">/match/{}</span>/ball-by-ball/".format(project_key, key)

headers = {
    'rs-token': token
}
response = requests.get(url, headers=headers)

print(response.json())

Simplified Data Schema

Let's dive into the essential attributes available in the response schema. We'll keep it simple and focus on what matters most:
Attribute Description
over_number The number of the over.
ball_type The type of ball bowled.
batsman Details about the batsman.
bowler Details about the bowler.
team_score The team's score after each ball.
extras Extra runs scored on the ball.
fielders Details about fielders and fielding plays.
wicket Information about wickets taken.

What more can you do with Match Ball-by-Ball API?

Ball-by-Ball Commentary

The Match Ball-by-Ball API is incredibly versatile. You can use it to build the ball-by-ball commentary section of a live cricket score website or integrate it wherever one line information about the match's progress is needed on a ball-by-ball basis.

Access the Latest Over Information

Want to know what happened in the most recent over? You can access the ball-by-ball details of the latest over without specifying the over key or using the "FIRST OVER" parameter.

Access the First Over

Similarly, if you're interested in the first over of a match, just include the "FIRST OVER" parameter in your request URL.

Crawling Through Overs

When you need information about a specific over and want to explore the preceding and succeeding overs, you can do so by using the previous_over_key or next_over_key properties in the request URL. This way, you can navigate through overs seamlessly.

Handling API Responses

The Match Ball-by-Ball API might return various HTTP status codes in response to your requests. Here are some of the possible status codes and their meanings:
  • 400 - Invalid input to process
  • 400 - Invalid Page Key provided
  • 401 - Invalid access token to process
  • 402 - Project is inactive
  • 403 - Access is limited to specific user groups
  • 404 - Resource not found
  • 404 - Not supported for the requested Metric Group
  • 500 - Unknown error

Caching for Improved Performance

The API responses come with a cache object, which is valuable for improving your application's performance. It includes information about caching recommendations, such as the cache key and the recommended time for caching a particular response. This intelligent caching mechanism dynamically determines the best expire time based on various factors.
  • cache.key: The key or ID recommended for caching a response.
  • cache.expires: The recommended duration for caching the data.
Remember that the cache's expire time may vary depending on different situations, and it's crucial for efficient data storage and retrieval.

Use Cases for Your Cricket App

  • Live Scoreboards: Provide real-time match updates to engage your users.
  • In-Depth Analysis: Offer insights into player performance, wickets, and key moments.
  • Match Highlights: Create highlights with detailed commentary to relive the action.
  • Custom Widgets: Build widgets for websites or mobile apps, keeping users informed.

Wrapping Up

The Match Ball-by-Ball API opens up a world of real-time cricket engagement possibilities. Whether you're building a cricket website, a mobile app, or any other cricket-related service, this API empowers you to provide cricket data with one line commentary. Elevate your cricket application to the next level and offer a thrilling experience to fans. So, if you're a cricket app developer, a sports news platform, or any service related to cricket, the Match Ball-by-Ball API is your game-changer. Dive into the world of real-time cricket action and take your application to new heights. With this API, you're not just building apps; you're creating experiences for cricket lovers worldwide.