Menu

How do I get a pitcher's pitch mix and whiff rate in Python?
📰

How do I get a pitcher's pitch mix and whiff rate in Python?

DEV Community: datascience·noah·16 days ago
#NuI1KwqV
#devtodatascience#science#devto#dev#pitches
Reading 0:00
15s threshold

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. It takes 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 " ]])

Enter fullscreen mode

Exit fullscreen mode

You need requests and pandas ( pip install requests pandas ) and a free API key from FastballAPI .

What comes back

The data object, trimmed to the first rows.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.