The Main Object to intact wit the API is the League Object.

League

class fantraxapi.objs.League(league_id: str, session: Session | None = None)[source]

League Class to represent a Fantrax League.

Parameters:
  • league_id (str) – Fantrax League ID.

  • session (Session | None) – Custom Session object.

Variables:
  • league_id (str) – Fantrax League ID.

  • session (Session) – Request Session Object.

  • logged_in (bool) – True when there’s a logged-in User.

  • name (str) – Name of the League.

  • year (str) – Year of the League.

  • start_date (datetime) – Start date of the League.

  • end_date (datetime) – End date of the League.

  • positions (dict[str, Position]) – Dictionary of Position ID to Positions.

  • status (dict[str, Status]) – Dictionary of Status ID to Status.

  • scoring_periods (dict[int, ScoringPeriod]) – Dictionary of Scoring Period Number to ScoringPeriod.

  • scoring_periods_lookup (dict[str, ScoringPeriod]) – Dictionary of Scoring Period Range (%Y/%m/%d-%Y/%m/%d) to ScoringPeriod.

  • scoring_dates (dict[int, date]) – Dictionary of daily period numbers to dates that have scoring in this season.

  • teams (list[Team]) – List of Teams in the League.

  • team_lookup (dict[str, Team]) – Dictionary of Team IDs to Teams.

team(team_identifier: str) Team[source]

Return a Team object for the given Team ID or where the Team name contains the given value.

Parameters:

team_identifier (str) – Team identifier.

Returns:

Team object that corresponds with the provided team identifier.

Return type:

Team

Raises:

NotTeamInLeague – When the team identifier provided is not found to be associated with any team in the League.

scoring_period_results(season: bool = True, playoffs: bool = True) dict[int, ScoringPeriodResult][source]

Returns Season ScoringPeriodResult objects for the league.

Parameters:
  • season (bool) – Return season Scoring Periods Results for this season.

  • playoffs (bool) – Return playoff Scoring Periods Results for this season.

Returns:

Dictionary of Period Number to ScoringPeriodResult object.

Return type:

dict[int, ScoringPeriodResult]

standings(scoring_period_number: int | None = None, only_period: bool = False) Standings[source]

Returns Standings object that represents either the standings after a period or the latest period’s standings when scoring_period_number is None.

Parameters:
  • scoring_period_number (int | None) – Period number, defaults to None.

  • only_period (bool) – Only that specific period’s standings, defaults to False.

Returns:

Standings object that corresponds with the period standing.

Return type:

Standings

pending_trades() list[Trade][source]

Returns a list of Trade objects that represent pending trades.

Returns:

List of Trade objects that represent pending trades.

Return type:

list[Trade]

Raises:

NotLoggedIn – When there is no logged-in User in the Session object.

trade_block() list[TradeBlock][source]

Returns a list of TradeBlock objects that represent each Trade Block.

Returns:

List of TradeBlock objects that represent each Trade Block.

Return type:

list[TradeBlock]

Raises:

NotLoggedIn – When there is no logged-in User in the Session object.

transactions(count: int = 100) list[Transaction][source]

Returns a list of Transaction objects that represent the latest transactions.

Parameters:

count (int) – Number of transactions to return, defaults to 100.

Returns:

List of Transaction objects that represent the latest transactions.

Return type:

list[Transaction]

position_counts(team_id: str, scoring_period_number: int | None = None) dict[str, PositionCount][source]

Returns a Dictionary of PositionCount objects that represents the positions used for a given Team ID for a specific period or the latest period’s standings when scoring_period_number is None.

Parameters:
  • team_id (str) – Team ID to get positions for.

  • scoring_period_number (int | None) – Period Number, defaults to None.

Returns:

Dictionary of Position Short Names to PositionCount objects.

Return type:

dict[str, PositionCount]

Raises:

PeriodNotInSeason – When the period_number is not in the Season

live_scores(scoring_date: date) dict[str, list[LivePlayer]][source]

Returns a Dictionary of Team IDs to a list of LivePlayer objects with scores for that day.

Parameters:

scoring_date (date) – Date of the Live Scoring.

Returns:

Dictionary of Team IDs to a list of LivePlayer objects with scores for that day.

Return type:

dict[str, list[LivePlayer]]

Raises:

DateNotInSeason – When the scoring_date is not in the Season.

team_roster(team_id: str, period_number: int | None = None) Roster[source]

Returns a Roster object that represents the given Team ID’s roster for a specific period or the latest period’s standings when number is None.

Parameters:
  • team_id (str) – Team ID.

  • period_number (int | None) – Daily Period Number, defaults to None.

Returns:

Roster object that represent the given Team ID’s roster.

Return type:

Roster

Raises:

PeriodNotInSeason – When the period_number is not in the Season