How to build a live cricket score tracker
Contents

What is a live score tracker

A live score tracker is a digital feature that shows real-time updates from sporting events directly to users’ screens.

These systems power the constantly updating scorelines, match status, player stats, and event data that fans expect when following games online or in apps.

Live score trackers rely on sports data APIs to fetch up-to-the-minute information as matches unfold, ensuring users see updates on runs, wickets, overs, and key match events without refreshing the page.

APIs act as a bridge between reliable data sources and your app or website, delivering structured responses that your frontend can render quickly and efficiently.

This real-time data keeps users engaged, enhances the user experience, and supports features such as live commentary, scoreboards, and interactive widgets.

Introducing the Sportmonks cricket API

To build your live cricket score tracker, you need a data source that delivers real-time cricket information in a structured, reliable way. The Sportmonks Cricket API is designed specifically for this purpose, giving developers access to live match data, fixtures, player and team stats, and more via simple REST endpoints that return JSON.

Key features that matter for live tracking

– Live scores and match status so you always know what games are in progress and how they are unfolding.
– Ball-by-ball details and commentary for deep insight into match flow and events.
– Batting and bowling scoreboards, giving statistics for teams and players.
– Global coverage with data from major and minor cricket leagues around the world.
– Developer-friendly documentation includes, allowing you to enrich responses with related data such as team info, player details, and more.

Every request to the API uses an API token for authentication. You include this token in your query before you can retrieve protected match data.

Sportmonks API endpoints you’ll use most

When building a live score tracker, the following endpoints are especially important:
Livescores – returns all currently live matches, including score and status.
Fixtures – lets you look up upcoming or past matches and fetch details by match ID.
Teams – provides information on teams playing in a match (names, logos, IDs).
Players – returns detailed player profiles and career stats.

Step by step on How to build a cricket score tracker

Step-by-step guide

Step 1: Gather the tools

What you’ll need:

– API Token
Obtain a Sportmonks Cricket API token
Create one by visiting MySportmonks
Free plan available for testing

– Code Editor (Recommended)
Visual Studio Code
Or any code editor you prefer

– Postman (Optional but helpful)
Testing and debugging API requests
Sportmonks provides a ready-to-use Cricket API Postman collection
Import the collection here

api token

Step 2: Decide which leagues you want to display

Planning your coverage:
Consider which cricket leagues and formats interest your audience:
– International matches (Test, ODI, T20I)
– Domestic T20 leagues (IPL, BBL, PSL, CPL)
– Domestic First-class cricket
– Women’s cricket

Important considerations:

1. Check your subscription plan
– Visit the Cricket API coverage page
– Ensure your plan includes the leagues you want to display
– Free plan includes: T20I, BBL, CSA T20 Challenge

2. Use the “All Leagues” endpoint
– Retrieve a comprehensive list of leagues available in your subscription
– Endpoint: GET /leagues

3. Key point: If your plan has no ongoing matches, the livescores API will not return data

cricket coverage page

Step 3: Selecting the data to show

Typical cricket score tracker displays

Essential information
– Date and time of the match
– League/series name and stage
– Teams (home vs away / batting first vs second)
– Match status (Not Started, Live, Finished, Abandoned)
– Current score (runs/wickets, overs)
– Match format (Test, ODI, T20, T20I)

Match events
– Wickets (dismissals)
– Boundaries (fours and sixes)
– Milestones (50s, 100s)
– Over completions

Visual elements
– Team logos and flags
– League/series logos
– Country flags
– Player images

Step 4: Choose the correct endpoint

Primary endpoint for live cricket scores

GET Livescores
– Returns all matches that are currently live
– Appears 15 minutes before the match starts
– Disappears 15 minutes after the match ends
– Perfect for real-time score tracking

Base URL:

https://cricket.sportmonks.com/api/v2.0/livescores?api_token=YOUR_TOKEN

Alternative endpoints:

– GET Fixtures
All matches (past, present, future)
Use for match schedules and upcoming fixtures

– GET Fixtures by ID
Filter matches by specific ID
Ideal for a particular team

For this guide, we’ll focus on the GET Livescores endpoint.

Step 5: Build your API request

Enhancing your request with includes:

The base livescores URL is just the starting point. To get comprehensive match data, add “includes” to your request.

Example: Basic live score with events and participants

