Cookbook
Pitcher exit velocity
Average exit velocity allowed by each pitcher in an MLB game, from Statcast play-by-play.
Exit velo allowed, per pitcher
import os, requests
from collections import defaultdict
KEY = os.environ["STATSHAWK_KEY"]
BASE = "https://api.statshawk.ai/v1"
games = requests.get(
f"{BASE}/competitions/mlb/editions/2026/games",
headers={"X-API-Key": KEY},
params={"date": "2026-04-15"},
timeout=10,
).json()["data"]["items"]
pbp = requests.get(
f"{BASE}/contests/{games[0]['id']}/play-by-play",
headers={"X-API-Key": KEY},
timeout=15,
).json()["data"]
velo = defaultdict(list)
for pa in pbp["plate_appearances"]:
for pitch in pa["pitches"]:
if pitch["is_in_play"] and "launch_speed" in pitch:
velo[pa["pitcher_id"]].append(pitch["launch_speed"])
for pitcher_id, speeds in sorted(velo.items(), key=lambda kv: -max(kv[1])):
print(f"{pitcher_id}: avg EV {sum(speeds)/len(speeds):.1f} mph, max {max(speeds):.1f} ({len(speeds)} BIP)")