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 November 18, 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.

Or use the official client: pip install fastballapi

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": "Aaron Judge: strikeout",
      "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": "Aaron Judge: home run (fly ball), 3 runs 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.

The data this uses

Every row above comes from MLB pitch-by-pitch data and MLB spray chart data. MLB pitch-by-pitch since 2015 (about 98% of games to 2017, all from 2018): pitch type, velocity, location and the count, with the plate appearance. REST or MCP.

More guides

Rather ask Claude? 16 free Claude skills call these endpoints for you.

Start with 500 free credits every month

No card. REST or MCP.