https://cricket.sportmonks.com/api/v2.0/livescores?api_token=YOUR_TOKEN&include=runs,batting,bowling

Common includes for live cricket scores:

– runs
score summary
total runs, wickets, overs

– batting
batting scorecard
player runs, balls faced, 4s, 6s, SR

– bowling
bowling figures
overs, wickets, runs, economy

– balls
ball-by-ball
every delivery with commentary

– lineup
playing XI
team composition, captain, keeper

– venue
ground info
stadium name, city, capacity

– toss
toss details
toss winner, decision (bat/bowl)

– teams
team information
team names, logos, details

Combining multiple includes:

https://cricket.sportmonks.com/api/v2.0/livescores?api_token=YOUR_TOKEN&include=runs,batting,bowling,lineup,venue,toss

This returns:
– Live scores
– Complete batting scorecard
– Complete bowling figures
– Playing XI
– Venue details
– Toss information

Pro tip: You can add as many or as few includes as needed. The API is flexible; request only what you’ll display on your tracker.

The complete list of available includes is available in the Livescores documentation.

Step 6: Evaluating the response

Understanding the API response:

Let’s analyse a real match example to see what data the API returns.

Example match:
– India vs Australia
– T20 International
– Live match in progress

Request URL:

https://cricket.sportmonks.com/api/v2.0/livescores?api_token=YOUR_TOKEN&include=runs,batting,bowling,lineup

Response structure:

{
 "data": [
   {
     "id": 12345,
     "league_id": 67,
     "season_id": 890,
     "round": "Group A",
     "localteam_id": 1,
     "visitorteam_id": 5,
     "starting_at": "2026-02-11 14:30:00",
     "type": "T20I",
     "live": true,
     "status": "1st Innings",
     "note": "India won the toss and elected to bat",
     "venue_id": 45,
     "toss_won_team_id": 1,
     "winner_team_id": null,
     "runs": [
       {
         "team_id": 1,
         "score": 165,
         "wickets": 4,
         "overs": 18.3
       }
     ],
     "batting": [
       {
         "player_id": 101,
         "player_name": "Virat Kohli",
         "runs": 67,
         "balls_faced": 45,
         "fours": 6,
         "sixes": 2,
         "strike_rate": 148.89,
         "dismissal": "not out"
       },
       {
         "player_id": 102,
         "player_name": "Rohit Sharma",
         "runs": 42,
         "balls_faced": 28,
         "fours": 4,
         "sixes": 3,
         "strike_rate": 150.00,
         "dismissal": "caught",
         "bowler_id": 201
       }
       // More batsmen...
     ],
     "bowling": [
       {
         "player_id": 201,
         "player_name": "Mitchell Starc",
         "overs": 4,
         "maidens": 0,
         "runs_conceded": 32,
         "wickets": 2,
         "economy": 8.00
       }
       // More bowlers...
     ],
     "lineup": [
       {
         "player_id": 101,
         "player_name": "Virat Kohli",
         "position": "Batsman",
         "captain": false,
         "wicketkeeper": false
       },
       {
         "player_id": 103,
         "player_name": "MS Dhoni",
         "position": "Wicket Keeper",
         "captain": true,
         "wicketkeeper": true
       }
       // More players...
     ]
   }
 ]
}

Key data points to extract:

  1. Match status: “status”: “1st Innings” or “Live” or “Finished”
  2. Current score: “score”: 165, “wickets”: 4, “overs”: 18.3
  3. Batting performance: Individual player stats with runs, balls, SR
  4. Bowling figures: Overs bowled, wickets taken, economy rate
  5. Live flag: “live”: true indicates the match is currently in progress

Step 7: Filtering and optimising requests

Scenario: You only want to display specific data on your tracker to reduce payload size and improve performance.

Using the select parameter:

If you only need certain fields from the API response, use the select parameter:

https://cricket.sportmonks.com/api/v2.0/livescores?api_token=YOUR_TOKEN&include=runs&select=id,localteam_id,visitorteam_id,status,live

This returns only:
– Match ID
– Team IDs
– Match status
– Live flag
– Runs data (from include)

Benefits:
– Smaller payload size
– Faster response times
– Reduced bandwidth usage
– Better performance on mobile

Using filters for specific matches:

Filter by team:

https://cricket.sportmonks.com/api/v2.0/livescores?api_token=YOUR_TOKEN&filter[localteam_id]=1

