

## NBA games today [#nba-games-today]

```python title="todays_scoreboard.py"
import os, requests, datetime
KEY = os.environ["STATSHAWK_KEY"]
BASE = "https://api.statshawk.ai/v1"
EDITION_YEAR = "2026"

today = datetime.date.today().isoformat()
contests = requests.get(
    f"{BASE}/competitions/nba/editions/{EDITION_YEAR}/contests",
    headers={"X-API-Key": KEY},
    params={"date": today},
    timeout=10,
).json()["data"]["items"]

def score_for(entrant):
    value = ((entrant.get("result") or {}).get("value") or {})
    return value.get("score")

for contest in contests:
    by_slot = {e.get("start_slot"): e for e in contest["entrants"]}
    home = by_slot.get(0)
    away = by_slot.get(1)
    home_name = home["subject"]["name"] if home else "?"
    away_name = away["subject"]["name"] if away else "?"
    home_score = score_for(home) if home else None
    away_score = score_for(away) if away else None
    score = f"{away_score}–{home_score}" if home_score is not None else contest["starts_at"][11:16]
    print(f"{away_name} @ {home_name}   {score}   {contest['status']}")
```

## curl version [#curl-version]

```bash title="quick check"
curl -H "X-API-Key: $STATSHAWK_KEY" \
  "https://api.statshawk.ai/v1/competitions/nba/editions/2026/contests?date=$(date +%F)" \
  | jq '.data.items[]
        | . as $c
        | ($c.entrants | map({key: (.start_slot|tostring), value: .}) | from_entries) as $s
        | "\($s["1"].subject.name) @ \($s["0"].subject.name)  \($s["1"].result.value.score // "-")–\($s["0"].result.value.score // "-")  \($c.status)"'
```

The edition year is hardcoded to `2026` — for seasons that span a calendar-year boundary,
the edition year is the season's label year, not necessarily today's calendar year.

<PlaygroundLink href="/docs/api">
  Open the competition contests endpoint in the playground →
</PlaygroundLink>
