Skip to content

GriddyNFL

sdk

NFL SDK client for accessing NFL data from multiple API endpoints.

This module provides the GriddyNFL class, the main entry point for accessing NFL data including games, stats, rosters, and Next Gen Stats.

Example

from griddy.nfl import GriddyNFL nfl = GriddyNFL(nfl_auth={"accessToken": "your_token"}) games = nfl.games.get_games(season=2024, week=1) stats = nfl.stats.passing.get_passing_stats(season=2024)

GriddyNFL

GriddyNFL(
    nfl_auth,
    server_idx=None,
    server_url=None,
    url_params=None,
    client=None,
    async_client=None,
    retry_config=UNSET,
    timeout_ms=None,
    debug_logger=None,
)

Bases: LazySubSDKMixin, BaseGriddySDK, BaseSDK

Main client for accessing NFL data from multiple API endpoints.

GriddyNFL provides unified access to NFL data through three API categories:

  • Regular API: Public NFL.com endpoints for games, rosters, standings
  • Pro API: Advanced statistics, betting odds, player projections
  • Next Gen Stats: Player tracking data and advanced analytics

Sub-SDKs are loaded lazily on first access to minimize startup time.

Attributes:

Name Type Description
authentication Authentication

Token generation and refresh operations.

combine Combine

NFL Combine workout data and results.

draft Draft

NFL Draft picks and information.

games Games

Game schedules, scores, and details.

rosters Rosters

Team rosters and player assignments.

standings Standings

Division and conference standings.

football_teams Teams

Team information and details.

venues Venues

Stadium information.

weeks Weeks

Season week information.

stats StatsSDK

Aggregated player/team statistics (passing, rushing, etc.).

betting Betting

Betting odds and lines.

content Content

Game previews and film cards.

players Players

Player information and projections.

pro_games ProGames

Advanced game data.

schedules Schedules

Matchup rankings and injury reports.

transactions Transactions

Player transactions.

teams Teams

Pro team information.

ngs NextGenStats

Next Gen Stats (tracking data, leaderboards, charts).

Example

from griddy.nfl import GriddyNFL

Initialize with auth token

nfl = GriddyNFL(nfl_auth={"accessToken": "your_token"})

Get games

games = nfl.games.get_games(season=2024, week=1)

Get Next Gen Stats

passing = nfl.ngs.stats.get_passing_stats(season=2024)

Use as context manager

with GriddyNFL(nfl_auth=auth) as nfl: ... games = nfl.games.get_games(season=2024)

Parameters:

Name Type Description Default
nfl_auth Union[NFLAuth, Dict[str, Any]]

Authentication info containing at least an access token. Accepts an NFLAuth model or a dict with camelCase keys (e.g. {"accessToken": "..."}). Dicts are validated and coerced to NFLAuth at init time.

required
server_idx Optional[int]

Index of the server to use from the server list.

None
server_url Optional[str]

Override the default server URL.

None
url_params Optional[Dict[str, str]]

Parameters to template into the server URL.

None
client Optional[HttpClient]

Custom synchronous HTTP client (must implement HttpClient).

None
async_client Optional[AsyncHttpClient]

Custom async HTTP client (must implement AsyncHttpClient).

None
retry_config OptionalNullable[RetryConfig]

Configuration for automatic request retries.

UNSET
timeout_ms Optional[int]

Request timeout in milliseconds.

None
debug_logger Optional[Logger]

Custom logger for debug output.

None
Example

nfl = GriddyNFL(nfl_auth={"accessToken": "your_token"})

Source code in src/griddy/nfl/sdk.py
def __init__(
    self,
    nfl_auth: Union[models.NFLAuth, Dict[str, Any]],
    server_idx: Optional[int] = None,
    server_url: Optional[str] = None,
    url_params: Optional[Dict[str, str]] = None,
    client: Optional[HttpClient] = None,
    async_client: Optional[AsyncHttpClient] = None,
    retry_config: OptionalNullable[RetryConfig] = UNSET,
    timeout_ms: Optional[int] = None,
    debug_logger: Optional[Logger] = None,
) -> None:
    """Initialize the GriddyNFL client.

    Args:
        nfl_auth: Authentication info containing at least an access token.
            Accepts an ``NFLAuth`` model or a dict with camelCase keys
            (e.g. ``{"accessToken": "..."}``).  Dicts are validated and
            coerced to ``NFLAuth`` at init time.
        server_idx: Index of the server to use from the server list.
        server_url: Override the default server URL.
        url_params: Parameters to template into the server URL.
        client: Custom synchronous HTTP client (must implement HttpClient).
        async_client: Custom async HTTP client (must implement AsyncHttpClient).
        retry_config: Configuration for automatic request retries.
        timeout_ms: Request timeout in milliseconds.
        debug_logger: Custom logger for debug output.

    Example:
        >>> nfl = GriddyNFL(nfl_auth={"accessToken": "your_token"})
    """
    if isinstance(nfl_auth, dict):
        nfl_auth = models.NFLAuth.model_validate(nfl_auth)

    self._init_sdk(
        auth=nfl_auth,
        server_idx=server_idx,
        server_url=server_url,
        url_params=url_params,
        client=client,
        async_client=async_client,
        retry_config=retry_config,
        timeout_ms=timeout_ms,
        debug_logger=debug_logger,
        custom_auth_info=nfl_auth,
    )

authentication instance-attribute

authentication