Returns only matches where team ID 1 is the home/local team.

Filter by date:

https://cricket.sportmonks.com/api/v2.0/fixtures?api_token=YOUR_TOKEN&filter[starting_at]=2026-02-11

Returns all fixtures scheduled for February 11, 2026.

Combining filters:

https://cricket.sportmonks.com/api/v2.0/fixtures?api_token=YOUR_TOKEN&filter[localteam_id]=1&filter[starting_at]=2026-02-11

For more filtering techniques, refer to our dedicated filter tutorial.

Step 8: Implementing real-time updates

Keeping scores fresh
Cricket scores change rapidly during live matches. Your tracker needs to update regularly.

Recommended update strategy
Option 1: Polling (Simpler – Recommended for beginners)

Set up automatic requests at regular intervals:

// Poll every 5 seconds during live matches
setInterval(async () => {
 const response = await fetch('YOUR_API_ENDPOINT');
 const data = await response.json();
 updateScoreboard(data);
}, 5000);

Polling frequency guidelines:
– Live matches: Every 5-10 seconds
– Pre-match (15 min before): Every 30-60 seconds
– Post-match: Stop polling

Option 2: Smart polling with status check

Only poll when matches are actually live:

async function updateScores() {
 const data = await fetchLiveScores();
 
 if (data.length === 0) {
   // No live matches - increase polling interval
   setTimeout(updateScores, 60000); // Check every minute
 } else {
   // Live matches found - poll frequently
   updateUI(data);
   setTimeout(updateScores, 5000); // Check every 5 seconds
 }
}
Best practices:

– Stop polling for completed matches
– Increase the interval when there are no live matches
– Cache responses to reduce API calls
– Monitor your API quota usage

Step 9: Building the user interface

Essential UI components for your cricket score tracker:
1. Match list view

– Display all live matches
– Show current score, overs, wickets
– Indicate match status (Live, Scheduled, Finished)
– Team logos and names

2. Match detail view (when user clicks a match)

– Full batting scorecard
– Complete bowling figures
– Ball-by-ball commentary (optional)
– Match information (venue, toss, date/time)

3. Navigation

– Filter by date (Today, Tomorrow, Yesterday)
– Filter by league/tournament
– Search functionality

4. Visual indicators

– “LIVE” badge for ongoing matches
– Colour coding for wickets/boundaries
– Progress indicators for overs

Step 10: Handling edge cases and errors

Common scenarios to handle:

1. No live matches

if (response.data.length === 0) {
 displayMessage("No live matches at the moment");
 // Show upcoming fixtures instead
}

2. API rate limit

if (response.status === 429) {
 // Too many requests
 // Increase polling interval
 // Show cached data
}

3. Network errors

try {
 const data = await fetchLiveScores();
} catch (error) {
 console.error("Failed to fetch scores:", error);
 // Display last known scores
 // Show error message to user
}

4. Match status changes

– Match moves from “Scheduled” to “Live”
– Match moves from “Live” to “Finished”
– Match is “Abandoned” or “Postponed”

Power your live cricket coverage with Sportmonks

If you want reliable, real-time cricket data to bring your live score tracker to life, the Sportmonks Cricket API delivers fast live scores, ball-by-ball details, player stats and worldwide coverage straight to your app or website. Easy to integrate and backed by clear documentation, it’s built for developers who want quality data and flexibility. Start your free trial today and see how quickly you can elevate your cricket experience.

Frequently asked questions

What is a cricket API and how does it work?
A cricket API is a service that provides structured access to cricket data including live scores, player stats, match schedules, and historical results. Your app or site makes HTTP requests to the API and receives JSON responses you can render in real time.
Why should I use an API for live cricket scores?
Using a live data API keeps your platform updated with the latest scores, overs, wickets, and match events without manual updating. This engages users and boosts retention by delivering accurate, up-to-the-second information.
How do I start with the Sportmonks Cricket API?
Sign up for a Sportmonks account, obtain your API token, and use it to authenticate your requests. Refer to the official documentation for endpoint details and example requests

Written by David Jaja

David Jaja is a technical content manager at Sportmonks, where he makes complex football data easier to understand for developers and businesses. With a background in frontend development and technical writing, he helps bridge the gap between technology and sports data. Through clear, insightful content, he ensures Sportmonks' APIs are accessible and easy to use, empowering developers to build standout football applications