How do I get MLB home run leaders and stat leaders in Python?
MLB home run leaders for 2026 among qualified hitters, with batting line and strikeout rate. Kyle Schwarber and Pete Crow-Armstrong tied at 45.
Code verified November 18, 2026. One call to get_leaders, 5 credits.
The call
stat also takes avg, obp, slg, ops, re24, bb_pct and k_pct for hitters, and era, whip, so, k_per_9 and bb_per_9 for pitchers. Only qualified players are ranked; override the minimum with min_pa or min_ip.
import requests
import pandas as pd
API_KEY = "YOUR_API_KEY"
resp = requests.post(
"https://mcp.fastballapi.com/v1/get_leaders",
headers={"x-api-key": API_KEY},
json={
"stat": "hr",
"season": 2026,
"limit": 10,
},
timeout=60,
)
resp.raise_for_status()
data = resp.json()["data"]
leaders = pd.DataFrame(data["leaders"])
print("season", data["season"], "- qualifier:", data["qualifier"])
cols = ["name", "team", "pa", "hr", "avg", "obp", "slg", "ops", "k_pct"]
print(leaders[cols].to_string(index=False))
print("home runs per 100 PA:", (leaders["hr"] / leaders["pa"] * 100).round(1).tolist())
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.
{
"stat": "hr",
"season": 2026,
"qualifier": "502 plate appearances",
"leaders": [
{
"player_id": "33712",
"name": "Kyle Schwarber",
"team": "PHI",
"pa": 701,
"avg": 0.232,
"obp": 0.353,
"slg": 0.502,
"ops": 0.855,
"k_pct": 0.31,
"bb_pct": 0.148,
"hr": 45,
"re24": 36.5
},
{
"player_id": "4717833",
"name": "Pete Crow-Armstrong",
"team": "CHC",
"pa": 726,
"avg": 0.279,
"obp": 0.371,
"slg": 0.569,
"ops": 0.94,
"k_pct": 0.256,
"bb_pct": 0.113,
"hr": 45,
"re24": 48.4
},
"...8 more"
],
"count": 10
}What to do next
- get_player (5 credits). One leader's career and season line.
- get_spray_chart (10 credits). Where a leader's balls in play land.
More guides
The same guide for other sports
- PuckAPI: How do I rank NHL goalies by goals saved above expected?
- FighterAPI: Who lands the most significant strikes per 15 minutes in the UFC?
- StrikerAPI: Who leads the Premier League in expected goals, and how do I rank players in Python?
- BirdieAPI: How do I get a golf tournament leaderboard in Python?
- YorkerAPI: How do I get cricket leaderboards in Python?
Rather ask Claude? 20 free Claude skills call these endpoints for you.
Start with 500 free credits every month
No card. REST or MCP.