How do I compare NBA team pace and efficiency in pandas?
Pace, offensive and defensive rating, net rating and the four factors for all 30 teams in one call, ready to sort and plot.
Code verified November 18, 2026. One call to get_team_stats, 5 credits.
The call
Add season_type or team to narrow it.
import requests
import pandas as pd
API_KEY = "YOUR_API_KEY"
resp = requests.post(
"https://mcp.dunkapi.com/v1/get_team_stats",
headers={"x-api-key": API_KEY},
json={
"season": 2026,
},
timeout=60,
)
resp.raise_for_status()
data = resp.json()["data"]
teams = pd.DataFrame(data["teams"]).set_index("abbrev")
cols = ["pace", "off_rating", "def_rating", "net_rating", "efg_pct", "tov_pct", "oreb_pct", "ft_rate"]
print(teams[cols].sort_values("net_rating", ascending=False).head(10))
print(teams[["pace", "net_rating"]].corr().round(2))
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 dunkapi
What comes back
The data object of the response, trimmed to the first rows. Every field is real output from the run above.
{
"season": 2026,
"teams": [
{
"abbrev": "OKC",
"games": 82,
"wins": 64,
"losses": 18,
"pace": 102.6,
"off_rating": 116,
"def_rating": 105.1,
"net_rating": 10.9,
"efg_pct": 0.561,
"tov_pct": 0.123,
"oreb_pct": 0.223,
"ft_rate": 0.261
},
{
"abbrev": "SA",
"games": 82,
"wins": 62,
"losses": 20,
"pace": 102.8,
"off_rating": 116.6,
"def_rating": 108.5,
"net_rating": 8.1,
"efg_pct": 0.559,
"tov_pct": 0.131,
"oreb_pct": 0.262,
"ft_rate": 0.274
},
"...28 more"
],
"count": 30,
"method": "Possessions = FGA - OREB + TOV + 0.44 x FTA, averaged over both teams. Ratings are points per 100 possessions."
}What to do next
- get_standings (2 credits). Add conference and home or away records from the same games.
- get_shot_chart (10 credits). Pass opponent with a team to see the shots its defence gives up.
The data this uses
Every row above comes from NBA shot chart data. The x/y location of every NBA field goal attempt in the play-by-play since 2003-04, with distance, zone, result and expected points. REST or MCP.
More guides
The same guide for other sports
Rather ask Claude? 16 free Claude skills call these endpoints for you.
Start with 500 free credits every month
No card. REST or MCP.