from __future__ import annotations from typing import Any import requests HEADERS = { "User-Agent": "Mozilla/5.0", "Accept-Language": "en-US,en;q=0.9", } LIVE_FEED_URL_TEMPLATE = "https://statsapi.mlb.com/api/v1.1/game/{game_pk}/feed/live" def fetch_live_game_feed(game_pk: str) -> dict[str, Any]: if not game_pk: return {} url = LIVE_FEED_URL_TEMPLATE.format(game_pk=game_pk) response = requests.get(url, headers=HEADERS, timeout=30) response.raise_for_status() return response.json()