cricketlive
v1.0.0
Published
Get live cricket match details.
Downloads
3
Readme
Table of Contents
- Features
- Installation
- Usage
- Example Data
- API
- Errors
- Prerequisites
- Configuration
- Testing
- Changelog
- FAQ
- Credits
- Special Thanks
- Contributing
- License
Features
- Fetches live cricket scores from ESPN Cricinfo
- Provides detailed match information including team scores, overs, and match status
- Easy to integrate with Node.js projects
Installation
- Before using this module, it is required to download NodeJS from nodejs.org.
- To install the module, use npm:
npm i cricketlive
Usage
// Import cricket live module
const { cricketlive } = require('cricketlive')
// Get The URL Of The Cricket Match From espncricinfo.com
// NOTE* - THE URL MUST END WITH THE PATH /live-cricket-score (Get the URL by going into summary section of the Match).
const url = 'https://www.espncricinfo.com/series/icc-men-s-t20-world-cup-2024-1411166/nepal-vs-netherlands-7th-match-group-d-1415707/live-cricket-score'
// replace with actual match URL
cricketlive(url).then(details => {
console.log(details)
}).catch(error => {
console.error(error)
})
Example Data
{
"battingTeam": "Netherlands",
"battingTeamOversAndTarget": "(18.4/20 ov, T:107) 109/4",
"teamScores": { "Nepal": "106", "Netherlands": "109/4" },
"matchStatus": "Netherlands won by 6 wickets (with 8 balls remaining)",
"matchIsStarted": true,
"matchIsEnd": true,
"matchInBreak": false
}
API
Parameters
- url
(string)
: The URL of the cricket match details page to scrape.
Returns
- A
promise
that resolves to an object containing the match details:
{
"battingTeam": "Team Name",
"battingTeamOversAndTarget": "20 ov, target 150",
"teamScores": {
"Team Name 1": "150/5",
"Team Name 2": "145/9"
},
"matchStatus": "Team Name won by 5 runs",
"matchIsStarted": true,
"matchIsEnd": true,
"matchInBreak": false
}
Errors
- If there is an error fetching or parsing the data, the promise will be rejected with an error message.
Changelog
- [2024.06.05] - Initial release -
v1.0.0