How do I get a pitcher's pitch mix and whiff rate in Python?
A pitcher's arsenal for a season: how often each pitch is thrown, how hard, and how often it draws a swing and a miss.
Code verified October 10, 2026. One call to get_pitch_mix, 5 credits.
The call
pitcher_id comes from search_players.
import requests
import pandas as pd
API_KEY = "YOUR_API_KEY"
resp = requests.post(
"https://mcp.fastballapi.com/v1/get_pitch_mix",
headers={"x-api-key": API_KEY},
json={
"pitcher_id": "42409",
"season": 2026,
},
timeout=60,
)
resp.raise_for_status()
data = resp.json()["data"]
mix = pd.DataFrame(data["mix"])
print(data["pitcher"]["name"], data["pitches"], "pitches")
print(mix[["name", "usage", "avg_velocity", "max_velocity", "whiff_rate"]])
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.
{
"pitcher": {
"id": "42409",
"name": "Tarik Skubal"
},
"season": 2026,
"pitches": 2450,
"mix": [
{
"pitch_type": "FF",
"name": "Four-seam FB",
"pitches": 930,
"usage": 0.38,
"avg_velocity": 96.4,
"max_velocity": 101,
"whiff_rate": 0.256,
"ball_rate": 0.283,
"in_play": 161
},
{
"pitch_type": "CH",
"name": "Changeup",
"pitches": 627,
"usage": 0.256,
"avg_velocity": 87.3,
"max_velocity": 92,
"whiff_rate": 0.473,
"ball_rate": 0.348,
"in_play": 106
},
"...3 more"
],
"count": 5
}What to do next
- get_pitches (10 credits). The individual pitches behind each row, with location, for your own features.
- get_leaders (5 credits). Rank every qualified pitcher on a stat before you pick one to look at.
More guides
Start with 500 free credits
No card. REST or MCP.