Token generation and refresh operations for NFL API access.

combine instance-attribute

combine

NFL Combine workout data and results.

draft instance-attribute

draft

NFL Draft picks and information.

games instance-attribute

games

Game schedules, scores, and details from the regular API.

rosters instance-attribute

rosters

Team rosters and player assignments.

standings instance-attribute

standings

Division and conference standings.

football_teams instance-attribute

football_teams

Team information and details.

venues instance-attribute

venues

Stadium and venue information.

weeks instance-attribute

weeks

Season week information.

football_stats instance-attribute

football_stats

Historical and live football statistics (football_stats.historical, football_stats.live).

experience instance-attribute

experience

Game details by slug or ID, with optional replays and drive charts.

video_content instance-attribute

video_content

Video replay content for games.

stats instance-attribute

stats

Aggregated player and team statistics (stats.passing, stats.rushing, etc.).

betting instance-attribute

betting

Betting odds and lines.

content instance-attribute

content

Game previews, film cards, and insights.

players instance-attribute

players

Player information, statistics, and projections.

pro_games instance-attribute

pro_games

Advanced game data and statistics.

schedules instance-attribute

schedules

Matchup rankings and injury reports.

transactions instance-attribute

transactions

Player transactions and roster moves.

teams instance-attribute

teams

Pro team information, rosters, and schedules.

ngs instance-attribute

ngs

Next Gen Stats data (tracking statistics, leaderboards, charts, highlights).

authenticate_via_browser classmethod

authenticate_via_browser(
    login_email,
    login_password,
    headless=False,
    save_credentials_path=None,
    server_idx=None,
    server_url=None,
    url_params=None,
    client=None,
    async_client=None,
    retry_config=UNSET,
    timeout_ms=None,
    debug_logger=None,
)

Create a GriddyNFL instance by authenticating via browser.

Uses Playwright to log into NFL.com and capture auth tokens.

Parameters:

Name Type Description Default
login_email str

Email address for NFL.com account.

required
login_password str

Password for NFL.com account.

required
headless bool

If True, run browser in headless mode. Defaults to False.

False
save_credentials_path Optional[str]

If provided, save credentials to this file path.

None
server_idx Optional[int]

Index of the server to use from the server list.

None
server_url Optional[str]

Override the default server URL.

None
url_params Optional[Dict[str, str]]

Parameters to template into the server URL.

None
client Optional[HttpClient]

Custom synchronous HTTP client (must implement HttpClient).

None
async_client Optional[AsyncHttpClient]

Custom async HTTP client (must implement AsyncHttpClient).

None
retry_config OptionalNullable[RetryConfig]

Configuration for automatic request retries.

UNSET
timeout_ms Optional[int]

Request timeout in milliseconds.

None
debug_logger Optional[Logger]

Custom logger for debug output.

None

Returns:

Type Description
GriddyNFL

A fully-initialized GriddyNFL instance.

Example

nfl = GriddyNFL.authenticate_via_browser( ... login_email="user@example.com", ... login_password="password", ... headless=True, ... save_credentials_path="creds.json", ... )

Source code in src/griddy/nfl/sdk.py
@classmethod
def authenticate_via_browser(
    cls,
    login_email: str,
    login_password: str,
    headless: bool = False,
    save_credentials_path: Optional[str] = None,
    server_idx: Optional[int] = None,
    server_url: Optional[str] = None,
    url_params: Optional[Dict[str, str]] = None,
    client: Optional[HttpClient] = None,
    async_client: Optional[AsyncHttpClient] = None,
    retry_config: OptionalNullable[RetryConfig] = UNSET,
    timeout_ms: Optional[int] = None,
    debug_logger: Optional[Logger] = None,
) -> "GriddyNFL":
    """Create a GriddyNFL instance by authenticating via browser.

    Uses Playwright to log into NFL.com and capture auth tokens.

    Args:
        login_email: Email address for NFL.com account.
        login_password: Password for NFL.com account.
        headless: If True, run browser in headless mode. Defaults to False.
        save_credentials_path: If provided, save credentials to this file path.
        server_idx: Index of the server to use from the server list.
        server_url: Override the default server URL.
        url_params: Parameters to template into the server URL.
        client: Custom synchronous HTTP client (must implement HttpClient).
        async_client: Custom async HTTP client (must implement AsyncHttpClient).
        retry_config: Configuration for automatic request retries.
        timeout_ms: Request timeout in milliseconds.
        debug_logger: Custom logger for debug output.

    Returns:
        A fully-initialized GriddyNFL instance.

    Example:
        >>> nfl = GriddyNFL.authenticate_via_browser(
        ...     login_email="[email protected]",
        ...     login_password="password",
        ...     headless=True,
        ...     save_credentials_path="creds.json",
        ... )
    """
    from .utils.security import do_browser_auth

    if debug_logger is None:
        debug_logger = get_default_logger()

    nfl_auth = do_browser_auth(
        email=login_email,
        password=login_password,
        headless=headless,
        logger=debug_logger,
    )

    if save_credentials_path is not None:
        with open(save_credentials_path, "w") as outfile:
            json.dump(nfl_auth, outfile, indent=4)

    return cls(
        nfl_auth=nfl_auth,
        server_idx=server_idx,
        server_url=server_url,
        url_params=url_params,
        client=client,
        async_client=async_client,
        retry_config=retry_config,
        timeout_ms=timeout_ms,
        debug_logger=debug_logger,
    )