Skip to content

League Class

Christian Wendt edited this page Nov 17, 2020 · 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, username: str = None, password: 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

def player_info(name: str = None, playerId: int = None) -> 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: