How do I get an NBA player's game log and a rolling average?
Every game a player appeared in, with minutes, points, shooting and plus-minus, loaded into pandas for a 10-game rolling average.
Code verified October 10, 2026. One call to get_player_games, 5 credits.
The call
player_id comes from search_players. Page with offset for the rest of the season.
import requests
import pandas as pd
API_KEY = "YOUR_API_KEY"
resp = requests.post(
"https://mcp.dunkapi.com/v1/get_player_games",
headers={"x-api-key": API_KEY},
json={
"player_id": "3975",
"season": 2026,
"limit": 40,
},
timeout=60,
)
resp.raise_for_status()
data = resp.json()["data"]
log = pd.DataFrame(data["games"]).sort_values("date")
log["pts_avg10"] = log["pts"].rolling(10).mean()
print(log[["date", "opponent", "minutes", "pts", "tpm", "tpa", "pts_avg10"]].tail(10).round(1))
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.
{
"player_id": "3975",
"games": [
{
"game_id": "401866759",
"date": "2026-04-17",
"opponent": "PHX",
"home": false,
"result": "L",
"minutes": 36,
"pts": 17,
"fgm": 4,
"fga": 16,
"tpm": 3,
"tpa": 10,
"reb": 4,
"ast": 4,
"plus_minus": -13
},
{
"game_id": "401866756",
"date": "2026-04-15",
"opponent": "LAC",
"home": false,
"result": "W",
"minutes": 36,
"pts": 35,
"fgm": 12,
"fga": 23,
"tpm": 7,
"tpa": 12,
"reb": 1,
"ast": 4,
"plus_minus": 9
},
"...38 more"
],
"count": 40,
"next_offset": 40
}What to do next
- get_player (5 credits). Per-season averages and shooting splits for the same player.
- get_leaders (5 credits). Rank everyone on a stat for the season.
More guides
Start with 500 free credits
No card. REST or MCP.