Nfl¶
griddy / nfl**
Module Contents¶
Classes¶
BaseSDK
¶
Source code in griddy/nfl/basesdk.py
GriddyNFL
¶
GriddyNFL(
nfl_auth: Optional[Dict[str, Any]] = None,
login_email: Optional[str] = None,
login_password: Optional[str] = None,
headless_login: Optional[bool] = False,
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,
)
Bases: BaseSDK
flowchart TD
griddy.nfl.GriddyNFL[GriddyNFL]
griddy.nfl.basesdk.BaseSDK[BaseSDK]
griddy.nfl.basesdk.BaseSDK --> griddy.nfl.GriddyNFL
click griddy.nfl.GriddyNFL href "" "griddy.nfl.GriddyNFL"
click griddy.nfl.basesdk.BaseSDK href "" "griddy.nfl.basesdk.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.
| ATTRIBUTE | DESCRIPTION |
|---|---|
authentication |
Token generation and refresh operations.
TYPE:
|
combine |
NFL Combine workout data and results.
TYPE:
|
draft |
NFL Draft picks and information.
TYPE:
|
games |
Game schedules, scores, and details.
TYPE:
|
rosters |
Team rosters and player assignments.
TYPE:
|
standings |
Division and conference standings.
TYPE:
|
football_teams |
Team information and details.
TYPE:
|
venues |
Stadium information.
TYPE:
|
weeks |
Season week information.
TYPE:
|
stats |
Aggregated player/team statistics (passing, rushing, etc.).
TYPE:
|
betting |
Betting odds and lines.
TYPE:
|
content |
Game previews and film cards.
TYPE:
|
players |
Player information and projections.
TYPE:
|
pro_games |
Advanced game data.
TYPE:
|
schedules |
Matchup rankings and injury reports.
TYPE:
|
transactions |
Player transactions.
TYPE:
|
teams |
Pro team information.
TYPE:
|
ngs |
Next Gen Stats (tracking data, leaderboards, charts).
TYPE:
|
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)
Initialize the GriddyNFL client.
You must provide authentication either via a pre-obtained auth token (nfl_auth) or via email/password for browser-based authentication.
| PARAMETER | DESCRIPTION |
|---|---|
nfl_auth
|
Dictionary containing authentication information, must include 'accessToken' key. Example:
TYPE:
|
login_email
|
Email address for NFL.com account. Used with login_password for browser-based authentication.
TYPE:
|
login_password
|
Password for NFL.com account.
TYPE:
|
headless_login
|
If True, run browser in headless mode during authentication. Defaults to False.
TYPE:
|
server_idx
|
Index of the server to use from the server list.
TYPE:
|
server_url
|
Override the default server URL.
TYPE:
|
url_params
|
Parameters to template into the server URL.
TYPE:
|
client
|
Custom synchronous HTTP client (must implement HttpClient).
TYPE:
|
async_client
|
Custom async HTTP client (must implement AsyncHttpClient).
TYPE:
|
retry_config
|
Configuration for automatic request retries.
TYPE:
|
timeout_ms
|
Request timeout in milliseconds.
TYPE:
|
debug_logger
|
Custom logger for debug output.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If neither nfl_auth nor email/password is provided, or if both are provided. |
Example
With pre-obtained token¶
nfl = GriddyNFL(nfl_auth={"accessToken": "your_token"})
With email/password¶
nfl = GriddyNFL( ... login_email="user@example.com", ... login_password="password", ... headless_login=True, ... )
Source code in griddy/nfl/sdk.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | |
Attributes¶
authentication
instance-attribute
¶
authentication: Authentication
Token generation and refresh operations for NFL API access.
stats
instance-attribute
¶
stats: StatsSDK
Aggregated player and team statistics (stats.passing, stats.rushing, etc.).
fantasy_statistics
instance-attribute
¶
Fantasy football statistics and scoring metrics.
ngs
instance-attribute
¶
ngs: NextGenStats
Next Gen Stats data (tracking statistics, leaderboards, charts, highlights).
Functions¶
Functions¶
dynamic_import
¶
Dynamically import a module with retry logic for handling race conditions.
This function handles edge cases where parallel imports can cause KeyError due to half-initialized modules in sys.modules.
:param modname: The name of the module to import (absolute or relative) :param package: The package name for relative imports (e.g., package) :param retries: Number of retry attempts (default: 3) :returns: The imported module :raises KeyError: If import fails after all retries
Source code in griddy/nfl/_import.py
close_clients
¶
close_clients(
owner: ClientOwner,
sync_client: Union[HttpClient, None],
sync_client_supplied: bool,
async_client: Union[AsyncHttpClient, None],
async_client_supplied: bool,
) -> None
A finalizer function that is meant to be used with weakref.finalize to close httpx clients used by an SDK so that underlying resources can be garbage collected.