Metadata-Version: 2.4
Name: pycricinfo
Version: 0.0.13
Summary: An API using pycricinfo to collect data from ESPN Cricinfo
Project-URL: Homepage, https://github.com/mattholland0202/py-cricinfo
Project-URL: Source, https://github.com/mattholland0202/py-cricinfo
Author: Matt Holland
License: MIT
License-File: LICENSE
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.13
Requires-Dist: beautifulsoup4>=4.13.4
Requires-Dist: prettytable>=3.16.0
Requires-Dist: pydantic-settings>=2.9.1
Requires-Dist: pydantic>=2.11.5
Requires-Dist: requests>=2.32.3
Provides-Extra: api
Requires-Dist: fastapi>=0.115.12; extra == 'api'
Requires-Dist: uvicorn>=0.34.2; extra == 'api'
Provides-Extra: dev
Requires-Dist: ruff>=0.11.0; extra == 'dev'
Description-Content-Type: text/markdown

# pycricinfo

[![PyPI version](https://img.shields.io/pypi/v/pycricinfo)](https://pypi.org/project/pycricinfo/)
[![Upload to PyPi](https://github.com/mattholland0202/py-cricinfo/actions/workflows/python-publish.yml/badge.svg)](https://github.com/mattholland0202/py-cricinfo/actions/workflows/python-publish.yml)

A Python package using ESPNCricinfo's API to extract match, player & statistical data.

Defines Pydantic models to represent data from the Cricinfo API, allowing easier interaction with the data in your code.

## Installation
Use your package manager of choice to install `pycricinfo`. For example:

#### Pip
```
pip install pycricinfo
```

#### UV
```
uv add pycricinfo
```

### Optional installation: API
This project also comes with an optional dependency to run an API wrapper around Cricinfo, providing an OpenAPI specification via Swagger through `FastAPI`. Install this optional dependency with:
```
pip install 'pycricinfo[api]'
```
or
```
uv add pycricinfo --optional api
```

## Sample usage: CLI
Installing the project adds 2 scripts:

### `print_scorecard`
Produces a match scorecard in the CLI.

Parameters:
* `--file`: A path to a JSON file from the Cricinfo match summary API
* `--match_id`: The Cricinfo ID of a match while will be fetched from the summary API
### `print_ballbyball` 
Produces a summary of each ball in a page of data in the CLI.

Parameters:
* `--file`: A path to a JSON file from the Cricinfo 'play-by-play' API to the
* `--match_id`: The Cricinfo ID of a match while will be fetched from the summary API
* `--innings`: The innings of the game to get data from
* `--page`: The page of commentary to return from that innings


Installing the optional API dependency adds a further script:

### `run_api`
Runs `uvicorn` to launch a `FastAPI` wrapper around the Cricinfo API, which will launch on port 8000, with the Swagger documentation available at `http://localhost:8000/docs`

## Sample usage: In code
Import one of the `get_` function from `pycricinfo.search`, for example:
```python
from pycricinfo.search import get_player


def fetch_player_from_cricinfo(player_id: int):
    cricinfo_player = get_player(player_id)
    print(cricinfo_player.display_name)
```