Skip to content

Guides

How do I get a batter's powerplay and death overs stats in Python?

A player's batting and bowling split by phase of the innings: powerplay, middle overs and death, counted from every ball.

Code verified November 3, 2026. One call to get_player_stats, 5 credits.

The call

player_id comes from search_players. Split by season or competition with by. A career shows only the part in the record, which starts in December 2001.

import requests
import pandas as pd

API_KEY = "YOUR_API_KEY"

resp = requests.post(
    "https://mcp.yorkerapi.com/v1/get_player_stats",
    headers={"x-api-key": API_KEY},
    json={
        "player_id": "ba607b88",
        "format": "t20",
        "by": "phase",
    },
    timeout=60,
)
resp.raise_for_status()
data = resp.json()["data"]

bat = pd.DataFrame(data["batting"]).set_index("group_key")
print(data["name"])
print(bat[["balls", "runs", "average", "strike_rate", "sixes"]])

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.

{
  "player_id": "ba607b88",
  "name": "V Kohli",
  "grouped_by": "phase",
  "batting": [
    {
      "group_key": "middle",
      "matches": 277,
      "innings": 277,
      "runs": 6239,
      "balls": 4938,
      "outs": 135,
      "fours": 430,
      "sixes": 182,
      "dots": 1283,
      "hundreds": 0,
      "fifties": 9,
      "highest": 87,
      "average": 46.21,
      "strike_rate": 126.35
    },
    {
      "group_key": "powerplay",
      "matches": 313,
      "innings": 313,
      "runs": 4520,
      "balls": 3555,
      "outs": 100,
      "fours": 565,
      "sixes": 105,
      "dots": 1420,
      "hundreds": 0,
      "fifties": 0,
      "highest": 44,
      "average": 45.2,
      "strike_rate": 127.14
    },
    "...1 more"
  ],
  "bowling": [
    {
      "group_key": "middle",
      "matches": 36,
      "balls": 351,
      "runs_conceded": 477,
      "wickets": 7,
      "dots": 81,
      "wides": 11,
      "noballs": 6,
      "five_wickets": 0,
      "best": "1/4",
      "overs": "58.3",
      "average": 68.14,
      "economy": 8.15,
      "strike_rate": 50.1
    },
    {
      "group_key": "death",
      "matches": 9,
      "balls": 52,
      "runs_conceded": 95,
      "wickets": 1,
      "dots": 12,
      "wides": 0,
      "noballs": 1,
      "five_wickets": 0,
      "best": "1/9",
      "overs": "8.4",
      "average": 95,
      "economy": 10.96,
      "strike_rate": 52
    }
  ],
  "count": 5
}

What to do next

  • get_matchup (5 credits). The same batter against one bowler.
  • get_deliveries (10 credits). The balls themselves: pass batter_id and a competition.

More guides

The same guide for other sports

Start with 500 free credits every month

No card. REST or MCP.