How do I get a batter's record against a bowler in Python?
Balls, runs, strike rate, dots, fours, sixes and every dismissal for one batter against one bowler, overall and by format.
Code verified November 3, 2026. One call to get_matchup, 5 credits.
The call
Both ids come from search_players. Pass format or competition to narrow it.
import requests
import pandas as pd
API_KEY = "YOUR_API_KEY"
resp = requests.post(
"https://mcp.yorkerapi.com/v1/get_matchup",
headers={"x-api-key": API_KEY},
json={
"batter_id": "30a45b23",
"bowler_id": "462411b3",
},
timeout=60,
)
resp.raise_for_status()
data = resp.json()["data"]
s = data["summary"]
print(data["batter"]["name"], "v", data["bowler"]["name"], s["runs"], "off", s["balls"], "balls, out", s["dismissals"], "times")
print(pd.DataFrame(data["by_format"])[["format", "balls", "runs", "strike_rate", "dots"]])
Replace YOUR_API_KEY with a key from your dashboard. Python needs requests and pandas (pip install requests pandas). JavaScript runs on Node 18 or newer, or in the browser.
What comes back
The data object of the response, trimmed to the first rows. Every field is real output from the run above.
{
"batter": {
"player_id": "30a45b23",
"name": "SPD Smith"
},
"bowler": {
"player_id": "462411b3",
"name": "JJ Bumrah"
},
"summary": {
"matches": 33,
"innings": 37,
"runs": 281,
"balls": 412,
"outs": 10,
"fours": 31,
"sixes": 4,
"dots": 259,
"average": 28.1,
"strike_rate": 68.2,
"dismissals": 9,
"balls_per_dismissal": 45.8
},
"by_format": [
{
"format": "test",
"matches": 8,
"innings": 12,
"runs": 95,
"balls": 227,
"outs": 5,
"fours": 9,
"sixes": 1,
"dots": 172,
"average": 19,
"strike_rate": 41.85
},
{
"format": "odi",
"matches": 14,
"innings": 14,
"runs": 103,
"balls": 121,
"outs": 2,
"fours": 16,
"sixes": 0,
"dots": 67,
"average": 51.5,
"strike_rate": 85.12
},
"...1 more"
],
"dismissals": [
{
"match_id": "895815",
"date": "2016-01-23",
"competition": "odi",
"innings": 1,
"delivery": "11.5",
"wicket_kind": "caught"
},
{
"match_id": "980957",
"date": "2016-05-01",
"competition": "ipl",
"innings": 1,
"delivery": "9.2",
"wicket_kind": "caught"
},
"...7 more"
],
"count": 412
}What to do next
- get_player_stats (5 credits). The batter by phase of the innings: powerplay, middle overs and death.
- get_deliveries (10 credits). The balls themselves: pass batter_id and a competition.
More guides
Start with 500 free credits every month
No card. REST or MCP.