Skip to main content

YorkerAPI for Python

Python client for the YorkerAPI Cricket data API. It has no required dependencies (standard library only) and works on Python 3.9 and newer. Pandas is optional.

Install

pip install yorkerapi
pip install "yorkerapi[pandas]"   # only if you want DataFrames

Set your key

Get a free key at https://yorkerapi.com/signup. Free accounts get 500 credits a month.

export YORKERAPI_API_KEY=your_key_here
from yorkerapi import Client

client = Client()                      # reads YORKERAPI_API_KEY
client = Client(api_key="your_key")    # or pass it in

Examples

1. Competitions and their keys

list_competitions returns every competition we hold with its key, format and gender. Pass the key to other tools.

from yorkerapi import Client

client = Client()

comps = client.list_competitions(format="t20")["competitions"]
for c in comps[:5]:
    print(c)

2. One match, ball by ball

get_match returns the scorecards; get_deliveries returns every ball with the score after it. Load the balls into pandas.

from yorkerapi import Client, to_dataframe

client = Client()

match = client.get_match("1535465")
balls = client.get_deliveries(match_id="1535465", innings=1)
df = to_dataframe(balls, key="deliveries")
print(match["match"], len(df), "balls in the first innings")

3. A batter against a bowler

Find both ids with search_players, then ask for the matchup.

from yorkerapi import Client

client = Client()

batter = client.search_players("V Kohli", limit=1)["players"][0]
bowler = client.search_players("JJ Bumrah", limit=1)["players"][0]
print(client.get_matchup(batter["player_id"], bowler["player_id"]))

Credits

Every method returns the data object from the response. After each call, client.last_credits_used and client.last_credits_remaining hold the counters from the X-Credits-Used and X-Credits-Remaining headers. Methods that take estimate_only=True return the price of a call without running or charging it.

Pandas

from yorkerapi import to_dataframe

df = to_dataframe(data)                # finds the main list in the response
df = to_dataframe(data, key="rows")    # or name the list yourself

Nested fields become dotted columns. Install pandas separately or with pip install "yorkerapi[pandas]".

Errors

Every error is an APIError subclass, with the server's message and the HTTP status.

Exception Status Meaning
AuthError 401 Missing, invalid or revoked key
InsufficientCreditsError 402 Not enough credits for the call
NotFoundError 404 The id or name does not exist
RateLimitError 429 Too many requests; has .retry_after when the server sends it
APIError 400, 5xx Bad arguments or a server problem
APIConnectionError none No response (network or timeout)
from yorkerapi import Client, APIError, InsufficientCreditsError, RateLimitError

client = Client()
try:
    data = client.list_competitions()
except InsufficientCreditsError:
    print("Out of credits, top up at https://yorkerapi.com")
except RateLimitError as exc:
    print("Slow down, retry after", exc.retry_after)
except APIError as exc:
    print(exc.status_code, exc.message)

The client retries 429 and 5xx responses and connection failures up to 3 times with backoff, and honors Retry-After. Set Client(max_retries=0) to turn that off.

If you see CERTIFICATE_VERIFY_FAILED on a python.org install for macOS, run the "Install Certificates.command" script that came with Python, or pip install certifi (the client uses it when present).

Options

Client(
    api_key=None,                          # defaults to $YORKERAPI_API_KEY
    base_url="https://mcp.yorkerapi.com",           # point at another host
    timeout=60.0,                          # seconds per request
    max_retries=3,
)

client.call("tool_name", {"arg": "value"}) calls any tool by name, which helps when the API adds a tool before this package does.

Tools

Method names match the API tool names. Arguments are keyword arguments; required ones can also be passed positionally. Each method's docstring lists its arguments (help(client.list_competitions)).

Method Credits What it does
get_schedule 2 Schedule
list_competitions 1 List competitions
list_teams 1 List teams
get_matches 2 Matches
get_match 5 Match
get_deliveries 10 Deliveries
search_players 1 Search players
get_player 5 Player
get_player_stats 5 Player stats
get_player_matches 5 Player matches
get_matchup 5 Matchup
get_leaders 5 Leaders
get_ratings 2 Ratings
get_venue 5 Venue
get_win_probability 10 Win probability
get_market_vs_model 10 Market vs model
get_odds 5 Odds
get_line_movement 10 Line movement

Full API reference: https://yorkerapi.com/docs

License

MIT

Metadata

Release files for yorkerapi 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yorkerapi 0.1.5
File Size Uploaded Provenance Actions
yorkerapi-0.1.5.tar.gz 14.3 kB With provenance Details for yorkerapi-0.1.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for yorkerapi 0.1.5
File Interpreter ABI Platform Actions
yorkerapi-0.1.5-py3-none-any.whl Python 3 none any Details for yorkerapi-0.1.5-py3-none-any.whl

Total release size: 27.6 kB

Release files / yorkerapi-0.1.5.tar.gz

Download URL yorkerapi-0.1.5.tar.gz
Size 14.3 kB
Tags Source
SHA-256 checksum
How to use checksums
08fbb1acfc703da17818b4a98e0e82e7581f936220efc7cef1ba550f6967f236
BLAKE2b-256 checksum
How to use checksums
faba84d8027012f8335829bfb7477df0cccfdcf5ef1618699754e0f396ea4264
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Release files / yorkerapi-0.1.5-py3-none-any.whl

Download URL yorkerapi-0.1.5-py3-none-any.whl
Size 13.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6782f7ada566a7fd808dc5ee388d91ad3592477258dd166818095099a7196eb9
BLAKE2b-256 checksum
How to use checksums
a65d83d5cb1dd8cf60a7f8e74df7577410ad5b3ecb4c4d97bb9da4fbf088cceb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Security for yorkerapi 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for yorkerapi-0.1.5.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page