Skip to content

League Class Basketball

Christian Wendt edited this page Dec 16, 2022 · 9 revisions

Documentation of all Variables and usable functions for League Class

League

The League Object is used for getting all of your ESPN Fantasy data including teams, roster, players, scoreboards.

Usage

Set debug parameter to True if you want to see all of the ESPN API requests and responses print to the console

from espn_api.basketball import League
league = League(league_id: int, year: int, espn_s2: str = None, swid: str = None, debug=False)

Links

Team Class

Variables

league_id: int
year: int
teams: List[Team]
settings: Settings
draft: List[Pick]

Functions

Returns basic information on a match up for a current week. This can be used for previous years
Check out Matchup Class!

def scoreboard(week: int = None) -> List[Matchup]

Returns a list of Activities. Requires Authentication

# msg_type inputs: 'FA', 'WAVIER', 'TRADED'
def recent_activity(size: int = 25, msg_type: str = None) -> List[Activity]:

Returns a list of free agents
Check out Player Class!

# position inputs: 'PG', 'SG', 'SF', 'PF', 'C', 'G', 'F'
def free_agents(week: int = None, size: int = 50, position: str = None, position_id: int=None) -> List[Player]:

Returns a Player with season stats or None if name or playerId invalid. If a list of ids are provided in playerId the function will return a list of players

def player_info(name: str = None, playerId: Union[int, list] = None) -> Union[Player, List[Player]]:

Returns more specific information for a matchup or scoring period
If matchup_period is provided: It will return the Box Score Class for that whole matchup across multiple NBA games that week
If scoring_period is provided: It will return the Box Score Class for that scoring period (usually a single day)
If none of the parameters are provided: It will return the Box Score Class for the current matchup and up to the current scoring period
If matchup_total is set to False the points will show for that current scoring period else it will show total points for the matchup
(Note: If league scoring is category you will have to pass both scoring_period and matchup_period to get box score )

def box_scores(matchup_period: int = None, scoring_period: int = None, matchup_total: bool = True) -> List[BoxScore]

Helper functions

def standings() -> List[Team]:
def get_team_data(team_id: int) -> Team: