Skip to content

Setting up a Sensor for Cricket

David edited this page Jan 2, 2023 · 4 revisions

There are important differences with ESPN's cricket API compared to other sports.

  • League IDs can change from one year to another and so you will likely need to set up a new sensor each year.
  • Just because a league ID works on https://www.espncricinfo.com/ does not mean ESPN has an API to support it.
  • The ESPN API for cricket does not allow multiple days to be requested at once, therefore games will show up as NOT_FOUND until less than 24 hours before they start. If ESPN ever supports multiple dates in a single call, the sensor will automatically pull them in. DO NOT REPORT A DEFECT OR ASSUME YOU SET THE SENSOR UP INCORRECTLY UNLESS https://www.espncricinfo.com/ SHOWS THE GAME IN PROGRESS AND YOU ARE STILL GETTING NOT_FOUND.
  • Like soccer, teams can play in multiple "leagues" and a sensor will need to be set up for each one of them to track all of the games.
  • League IDs are unique numerical values that come from https://www.espncricinfo.com/
  • There is no native support for any cricket leagues. You have to set up a Custom API Configuration.

Here is sample YAML that creates a sensor using a Custom API Configuration for the Hobart Hurricanes (HH) in the Big Bash League:

  - platform: teamtracker
    league_id: XXX
    sport_path: cricket
    league_path: 1324623
    team_id: HH
    name: hobart_hurricanes

You can get the values for the league_path and team_id from https://www.espncricinfo.com/ with the following steps:

  1. Once at https://www.espncricinfo.com/, Navigate to the the summary page of a game involving the team you want to track in the league you want to track.
  2. For the example above, I used: https://www.espncricinfo.com/series/big-bash-league-2022-23-1324623/hobart-hurricanes-vs-adelaide-strikers-26th-match-1324649/live-cricket-score
  3. The number for the league_path comes from the URL (1324623)
  4. The team_id is the short name used by ESPN to identify the team on the page (HH).
  5. Validate ESPN has a working API for the league by pasting the API URL into your browser and make sure you get a valid response. If your league_path came from https://www.espncricinfo.com/ and you get an error, there is no ESPN API support for your league.
  1. Here is a sample URL for the Big Bash league using league_path 1324623 that works: https://site.api.espn.com/apis/site/v2/sports/cricket/1324623/scoreboard
  2. Here is a sample URL for the Indian Premier League using league_path 1254058 that does not work: https://site.api.espn.com/apis/site/v2/sports/cricket/1254058/scoreboard