Skip to content

League Class

Christian Wendt edited this page Jul 31, 2022 · 18 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 settings, teams, roster, players, free agents, box scores/match ups, and power rankings.

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.football import League
league = League(league_id: int, year: int, espn_s2: str = None, swid: str = None, debug=False)

Links

Team Class, Pick Class, Settings Class

Variables

league_id: int
year: int
settings: Settings
teams: List[Team]
draft: List[Pick]
current_week: int # current fantasy football week
nfl_week: int # current nfl week

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 more specific information on week match ups and can only be used with current season
Check out Box Score Class!

def box_scores(week: int = None) -> List[BoxScore]

Calculates week power rankings using two step dominance. Returns a list of tuples with first position being score and second the Team Class

def power_rankings(week: int=None) -> List[Tuples(str, Team)]

Returns a list of free agents
Check out Box Player Class!

# position inputs: 'QB', 'RB', 'WR', 'TE', 'D/ST', 'K', 'FLEX' 
def free_agents(week: int = None, size: int = 50, position: str = None, position_id: int=None) -> List[BoxPlayer]:

Returns a list of Activities. Requires Authentication

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

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]]:

Gets latest league data. This can be used instead of creating a new League class each week

def refresh() -> None:

Helper functions

def standings() -> List[Team]:
def top_scorer() -> Team:
def least_scorer() -> Team:
def most_points_against() -> Team:
def top_scored_week() -> Tuple(Team, int):
def least_scored_week() -> Tuple(Team, int):
def get_team_data(team_id: int) -> Team: