yorkerapi
v0.2.0
Published
JavaScript and TypeScript client for the YorkerAPI Cricket data API: stats, play-by-play, odds and player props. No dependencies.
Maintainers
Readme
yorkerapi
Cricket data and odds API. JavaScript and TypeScript client for the YorkerAPI Cricket data API. No dependencies; Node 18+, Deno, Bun, and edge runtimes with fetch.
First call in plain Python
No package needed: standard library only. Set YORKERAPI_API_KEY to your key (free at https://yorkerapi.com/signup) and run this. search_players costs 1 credit.
import json, os, urllib.request
req = urllib.request.Request(
"https://mcp.yorkerapi.com/v1/search_players",
data=json.dumps({"name": "kohli"}).encode(),
headers={"x-api-key": os.environ["YORKERAPI_API_KEY"], "content-type": "application/json"},
)
with urllib.request.urlopen(req) as resp:
data = json.load(resp)["data"]
print("credits left:", resp.headers["x-credits-remaining"])
rows = next(v for v in data.values() if isinstance(v, list))
for row in rows[:5]:
print(row)Every tool works the same way: POST https://mcp.yorkerapi.com/v1/, JSON in, {"data": ...} out, with X-Credits-Used and X-Credits-Remaining headers.
YorkerAPI at a glance
- Cricket data and odds API: Cricket ball by ball in every format, men's and women's, joined to sportsbook match-winner prices.
- 19 tools, every one on the free plan. Each call costs 1 to 10 credits; the table below has every price.
- Free: 500 credits every month, no card. Plans: Starter $19/month (10,000 credits), Pro $49/month (30,000 credits), Scale $149/month (125,000 credits), Business $299/month (300,000 credits). Top-ups: 400 credits per $1, from $5.
- MCP server: https://mcp.yorkerapi.com/mcp?key=YOUR_API_KEY (or the key in an
x-api-keyheader; Claude and ChatGPT connect with a sign-in instead) - REST: POST https://mcp.yorkerapi.com/v1/ with your key in an
x-api-keyheader and the arguments as a JSON body. - Python:
pip install yorkerapi. JavaScript:npm install yorkerapi - Matches: Since 2001. 23,241 matches in every format, men's and women's, from Tests and ODIs to the IPL, the Big Bash, The Hundred and the county game.
- Deliveries: Every ball. More than 11.7 million deliveries with the batter, bowler, runs, extras and wicket on each.
- Prices: From mid-2020. Each sportsbook's match-winner price, a median of 29 books on IPL closing lines and 22 on Tests; about 93% of priced matches are linked to their ball-by-ball.
| Credits | Tools | | --- | --- | | 1 | get_data_status, list_competitions, list_teams, search_players | | 2 | get_schedule, get_matches, get_ratings | | 5 | get_match, get_player, get_player_stats, get_player_matches, get_matchup, get_leaders, get_venue, get_odds | | 10 | get_deliveries, get_win_probability, get_market_vs_model, get_line_movement |
Install
npm install yorkerapiGet a free key (500 credits every month, no card) at https://yorkerapi.com/signup?utm_source=npm&utm_medium=readme&utm_campaign=yorkerapi-js and set YORKERAPI_API_KEY.
import { Client } from "yorkerapi"
const client = new Client() // reads YORKERAPI_API_KEY, or new Client({ apiKey: "..." })
const data = await client.listCompetitions({"format":"t20"})
console.log(data)
console.log("credits left:", client.lastCreditsRemaining)Every method takes one object with the API's parameter names and returns the unwrapped data. client.call("tool_name", {...}) reaches any tool newer than this package. Errors are typed: AuthError (401), InsufficientCreditsError (402), NotFoundError (404), RateLimitError (429, with retryAfter), APIError otherwise. 429 and 5xx responses are retried with backoff.
Load a whole season
client.loadSeason(dataset, season) pulls every page of one dataset for a season and returns an array of row objects. Nested fields become dotted keys (home.abbrev).
const rows = await client.loadSeason("matches", 2025) // first call: pages through the API
const again = await client.loadSeason("matches", 2025) // second call: read from ~/.cache/yorkerapi/, no requests
await client.loadSeason("matches", 2025, { refresh: true }) // pull againA season is a year (2024) or a split season ("2024/25").
| Dataset | Tool | What a row is | Requests for a typical season | Credits for a typical season |
| --- | --- | --- | --- | --- |
| matches | getMatches | matches of a season across competitions (pass competition= to narrow) | 3 | 6 |
Price a big pull first
Every request costs the tool's normal credits. Per-game datasets (plays, odds and props by game) make one request per played game, so a full season is thousands of credits. Ask first:
console.log(await client.loadSeason("matches", 2025, { estimate: true }))
// { dataset: "matches", season: ..., calls: ..., credits: ..., basis: ..., data_calls: 0 }estimate: true makes no data requests and spends nothing. Where the tool accepts estimate_only (season-wide odds, props) it asks the server for the price; it uses the games already in your cache when there are some, and typical season sizes otherwise. The numbers in the table are the same typical sizes: they are approximate, an order of magnitude and not a quote.
maxCalls(default 100) stops a pull that turns out larger than expected. It throwsLoadLimitError, which holds the rows fetched so far (err.rows), and caches nothing. Raise it deliberately for a big pull.- Extra tool arguments go in
params({ team: "BOS" },{ league: "mls" }). Do not pass the season, paging or date arguments:loadSeasonsets them. - In Node the result is cached as JSON lines under
~/.cache/yorkerapi/(cacheDirorYORKERAPI_CACHE_DIRmoves it,cache: falseskips it). Browsers and other runtimes withoutnode:fshave no cache. client.lastLoadreports the last load:rows,calls,creditsUsedandcached.- Per-game datasets skip games that start today or later.
Tools
| Method | What it returns | Credits |
| --- | --- | --- |
| getSchedule | Schedule | 2 |
| listCompetitions | List competitions | 1 |
| listTeams | List teams | 1 |
| getMatches | Matches | 2 |
| getMatch | Match | 5 |
| getDeliveries | Deliveries | 10 |
| searchPlayers | Search players | 1 |
| getPlayer | Player | 5 |
| getPlayerStats | Player stats | 5 |
| getPlayerMatches | Player matches | 5 |
| getMatchup | Matchup | 5 |
| getLeaders | Leaders | 5 |
| getRatings | Ratings | 2 |
| getVenue | Venue | 5 |
| getWinProbability | Win probability | 10 |
| getMarketVsModel | Market vs model | 10 |
| getOdds | Odds | 5 |
| getLineMovement | Line movement | 10 |
| getDataStatus | Data status | 1 |
Full reference with response shapes: https://yorkerapi.com/docs?utm_source=npm&utm_medium=readme&utm_campaign=yorkerapi-js. The same data is available as a hosted MCP server for Claude, ChatGPT and Cursor: https://yorkerapi.com/mcp. A Python client is on PyPI: pip install yorkerapi.
MIT licensed.
