Skip to content

Guides

How do I measure a hitter's run value with runners in scoring position?

Every plate appearance with a runner on second or third, with the base-out state before it, the result, and the run value it added or cost.

Code verified October 10, 2026. One call to get_plate_appearances, 10 credits.

The call

batter_id comes from search_players. The cost is per call, not per row.

import requests
import pandas as pd

API_KEY = "YOUR_API_KEY"

resp = requests.post(
    "https://mcp.fastballapi.com/v1/get_plate_appearances",
    headers={"x-api-key": API_KEY},
    json={
        "batter_id": "33192",
        "season": 2026,
        "risp": True,
        "limit": 200,
    },
    timeout=60,
)
resp.raise_for_status()
data = resp.json()["data"]

pa = pd.DataFrame(data["plate_appearances"])
print(len(pa), "plate appearances, total run value", round(pa["run_value"].sum(), 1))
print(pa.groupby("result")["run_value"].agg(["count", "sum"]).round(2).sort_values("sum", ascending=False))

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.

{
  "plate_appearances": [
    {
      "game_id": "401816968",
      "inning": 3,
      "half": "top",
      "batter": {
        "id": "33192",
        "name": "Aaron Judge",
        "bats": "R"
      },
      "pitcher": {
        "id": "4791597",
        "name": "Zebby Matthews"
      },
      "before": {
        "outs": 2,
        "on_first": true,
        "on_second": true,
        "on_third": false
      },
      "result": "strikeout",
      "description": "Judge struck out swinging.",
      "run_value": -0.452
    },
    {
      "game_id": "401816938",
      "inning": 8,
      "half": "top",
      "batter": {
        "id": "33192",
        "name": "Aaron Judge",
        "bats": "R"
      },
      "pitcher": {
        "id": "36133",
        "name": "A.J. Minter"
      },
      "before": {
        "outs": 1,
        "on_first": true,
        "on_second": true,
        "on_third": false
      },
      "result": "home-run",
      "description": "Judge homered to left (415 feet), Rice scored and Bellinger scored.",
      "run_value": 2.343
    },
    "...53 more"
  ],
  "count": 55,
  "next_offset": null
}

What to do next

  • get_spray_chart (10 credits). Where the same hitter's balls in play land.
  • get_player_games (5 credits). The full game log, to see which games drove the total.

More guides

Start with 500 free credits

No card. REST or MCP.