Skip to main content

Iteracting with the playcricket API for statistical analysis and automated social media posts.

Project description

pyplaycricket

pyplaycricket is a package for extracting data programmatically from your playcricket site.


Installation

[fix link] Use the package manager pip to install pyplaycricket.

pip install pyplaycricket

Or install via Anaconda.

conda install -c conda-forge pyplaycricket

Access Requirements

To use the PlayCricket APIs you need to:

  1. Email play.cricket@ecb.co.uk to request access.
  2. You will need to be a PlayCricket admin for your club's site.
  3. You will need to share a fair usage agreement on behalf of your club.

They will confirm your site id and your API key.


Library Structure

The library is split into 4 main modules. 3 are generic playcricket modules which can be used for interrogating playcricket data. The Alleyn module has been created for club specific requests.

  • playcricket: generic methods for retrieving different data from playcricket sites.
  • utils: internal methods called repeatedly by other modules.
  • alleyn: specific methods for Alleyn CC analysis and social media posts.
  • config: where URLs, team IDs and more are stored for use in playcricket, utils and alleyn.

Quick start

Retrieve all playcricket matches in a given season for your club.

from playcric.playcricket import pc
site_id = 'insert_your_site_id_here'
api_key = 'insert_your_api_key_here'

playc = pc(api_key=api_key, site_id=site_id)
matches = playc.get_all_matches(season=2024)
id status published last_updated league_name league_id competition_name competition_id competition_type match_type game_type season match_date match_time ground_name ground_id ground_latitude ground_longitude home_club_name home_team_name home_team_id home_club_id away_club_name away_team_name away_team_id away_club_id umpire_1_name umpire_1_id umpire_2_name umpire_2_id umpire_3_name umpire_3_id referee_name referee_id scorer_1_name scorer_1_id scorer_2_name scorer_2_id
0 6571330 New Yes 2024-04-19 00:00:00 Friendly Limited Overs Standard 2024 2024-04-27 00:00:00 10:00 Edward Alleyn Club 9352 51.4491 -0.0915547 Alleyn CC Friendly XI 320697 672 Alleyn CC Burbage Badgers 268144 672
1 6242035 New Yes 2024-07-31 00:00:00 Surrey Junior Cricket Championship 10881 U11 Surrey County Cup 63219 Cup Limited Overs Standard 2024 2024-05-05 00:00:00 09:00 Battersea Park 56639 51.4802 -0.155702 Spencer CC, Surrey BU11 Tier1A 256417 5853 Alleyn CC Under 11 90654 672
2 6242558 New Yes 2024-07-31 00:00:00 Surrey Junior Cricket Championship 10881 U14 Surrey County Cup 63217 Cup Limited Overs Standard 2024 2024-05-05 00:00:00 09:30 Morden Park Main Pitch 57159 51.3888 -0.210369 AJ Cricket Academy Under 14 257934 14870 Alleyn CC Under 14 59853 672

Retrieve a league table

from playcric.playcricket import pc
site_id = 'insert_your_site_id_here'
api_key = 'insert_your_api_key_here'

playc = pc(api_key=api_key, site_id=site_id)
league_table, key = playc.get_league_table(117611, simple=True, clean_names=False)
POSITION TEAM W D L PTS
0 1 Horley CC, Surrey 8 2 1 219
1 2 Alleyn CC 8 2 2 198
2 3 Egham CC 6 1 4 170
3 4 Cobham Avorians CC 6 1 5 166
4 5 Byfleet CC 6 0 6 158
5 6 Kingstonian CC, Surrey 6 1 6 149
6 7 Thames Ditton CC 5 1 4 147
7 8 Effingham CC 4 2 5 118
8 9 Old Pauline CC 4 0 8 111
9 10 Churt and Hindhead CC 2 0 10 79

What are the different IDs used in the different functions?

Most of the IDs required for filtering on leagues, competitions, teams, clubs etc can be gleaned from the get_all_matches function. By default, this will return the matches associated with your site.

If you want to return all the fixtures for another club, you will need to find this on their playcricket site, at the bottom of the home page.

What is pyplaycricket?

In pyplaycricket, you can:

  • list all registered players for a club
  • get all matches for a club
  • get a league table in dataframe form
  • get all players involved in a fixture
  • get all partnerships from a fixture
  • get all individual stats from a fixture
  • get all individual stats totalled over a season

I hope pyplaycricket makes it easier to return data from playcricket for a variety of different use cases.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyplaycricket-0.1.2.tar.gz (22.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyplaycricket-0.1.2-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file pyplaycricket-0.1.2.tar.gz.

File metadata

  • Download URL: pyplaycricket-0.1.2.tar.gz
  • Upload date:
  • Size: 22.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for pyplaycricket-0.1.2.tar.gz
Algorithm Hash digest
SHA256 bfc6a3bef636f645247763e34858159730050167acbc49cd6d4ec5fbc0e8d212
MD5 030b84ce318ccdeca4e51eb20920d520
BLAKE2b-256 59ae10c40b95d3dce4f84dd3beb7f28cdde969d07c50f277b8cd2c1ac7f00d99

See more details on using hashes here.

File details

Details for the file pyplaycricket-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pyplaycricket-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for pyplaycricket-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 db3991c4335ea73bc5c94c6c07c865d4b1291b04ae963b2e469bdd5f45ff5546
MD5 c4729286e4345faf125151b128af114d
BLAKE2b-256 1a60d34e1f5dcea2ccbcf092be8b0ff06c5ad84131608fbccddc027e08e584c9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page