NFL SDK¶
nfl
¶
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 |
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
authentication
instance-attribute
¶
Token generation and refresh operations for NFL API access.
football_stats
instance-attribute
¶
Historical and live football statistics (football_stats.historical, football_stats.live).
experience
instance-attribute
¶
Game details by slug or ID, with optional replays and drive charts.
stats
instance-attribute
¶
Aggregated player and team statistics (stats.passing, stats.rushing, etc.).
ngs
instance-attribute
¶
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
|
SDKConfiguration
dataclass
¶
SDKConfiguration(
client,
client_supplied,
async_client,
async_client_supplied,
debug_logger,
security=None,
server_url="",
server_idx=0,
language="python",
sdk_version=__version__,
user_agent=__user_agent__,
retry_config=(lambda: UNSET)(),
timeout_ms=None,
server_type="regular",
custom_auth_info=None,
)
Bases: SDKConfiguration
NFL-specific SDK configuration with server type selection and auth info.
get_server_details
¶
Return the base URL and params for the configured server type.