Python wrapper for the ESPNCricInfo JSON API
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

README.md

python-espncricinfo

A Python 3 client for ESPNCricinfo's match, summary and player information.

Description

The splendid espncricinfo.com site not only provides individual HTML pages of cricket matches, it also provides a JSON representation of data from each match. This Python library provides access to many of those JSON attributes as well as some helper functions. All you need is the match ID, which is the number at the end of a match page URL. See the Usage section for instructions, and see match.py for individual functions.

Disclaimer: This library is not intended for commercial use and neither it nor its creator has any affiliation with ESPNCricInfo. The LICENSE for this library applies only to the code, not to the data.

The current version of this library is 0.4.1. It is very much a work in progress, and bug reports and feature requests are welcomed.

Installation

pip3 install python-espncricinfo

Usage

For a summary of live matches, create an instance of the Summary class:

>>> from espncricinfo.summary import Summary
>>> s = Summary()
>>> s.match_ids
['68079', '68209', '68081', '61375', '65429']

For individual matches, pass in the ID as a string:

>>> from espncricinfo.match import Match
>>> m = Match('64148')
>>> m.description
'England [Marylebone Cricket Club] tour of Australia, Only ODI: Australia v England at Melbourne, Jan 5, 1971'

More recent matches will have more methods available to them (for older matches, those methods will return None). A full list of methods available to an instance of the Match class is in the code.

For player details, pass in the player ID (found in a player's URL - for example, Ajinkya Rahane is '277916'):

>>> from espncricinfo.player import Player
>>> p = Player('277916')
>>> p.name
'Ajinkya Rahane'

A full list of methods available to an instance of the Player class is in the code.

For series (or league) details, pass in the series ID (found in a match URL, for example, India's 2018 tour of England is '18018'):

>>> from espncricinfo.series import Series
>>> s = Series('18018')
>>> s.name
'India tour of Ireland and England 2018'

Tests

To run the tests:

python tests.py

Requirements

See requirements.txt