Skip to content

CHPP client

pychpp.chpp

Client for the Hattrick CHPP API.

CHPP

CHPP(
    consumer_key,
    consumer_secret,
    access_token_key=None,
    access_token_secret=None,
)

Bases: CHPPXml

High-level object-oriented interface on top of the CHPP XML files.

Custom methods (team(), player(), match(), ...) return navigable objects from pychpp.models.custom.

arena

arena(id_=None, **kwargs)

Get an arena by its Hattrick ID.

If no ID is defined, the arena of the connected user's primary team is returned.

Parameters:

Name Type Description Default
id_ Optional[int]

Hattrick ID of the requested arena.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

challenge_manager

challenge_manager(
    team_id=None, is_weekend_friendly=None, **kwargs
)

Get a challenge manager object.

Parameters:

Name Type Description Default
team_id Optional[int]

Hattrick ID of the concerned team.

None
is_weekend_friendly Optional[bool]

Whether the request concerns a weekend friendly.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

check_token

check_token()

Check the token key and secret validity.

Returns:

Type Description

Validity and other information about the current token.

get_access_token

get_access_token(request_token, request_token_secret, code)

Query the access token from Hattrick once the user granted the application.

The access token has to be stored by the application in order to be used for further use of the CHPP class.

Parameters:

Name Type Description Default
request_token

Request token returned by get_auth().

required
request_token_secret

Request token secret returned by get_auth().

required
code

Code returned by Hattrick after the user granted the application, sent to callback_url by Hattrick or shown directly on Hattrick if callback_url was "oob".

required

Returns:

Type Description

A dict with "key" and "secret" keys.

Raises:

Type Description
ValueError

If request_token, request_token_secret or code is not a string.

get_auth

get_auth(callback_url='oob', scope='')

Get the url, request_token and request_token_secret to authenticate a user.

Parameters:

Name Type Description Default
callback_url

Url that has to be requested by Hattrick after the user has entered their credentials.

'oob'
scope str | list

Authorization granted by the user to the application. Can be one or more of "", "manage_challenges", "set_matchorder", "manage_youthplayers", "set_training", "place_bid".

''

Returns:

Type Description

A dict with "request_token", "request_token_secret" and "url" keys.

Raises:

Type Description
ValueError

If callback_url or scope is invalid.

invalidate_token

invalidate_token()

Invalidate the current token.

Returns:

Type Description

Information about the invalidated token.

league

league(
    id_=None,
    country_id=None,
    include_regions=None,
    **kwargs,
)

Get a league by its Hattrick ID or from a country ID.

Parameters:

Name Type Description Default
id_ Optional[int]

Hattrick ID of the requested league.

None
country_id Optional[int]

Hattrick ID of the country whose league is requested.

None
include_regions Optional[bool]

Whether to include the regions in the response.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

league_unit

league_unit(id_=None, **kwargs)

Get a league unit by its Hattrick ID.

If no ID is defined, the league unit of the connected user's primary team is returned.

Parameters:

Name Type Description Default
id_ Optional[int]

Hattrick ID of the requested league unit.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

match

match(id_, source_system=None, events=None, **kwargs)

Get a match by its Hattrick ID.

Parameters:

Name Type Description Default
id_ int

Hattrick ID of the requested match.

required
source_system Optional[str]

Source system of the requested match.

None
events Optional[bool]

Whether to include the match events.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

match_lineup

match_lineup(
    match_id=None,
    team_id=None,
    source_system=None,
    **kwargs,
)

Get a match lineup.

Parameters:

Name Type Description Default
match_id Optional[int]

Hattrick ID of the requested match.

None
team_id Optional[int]

Hattrick ID of the team for which the lineup is requested.

None
source_system Optional[str]

Source system of the requested match.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

matches_archive

matches_archive(
    id_=None,
    is_youth=None,
    first_match_date=None,
    last_match_date=None,
    season=None,
    include_hto=None,
    **kwargs,
)

Get a matches archive.

Parameters:

Name Type Description Default
id_ Optional[int]

Hattrick ID of the team to search matches for.

None
is_youth Optional[bool]

Whether the archive concerns a youth team.

None
first_match_date Optional[datetime]

Begin date to search matches.

None
last_match_date Optional[datetime]

End date to search matches.

None
season Optional[int]

Season to search matches for.

None
include_hto Optional[bool]

Whether to include tournament matches.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

open_session

open_session()

Open the OAuth session.

player

player(id_, **kwargs)

Get a player by their Hattrick ID.

Parameters:

Name Type Description Default
id_ int

Hattrick ID of the requested player.

required
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

region

region(id_=None, **kwargs)

Get a region by its Hattrick ID.

Parameters:

Name Type Description Default
id_ Optional[int]

Hattrick ID of the requested region.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

request

request(**kwargs)

Send a request to the CHPP API endpoint.

Parameters:

Name Type Description Default
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
Element

The parsed XML data fetched on Hattrick.

Raises:

Type Description
HTError

If the CHPP API returns an error.

team

team(id_=None, user_id=None, **kwargs)

Get a team by its Hattrick ID.

If no ID is given: - if 'user_id' is defined, the primary team of the corresponding user is returned; - else the primary team of the connected user is returned.

Parameters:

Name Type Description Default
id_ Optional[int]

Hattrick ID of the requested team.

None
user_id Optional[int]

Hattrick ID of the user whose primary team is requested.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

transfer_history

transfer_history(
    team_id=None, page=None, all_transfers=None, **kwargs
)

Get the transfer history of a team.

Parameters:

Name Type Description Default
team_id Optional[int]

Hattrick ID of the team to get the transfer history for.

None
page Optional[int]

Page of the transfer history to fetch.

None
all_transfers Optional[bool]

Whether to fetch all the pages of the transfer history.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
HTTransferHistory

The transfer history of the team.

user

user(id_=None, **kwargs)

Get a user by their Hattrick ID.

If no ID is defined, the connected user is returned.

Parameters:

Name Type Description Default
id_ Optional[int]

Hattrick ID of the requested user.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

xml_achievements

xml_achievements(user_id=None, **kwargs)

Request the achievements.xml file from the CHPP API.

Parameters:

Name Type Description Default
user_id Optional[int]

Which user to show achievements for. If None (the default), Hattrick uses the authenticated user's ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
Achievements

The parsed data from the achievements.xml file.

xml_alliance_details

xml_alliance_details(
    action_type="view",
    subset=None,
    alliance_id=None,
    **kwargs,
)

Request the alliance_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
action_type str

Indicates what type of action the page should perform. Allowed values: 'view' (Federation info), 'roles' (View the roles of a federation), 'members' (List the members of a federation), 'membersSubset' (List a subset of the members of a federation).

'view'
subset Optional[int]

Starting character names to show A = 65.... Z = 90. Use 0 for other than english starting characters. Only relevant for actionType membersSubset.

None
alliance_id Optional[int]

ID of the federation to search information for.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
AllianceDetailsView | AllianceDetailsRoles | AllianceDetailsMembers | AllianceDetailsMembersSubset

The parsed data from the alliance_details.xml file.

xml_alliances

xml_alliances(
    search_for,
    search_type=None,
    search_language_id=None,
    page_index=None,
    user_id=None,
    **kwargs,
)

Request the alliances.xml file from the CHPP API.

Parameters:

Name Type Description Default
search_for str

What to search for (length ≥ 3 characters).

required
search_type Optional[int]

Which field to search in. Allowed values: '1' (Let the list include only federations with names beginning with search string), '2' (Let the list include only federations with abbreviation including search string), '3' (Let the list include only federations with description including search string), '4' (Search for a specific AllianceID), '5' (Get the federations of the currently authenticated manager, or of another user).

None
search_language_id Optional[int]

Specifies a language to restrict the federations on the list to. If None (the default), Hattrick uses 0 (all languages).

None
page_index Optional[int]

Zero based pageindex to retrieve. If the search result spans more than one page, the total number of pages is returned. Each result may not return more than 25 rows. If None (the default), Hattrick uses 0.

None
user_id Optional[int]

The user to show the federations for. Gives AccessDenied if the user does not exist or has no team. If None (the default), Hattrick uses the authenticated user's ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
Alliances

The parsed data from the alliances.xml file.

xml_arena_details

xml_arena_details(
    stats_type=None,
    arena_id=None,
    team_id=None,
    match_type=None,
    first_date=None,
    last_date=None,
    stats_league_id=None,
)

Request the arena_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
stats_type Optional[str]

Statistics type to show. Allowed values: '(empty)' (Default view), 'MyArena' (Show supporter statistics for the users own arena), 'OtherArenas' (Shows supporter statistics over biggest arenas).

None
arena_id Optional[int]

Which arena to show details for. If None (the default), Hattrick uses the authenticated user's arena ID, if no team ID is supplied.

None
team_id Optional[int]

Which of the authenticated user's teams' arenas to show details for, only used when no arena ID is supplied. If None (the default), Hattrick uses the authenticated user's primary team's ID.

None
match_type Optional[str]

Which type of matches that will be included in the statistics. If None (the default), Hattrick uses All.

None
first_date Optional[datetime]

The first date the statistics should cover. If None (the default), Hattrick uses Date of first match in arena.

None
last_date Optional[datetime]

The last date the statistics should cover. If None (the default), Hattrick uses DateTime.Now.

None
stats_league_id Optional[int]

Which league to show statistics for. 0 = global statistic. Defaults to 0.

None

Returns:

Type Description
ArenaDetailsDefault | ArenaDetailsMyArena | ArenaDetailsLeagueArenaStats

The parsed data from the arena_details.xml file.

xml_avatars

xml_avatars(action_type=None, team_id=None, **kwargs)

Request the avatars.xml file from the CHPP API.

Parameters:

Name Type Description Default
action_type Optional[str]

Indicates what type of action the page should perform. Allowed values: 'players' (View the avatars of players for the team of the currently authenticated user), 'hof' (View the avatars of Hall of Fame players for the team of the currently authenticated user).

None
team_id Optional[int]

What team/user to show the avatars for. If None (the default), Hattrick uses the authenticated user's senior team ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
Avatars

The parsed data from the avatars.xml file.

xml_bookmarks

xml_bookmarks(bookmark_type_id=None, **kwargs)

Request the bookmarks.xml file from the CHPP API.

Parameters:

Name Type Description Default
bookmark_type_id Optional[int]

Bookmark Type.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
Bookmarks

The parsed data from the bookmarks.xml file.

xml_challenges

xml_challenges(
    action_type="view",
    team_id=None,
    is_weekend_friendly=0,
    suggested_team_ids=None,
    opponent_team_id=None,
    match_type=None,
    match_place=None,
    neutral_arena_id=None,
    training_match_id=None,
    **kwargs,
)

Request the challenges.xml file from the CHPP API.

Parameters:

Name Type Description Default
action_type str

Indicates what type of action the page should perform. Allowed values: 'view' (Returns data on the challenges made by the authenticated user and the offers received), 'challengeable' (Check if it is possible to challenge the teams specified in parameter suggestedTeamIDs), 'challenge' (Challenge an opponent to a friendly match. (Requires "manage_challenges" scope.)), 'accept' (Accept a challenge from an opponent. (Requires "manage_challenges" scope.)), 'decline' (Decline a challenge from an opponent. (Requires "manage_challenges" scope.)), 'withdraw' (Withdraw a not yet accepted challenge. (Requires "manage_challenges" scope.)).

'view'
team_id Optional[int]

Team ID to manage challenges for. Must refer to a senior team managed by requesting user. If None (the default), Hattrick uses the authenticated user's primary team ID.

None
is_weekend_friendly int

Show weekend Friendly match and use it to set data for weekend friendly. Defaults to 0.

0
suggested_team_ids Optional[str]

A comma-separated list of teamID numbers for the teams to check the challengeable status for.

None
opponent_team_id Optional[int]

The ID of the team to challenge.

None
match_type Optional[int]

Specifies whether to challenge for a normal friendly (0) or a friendly with cup rules (1). If None (the default), Hattrick uses 0.

None
match_place Optional[int]

Defines if challenger wants to play home (0), away (1) or on a neutral arena (2). If None (the default), Hattrick uses 0.

None
neutral_arena_id Optional[int]

ArenaID for arena where friendly on neutral ground should be played. If None (the default), Hattrick uses 0.

None
training_match_id Optional[int]

Specifies the training match ID for the friendly offer to accept.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
ChallengesView | ChallengesChallengeable | ChallengesChallenge | ChallengesAccept | ChallengesDecline | ChallengesWithdraw

The parsed data from the challenges.xml file.

xml_club

xml_club(team_id=None, **kwargs)

Request the club.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

Team ID to get data for. Must refer to a senior team managed by requesting user. If None (the default), Hattrick uses the authenticated user's primary team ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
Club

The parsed data from the club.xml file.

xml_cup_matches

xml_cup_matches(
    cup_id,
    season=None,
    cup_round=None,
    start_after_match_id=None,
    **kwargs,
)

Request the cup_matches.xml file from the CHPP API.

Parameters:

Name Type Description Default
cup_id int

What cup to show the matches for.

required
season Optional[int]

What season to show the matches for. If None (the default), Hattrick uses Latest Season.

None
cup_round Optional[int]

What cupround to show the matches for. If None (the default), Hattrick uses Latest CupRound.

None
start_after_match_id Optional[int]

For large cups in the first round, there will be more than 256 matches to display. To be able to fetch the next 256 matches, take the last MatchID received from the XML output. Send it as StartAfterMatchID=matchID. This will return the next 256 matches with MatchID > StartAfterMatchID. Matches are sorted by MatchID ascending. If None (the default), Hattrick uses 0.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
CupMatches

The parsed data from the cup_matches.xml file.

xml_current_bids

xml_current_bids(
    action_type="view",
    team_id=None,
    transfer_id=None,
    tracking_type_id=None,
    **kwargs,
)

Request the current_bids.xml file from the CHPP API.

Parameters:

Name Type Description Default
action_type str

Indicates what type of action the page should perform. Allowed values: 'view' (Shows all active, recently finished or hotlisted transfers for the specified team), 'ignoreTransfer' (Removes the tracking of a specific transfer, for Supporters only), 'deleteAllFinished' (Removes the tracking of all finished transfers in one go, for Supporters only).

'view'
team_id Optional[int]

Team ID to show the transfers for. Must refer to a senior team managed by requesting user. If None (the default), Hattrick uses the authenticated user's primary team ID.

None
transfer_id Optional[int]

ID of the transfer to be ignored.

None
tracking_type_id Optional[int]

Tracking type (category) of the transfer to be ignored. Only values 5, 8 and 9 are allowed.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
CurrentBids

The parsed data from the current_bids.xml file.

xml_economy

xml_economy(team_id=None, **kwargs)

Request the economy.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

Team ID to get data for. Must refer to a senior team managed by requesting user. If None (the default), Hattrick uses the authenticated user's primary team ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
Economy

The parsed data from the economy.xml file.

xml_fans

xml_fans(team_id=None, **kwargs)

Request the fans.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

Team ID to get data for. Must refer to a senior team managed by requesting user. If None (the default), Hattrick uses the authenticated user's primary team ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
Fans

The parsed data from the fans.xml file.

xml_hof_players

xml_hof_players(team_id=None, **kwargs)

Request the hof_players.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

Team ID for HoF. If None (the default), Hattrick uses the authenticated user's ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
HallOfFamePlayers

The parsed data from the hof_players.xml file.

xml_ladder_details

xml_ladder_details(
    team_id=None, page_size=None, page_index=None, **kwargs
)

Request the ladder_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

If pageindex is -1, the page where this team is positioned will be shown. If None (the default), Hattrick uses the authenticated user's primary team ID.

None
page_size Optional[int]

How many results to be shown in each page, the maximum value is 100. If None (the default), Hattrick uses 25.

None
page_index Optional[int]

What page to be shown, starts from 0. If None (the default), Hattrick uses -1.

None
ladder_id

Ladder ID to get data for.

required
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
LadderDetails

The parsed data from the ladder_details.xml file.

xml_ladder_list

xml_ladder_list(team_id=None, **kwargs)

Request the ladder_list.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

Team ID to get data for. If None (the default), Hattrick uses the authenticated user's primary team ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
LadderList

The parsed data from the ladder_list.xml file.

xml_league_details

xml_league_details(league_level_unit_id=None, **kwargs)

Request the league_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
league_level_unit_id Optional[int]

Specifies the 'series' (leagueLevelUnit) to look for data on. If None (the default), Hattrick uses LeaguelevelUnitID of the team of the currently authenticated user's primary club.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
LeagueDetails

The parsed data from the league_details.xml file.

xml_league_fixtures

xml_league_fixtures(
    league_level_unit_id=None, season=None, **kwargs
)

Request the league_fixtures.xml file from the CHPP API.

Parameters:

Name Type Description Default
league_level_unit_id Optional[int]

Specifies the 'series' (leagueLevelUnit) to look for data on. If None (the default), Hattrick uses LeaguelevelUnitID of the team of the currently authenticated user's primary club.

None
season Optional[int]

Specifies the season to look for data on. If None (the default), Hattrick uses the current season.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
LeagueFixtures

The parsed data from the league_fixtures.xml file.

xml_league_levels

xml_league_levels(league_id=None, **kwargs)

Request the league_levels.xml file from the CHPP API.

Parameters:

Name Type Description Default
league_id Optional[int]

The ID number of the League (for instance Sverige, USA, England...). If None (the default), Hattrick uses league ID of the team of the authenticated user's primary club.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
LeagueLevels

The parsed data from the league_levels.xml file.

xml_live

xml_live(
    action_type="view",
    match_id=None,
    source_system="hattrick",
    include_starting_lineup=False,
    use_live_events_and_texts=False,
    last_shown_indexes=None,
    **kwargs,
)

Request the live.xml file from the CHPP API.

Parameters:

Name Type Description Default
action_type str

Indicates what type of action the page should perform. Allowed values: 'view' (Show the latest event(s) for all tracked matches. If matchID is supplied), 'viewNew' (Show those matches where new events have occured since last request of the page), 'viewAll' (Show all the events for all matches), 'clearAll' (Remove all tracked matches from the tracking session), 'addMatch' (Add a new match to be tracked), 'deleteMatch' (Remove a particular match from the session).

'view'
match_id Optional[int]

The globally unique matchID.

None
source_system str

Specifies which source system the match belongs to. Defaults to hattrick.

'hattrick'
include_starting_lineup bool

Should StartingLineup and Substitutions be included in the response? Defaults to false.

False
use_live_events_and_texts bool

Should the events and texts be as on the live page on the site? Defaults to false.

False
last_shown_indexes Optional[str]

JSON formatted array of last shown indexes for each match.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
Live

The parsed data from the live.xml file.

xml_manager_compendium

xml_manager_compendium(user_id=None, **kwargs)

Request the manager_compendium.xml file from the CHPP API.

Parameters:

Name Type Description Default
user_id Optional[int]

What user to show the data for. If None (the default), Hattrick uses the authenticated user's ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
ManagerCompendium

The parsed data from the manager_compendium.xml file.

xml_match_details

xml_match_details(
    match_id,
    source_system=None,
    match_events=None,
    **kwargs,
)

Request the match_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
match_id int

Which match to show details for.

required
source_system Optional[str]

Specifies which source system the match belongs to.

None
match_events Optional[bool]

Whether match events shall be shown or not. Allowed values: 'false' (Show no match events), 'true' (Show match events).

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
MatchDetails

The parsed data from the match_details.xml file.

xml_match_lineup

xml_match_lineup(
    match_id=None,
    team_id=None,
    source_system=None,
    **kwargs,
)

Request the match_lineup.xml file from the CHPP API.

Parameters:

Name Type Description Default
match_id Optional[int]

Specifies which particular match data is requested for. If None (the default), Hattrick uses the last match.

None
team_id Optional[int]

Specifies which of the two participating teams data should be shown for. If None (the default), Hattrick uses the authenticated user's team.

None
source_system Optional[str]

Specifies which source system the match belongs to. If None (the default), Hattrick uses Hattrick.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
MatchLineup

The parsed data from the match_lineup.xml file.

xml_match_orders

xml_match_orders(
    match_id,
    action_type="view",
    team_id=None,
    source_system="Hattrick",
    lineup=None,
    **kwargs,
)

Request the match_orders.xml file from the CHPP API.

Parameters:

Name Type Description Default
match_id int

Specifies which particular match data is requested for.

required
action_type str

Indicates what type of action the page should perform. Allowed values: 'view' (Returns data on the matchorder for the match requested), 'setmatchorder' (Sets a matchorder for the match specified. Requests to set matchorder), 'predictratings' (Predicts the sector and tactic ratings for the match specified).

'view'
team_id Optional[int]

Team ID to get/set orders for. Must refer to a senior or youth team managed by requesting user. If None (the default), Hattrick uses the authenticated user's primary team ID.

None
source_system str

Specifies which source system the match belongs to. Defaults to Hattrick.

'Hattrick'
lineup Optional[str]

JSON formatted match orders to set for the match specified or to predict ratings. Must be specified as request body for POST. Required for actionType=setmatchorder and optional for actionType=predictratings, otherwise not used.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
MatchOrdersView | MatchOrdersSetMatchOrder | MatchOrdersPredictRatings

The parsed data from the match_orders.xml file.

xml_matches

xml_matches(team_id=None, is_youth=None, **kwargs)

Request the matches.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

What team to show the matches for: Either teamID or youthTeamID depending on isYouth. If None (the default), Hattrick uses the authenticated user's senior or youth team ID.

None
is_youth Optional[bool]

Is request for youth or not. If None (the default), Hattrick uses false.

None
last_match_date

Last date to show matches to. If more than 50 matches are affected, only the 50 first will be returned. If None (the default), Hattrick uses Datetime.Now + 28 days.

required
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
Matches

The parsed data from the matches.xml file.

xml_matches_archive

xml_matches_archive(
    team_id=None,
    is_youth=None,
    first_match_date=None,
    last_match_date=None,
    season=None,
    include_hto=None,
    **kwargs,
)

Request the matches_archive.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

What team to show the matches for: Either teamID or youthTeamID depending on isYouth. If None (the default), Hattrick uses the authenticated user's senior or youth team ID.

None
is_youth Optional[bool]

Is request for youth or not. If None (the default), Hattrick uses false.

None
first_match_date Optional[datetime]

First date to show matches in archive from. If None (the default), Hattrick uses Datetime.Now - 3 months.

None
last_match_date Optional[datetime]

Last date to show matches to. For performance reasons, only an interval of 2 seasons back in time can be specified. If None (the default), Hattrick uses Datetime.Now - 1 day.

None
season Optional[int]

Season to show matches for. (Only valid for senior teams, not for youth!).

None
include_hto Optional[bool]

If HTO matches (tournaments, ladders, preparation, and single matches) should be included. If None (the default), Hattrick uses false.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
MatchesArchive

The parsed data from the matches_archive.xml file.

xml_national_players

xml_national_players(
    team_id,
    action_type="view",
    match_type_category=None,
    show_all=None,
    **kwargs,
)

Request the national_players.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id int

What national team type to list.

required
action_type str

Indicates what type of action the page should perform. Allowed values: 'view' (View the national team players of a specific type ('regular' or 'U-20')), 'SupporterStats' (View the number of matches that players have played in the national team).

'view'
match_type_category Optional[int]

What national team type to list ('NT' = all matches played in this National Team, 'WC' = World Cup matches played in this National Team). If None (the default), Hattrick uses NT.

None
show_all Optional[bool]

Whether to show all players (true) or a maximum of 20 players ordered by number of matches played (false). If None (the default), Hattrick uses false.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
NationalPlayersView | NationalPlayersStats

The parsed data from the national_players.xml file.

xml_national_prospect_players

xml_national_prospect_players(
    team_id, player_category_id=None, **kwargs
)

Request the national_prospect_players.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id int

The nationalTeamID to list prospect players for.

required
player_category_id Optional[int]

Only list the prospect players in this category. Use 0 for players with no category set. If None (the default), Hattrick uses All categories.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
NationalProspectPlayers

The parsed data from the national_prospect_players.xml file.

xml_national_team_details

xml_national_team_details(team_id, **kwargs)

Request the national_team_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id int

What national team type to list.

required
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
NationalTeamDetails

The parsed data from the national_team_details.xml file.

xml_national_team_matches

xml_national_team_matches(
    league_office_type_id=None, **kwargs
)

Request the national_team_matches.xml file from the CHPP API.

Parameters:

Name Type Description Default
league_office_type_id Optional[int]

What national team type to list (2 = National teams, 4 = U-20 Teams). If None (the default), Hattrick uses 2.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
NationalTeamMatches

The parsed data from the national_team_matches.xml file.

xml_national_teams

xml_national_teams(league_office_type_id=None, **kwargs)

Request the national_teams.xml file from the CHPP API.

Parameters:

Name Type Description Default
league_office_type_id Optional[int]

What national team type to list (2 = National teams, 4 = U-20 Teams). If None (the default), Hattrick uses 2.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
NationalTeams

The parsed data from the national_teams.xml file.

xml_player_details

xml_player_details(
    action_type=None,
    player_id=None,
    include_match_info=None,
    team_id=None,
    bid_amount=None,
    max_bid_amount=None,
    **kwargs,
)

Request the player_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
action_type Optional[str]

Indicates what type of action the page should perform. Allowed values: 'view' (Shows information for the player with the corresponding playerID), 'placeBid' (Places a bid on the player and then shows all the information, for Supporters).

None
player_id Optional[int]

The player to get information for.

None
include_match_info Optional[bool]

Set it to 'true' to get LastMatch Container. If None (the default), Hattrick uses false.

None
team_id Optional[int]

Team ID of the team placing the bid. Must refer to a senior team managed by requesting user.

None
bid_amount Optional[int]

Bid amount in SEK.

None
max_bid_amount Optional[int]

Maximum bid amount in SEK (autobid).

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
PlayerDetails

The parsed data from the player_details.xml file.

xml_player_events

xml_player_events(player_id=None, **kwargs)

Request the player_events.xml file from the CHPP API.

Parameters:

Name Type Description Default
player_id Optional[int]

The player to get information for.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
PlayerEvents

The parsed data from the player_events.xml file.

xml_player_stats

xml_player_stats(player_id=None, **kwargs)

Request the player_stats.xml file from the CHPP API.

Parameters:

Name Type Description Default
player_id Optional[int]

The player to get statistics for.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
PlayerStats

The parsed data from the player_stats.xml file.

xml_players

xml_players(
    action_type="view",
    order_by=None,
    team_id=None,
    include_match_info=None,
    **kwargs,
)

Request the players.xml file from the CHPP API.

Parameters:

Name Type Description Default
action_type str

Indicates what type of action the page should perform. Allowed values: 'view' (View the list of players belonging to a team), 'viewOldies' (View the list of players who no longer belong to the club but were promoted from the youth team), 'viewOldCoaches' (View list of former players that now are coaches).

'view'
order_by Optional[str]

The field that the outdata PlayerList should be sorted by. If None (the default), Hattrick uses PlayerNumber.

None
team_id Optional[int]

The team for which the data should apply to. If None (the default), Hattrick uses the authenticated user's team ID.

None
include_match_info Optional[bool]

Include LastMatch container for all players. If None (the default), Hattrick uses false.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
PlayersView | PlayersViewOldies | PlayersViewOldCoaches

The parsed data from the players.xml file.

xml_region_details

xml_region_details(region_id=None, **kwargs)

Request the region_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
region_id Optional[int]

The region to get information for.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
RegionDetails

The parsed data from the region_details.xml file.

xml_search(
    search_type=None,
    search_string=None,
    search_string_2=None,
    search_id=None,
    search_league_id=None,
    page_index=None,
    **kwargs,
)

Request the search.xml file from the CHPP API.

Parameters:

Name Type Description Default
search_type Optional[int]

Which type of search to perform. Allowed values: '0' (Search for players), '1' (Search for arenas), '2' (Search for managers), '3' (Search for series), '4' (Search for teams), '5' (Search for regions), '6' (Search for match).

None
search_string Optional[str]

The string to search for. Must be >= 3 characters long.

None
search_string_2 Optional[str]

The second string to search for. Must be >= 3 characters long.

None
search_id Optional[int]

The specific ID to search for.

None
search_league_id Optional[int]

The specific LeagueID to search in. -1 searches in ALL leagues. If None (the default), Hattrick uses the authenticated user's league ID.

None
page_index Optional[int]

The zerobased PageIndex to retrieve. Will only have effect when resultset has more than 25 rows.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
Search

The parsed data from the search.xml file.

xml_staff_avatars

xml_staff_avatars(team_id=None, **kwargs)

Request the staff_avatars.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

Team ID to get data for. If None (the default), Hattrick uses the authenticated user's primary team ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
StaffAvatars

The parsed data from the staff_avatars.xml file.

xml_staff_list

xml_staff_list(team_id=None, **kwargs)

Request the staff_list.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

Team ID to get data for. If None (the default), Hattrick uses the authenticated user's primary team ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
StaffList

The parsed data from the staff_list.xml file.

xml_supporters

xml_supporters(
    action_type="supportedteams",
    user_id=None,
    team_id=None,
    page_index=None,
    page_size=None,
    **kwargs,
)

Request the supporters.xml file from the CHPP API.

Parameters:

Name Type Description Default
action_type str

Indicates what type of action the page should perform. Allowed values: 'supportedteams' (See the teams the user support), 'mysupporters' (See the teams supporting the team).

'supportedteams'
user_id Optional[int]

User ID to get data for. If None (the default), Hattrick uses the authenticated user's ID.

None
team_id Optional[int]

Team ID to get data for. If None (the default), Hattrick uses the authenticated user's primary team ID.

None
page_index Optional[int]

Zero based pageindex to retrieve. If None (the default), Hattrick uses 0.

None
page_size Optional[int]

How many results to be shown in each page, the maximum value is 500.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
SupportersSupportedTeams | SupportersMySupporters

The parsed data from the supporters.xml file.

xml_team_details

xml_team_details(
    team_id=None,
    user_id=None,
    include_domestics_flags=None,
    include_flags=None,
    include_supporters=None,
    **kwargs,
)

Request the team_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

Which team/user to show data for. teamID and userID give the same result, except that ownerless teams can only be accessed if submitting a teamID and that users without a team can only be accessed if userID is submitted. If None (the default), Hattrick uses the authenticated user's senior team ID.

None
user_id Optional[int]

Which team/user to show data for. If neither user_id nor team_id is supplied, user_id defaults to the authenticated user's ID.

None
include_domestics_flags Optional[bool]

Whether or not the teams own country should be included in the flag collections (provided games against domestic opponents have been played). If None (the default), Hattrick uses false.

None
include_flags Optional[bool]

Whether or not the flag collection should be provided. If None (the default), Hattrick uses false.

None
include_supporters Optional[bool]

Whether or not the supported teams and the teams supporters should be included. If None (the default), Hattrick uses false.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
TeamDetails

The parsed data from the team_details.xml file.

xml_team_history

xml_team_history(team_id=None, **kwargs)

Request the team_history.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

The ID of the team to fetch the history for. If None (the default), Hattrick uses the authenticated user's primary team ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
TeamHistory

The parsed data from the team_history.xml file.

xml_tournament_details

xml_tournament_details(
    tournament_id, season=None, **kwargs
)

Request the tournament_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
tournament_id int

The ID for the tournament to get data for.

required
season Optional[int]

The season of the tournament.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
TournamentDetails

The parsed data from the tournament_details.xml file.

xml_tournament_fixtures

xml_tournament_fixtures(
    tournament_id, season=None, match_round=None, **kwargs
)

Request the tournament_fixtures.xml file from the CHPP API.

Parameters:

Name Type Description Default
tournament_id int

The ID for the tournament to get data for.

required
season Optional[int]

The starting season of the tournament. This is available only for National Teams cups.

None
match_round Optional[int]

Specific match round for this tournament. It will pick the last match round if the selected round is greater than the tournament's last round.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
TournamentFixtures

The parsed data from the tournament_fixtures.xml file.

xml_tournament_league_tables

xml_tournament_league_tables(
    tournament_id,
    season=None,
    world_cup_round=None,
    **kwargs,
)

Request the tournament_league_tables.xml file from the CHPP API.

Parameters:

Name Type Description Default
tournament_id int

The ID for the tournament to get data for.

required
season Optional[int]

The season of the tournament.

None
world_cup_round Optional[int]

Specifies which particular world cup stage data is requested for. Used only for World Cup tournaments. Otherwise, not used.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
TournamentLeagueTables

The parsed data from the tournament_league_tables.xml file.

xml_tournament_list

xml_tournament_list(team_id=None, **kwargs)

Request the tournament_list.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

Team ID to get data for. If None (the default), Hattrick uses the authenticated user's primary team ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
TournamentList

The parsed data from the tournament_list.xml file.

xml_training

xml_training(
    action_type="view",
    team_id=None,
    training_type=None,
    training_level=None,
    training_level_stamina=None,
    league_id=None,
    from_date=None,
    **kwargs,
)

Request the training.xml file from the CHPP API.

Parameters:

Name Type Description Default
action_type str

Indicates what type of action the page should perform. Allowed values: 'view' (Training information for the authenticated user's team), 'stats' (Shows the distribution among training types for all leagues or for a specific league), 'setTraining' (Set the training settings for the authenticated user's team. (Requires "set_training" scope)), 'history' (The training changes of a senior team since a given date. Requires Gold supporter).

'view'
team_id Optional[int]

Team ID to view training information for. Must refer to a senior team managed by requesting user. For actionType=history, it can also be a team the user mentors. If None (the default), Hattrick uses the authenticated user's primary team ID, except in action setTraining.

None
training_type Optional[int]

Type of training to be set for the specified team if action is setTraining.

None
training_level Optional[int]

Training level to be set for the specified team (0-100) if action is setTraining.

None
training_level_stamina Optional[int]

Stamina level to be set for the specified team (5-100) if action is setTraining.

None
league_id Optional[int]

What LeagueID to retrieve statistics for (empty for global stats in version 1.7 or above). If None (the default), Hattrick uses the authenticated user's league ID.

None
from_date Optional[datetime]

The date to start the training history from. A date before the first Hattrick season or in the future is moved to the nearest valid date. If None (the default), Hattrick uses 16 weeks before today.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
TrainingView | TrainingSetTraining | TrainingStats | TrainingHistoryView

The parsed data from the training.xml file.

xml_training_events

xml_training_events(player_id, **kwargs)

Request the training_events.xml file from the CHPP API.

Parameters:

Name Type Description Default
player_id int

What player to show training events for.

required
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
TrainingEvents

The parsed data from the training_events.xml file.

xml_transfer_search(
    age_min,
    age_max,
    skill_type_1,
    min_skill_value_1,
    max_skill_value_1,
    age_days_min=None,
    age_days_max=None,
    skill_type_2=None,
    min_skill_value_2=None,
    max_skill_value_2=None,
    skill_type_3=None,
    min_skill_value_3=None,
    max_skill_value_3=None,
    skill_type_4=None,
    min_skill_value_4=None,
    max_skill_value_4=None,
    specialty=None,
    native_country_id=None,
    tsi_min=None,
    tsi_max=None,
    price_min=None,
    price_max=None,
    salary_min=None,
    salary_max=None,
    transfer_compare_avg_min=None,
    transfer_compare_avg_max=None,
    page_size=None,
    page_index=None,
    **kwargs,
)

Request the transfer_search.xml file from the CHPP API.

Parameters:

Name Type Description Default
age_min int

Minimum age value (years) to search for.

required
age_max int

Maximum age value (years) to search for.

required
skill_type_1 int

Main skill to search for.

required
min_skill_value_1 int

Minimum value for the main skill (skillType1) to search for. The difference between min and max can be up to 4 levels. Set pieces, leadership and experience need a minimum level of 5 and keeper of 3.

required
max_skill_value_1 int

Maximum value for the main skill (skillType1) to search for. The difference between min and max can be up to 4 levels.

required
age_days_min Optional[int]

Minimum age value (days) to search for. If None (the default), Hattrick uses 0.

None
age_days_max Optional[int]

Maximum age value (days) to search for. If None (the default), Hattrick uses 111.

None
skill_type_2 Optional[int]

Secondary skill to search for. If None (the default), Hattrick uses 'Not specified'.

None
min_skill_value_2 Optional[int]

Minimum value for the secondary skill (skillType2) to search for. If None (the default), Hattrick uses 'Not specified'.

None
max_skill_value_2 Optional[int]

Maximum value for the secondary skill (skillType2) to search for. If None (the default), Hattrick uses 'Not specified'.

None
skill_type_3 Optional[int]

Secondary skill to search for. If None (the default), Hattrick uses 'Not specified'.

None
min_skill_value_3 Optional[int]

Minimum value for the secondary skill (skillType3) to search for. If None (the default), Hattrick uses 'Not specified'.

None
max_skill_value_3 Optional[int]

Maximum value for the secondary skill (skillType3) to search for. If None (the default), Hattrick uses 'Not specified'.

None
skill_type_4 Optional[int]

Secondary skill to search for. If None (the default), Hattrick uses 'Not specified'.

None
min_skill_value_4 Optional[int]

Minimum value for the secondary skill (skillType4) to search for. If None (the default), Hattrick uses 'Not specified'.

None
max_skill_value_4 Optional[int]

Maximum value for the secondary skill (skillType4) to search for. If None (the default), Hattrick uses 'Not specified'.

None
specialty Optional[int]

The specialty of the players to search for. If None (the default), Hattrick uses 'Not specified'.

None
native_country_id Optional[int]

CountryID where the players to search for where born. If None (the default), Hattrick uses Not specified.

None
tsi_min Optional[int]

Minimum TSI value to search for. If None (the default), Hattrick uses 'Not specified'.

None
tsi_max Optional[int]

Maximum TSI value to search for. If None (the default), Hattrick uses 'Not specified'.

None
price_min Optional[int]

Minimum price to search for. If None (the default), Hattrick uses 'Not specified'.

None
price_max Optional[int]

Maximum price to search for. If None (the default), Hattrick uses 'Not specified'.

None
salary_min Optional[int]

Minimum weekly salary to search for. It is the player's base salary, without the extra 20% for foreign players, the same value as Salary in the results. If None (the default), Hattrick uses 'Not specified'.

None
salary_max Optional[int]

Maximum weekly salary to search for. It is the player's base salary, without the extra 20% for foreign players, the same value as Salary in the results. If None (the default), Hattrick uses 'Not specified'.

None
transfer_compare_avg_min Optional[int]

Minimum transfer estimate to search for. It is the estimate saved when the player was put on the market. Players without an estimate are left out when this is set. If None (the default), Hattrick uses 'Not specified'.

None
transfer_compare_avg_max Optional[int]

Maximum transfer estimate to search for. It is the estimate saved when the player was put on the market. Players without an estimate are included. If None (the default), Hattrick uses 'Not specified'.

None
page_size Optional[int]

How many results to be shown in each page, the maximum value is 100. If None (the default), Hattrick uses 25.

None
page_index Optional[int]

What page to be shown, starts from 0. If None (the default), Hattrick uses 0.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
TransferSearch

The parsed data from the transfer_search.xml file.

xml_transfers_player

xml_transfers_player(player_id, **kwargs)

Request the transfers_player.xml file from the CHPP API.

Parameters:

Name Type Description Default
player_id int

The player to get the transfers for.

required
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
TransfersPlayer

The parsed data from the transfers_player.xml file.

xml_transfers_team

xml_transfers_team(team_id=None, page_index=None, **kwargs)

Request the transfers_team.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

What team to show the transfers for. If None (the default), Hattrick uses the authenticated user's team ID.

None
page_index Optional[int]

What page in the list to retrieve. Each page consists of 25 records unless last page which may contain 25 or less. To get the last page, specify 0. Defaults to 1.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
TransfersTeam

The parsed data from the transfers_team.xml file.

xml_translations

xml_translations(language_id=None, **kwargs)

Request the translations.xml file from the CHPP API.

Parameters:

Name Type Description Default
language_id Optional[int]

The ID of the language to get the translations for.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
Translations

The parsed data from the translations.xml file.

xml_world_cup

xml_world_cup(
    action_type="viewMatches",
    cup_id=None,
    season=None,
    match_round=None,
    cup_series_unit_id=None,
    **kwargs,
)

Request the world_cup.xml file from the CHPP API.

Parameters:

Name Type Description Default
action_type str

Indicates what type of action the page should perform. Allowed values: 'viewMatches' (View a list of the matches of a particular group), 'viewGroups' (View a list of the groups (with points, place, etc.) of a particular round, season).

'viewMatches'
cup_id Optional[int]

The globally unique cupID. If None (the default), Hattrick uses 137 (the World Cup).

None
season Optional[int]

The starting season of the cup.

None
match_round Optional[int]

A key that indicates a certain round (typically 10 weeks or 9 days). Qualifications are always matchRound 1. If None (the default), Hattrick uses the last initialized round of the chosen cup.

None
cup_series_unit_id Optional[int]

The globally unique identifier of the CupSeriesUnit (a 'group' of 4-6 teams).

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
WorldCupViewMatches | WorldCupViewGroups

The parsed data from the world_cup.xml file.

xml_world_details

xml_world_details(
    league_id=None,
    country_id=None,
    include_regions=None,
    **kwargs,
)

Request the world_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
league_id Optional[int]

The leagueID to get information for.

None
country_id Optional[int]

The countryID to get information for.

None
include_regions Optional[bool]

Indicates if regions should be shown or not.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
WorldDetails

The parsed data from the world_details.xml file.

xml_world_languages

xml_world_languages(**kwargs)

Request the world_languages.xml file from the CHPP API.

Parameters:

Name Type Description Default
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
WorldLanguages

The parsed data from the world_languages.xml file.

xml_youth_avatars

xml_youth_avatars(youth_team_id=None, **kwargs)

Request the youth_avatars.xml file from the CHPP API.

Parameters:

Name Type Description Default
youth_team_id Optional[int]

Youth team ID to get data for. Must refer to a youth team managed by requesting user. If None (the default), Hattrick uses the authenticated user's primary youth team ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
YouthAvatars

The parsed data from the youth_avatars.xml file.

xml_youth_league_details

xml_youth_league_details(youth_league_id=None, **kwargs)

Request the youth_league_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
youth_league_id Optional[int]

Specifies the 'series' (league) to look for data on. If None (the default), Hattrick uses LeagueID of the youth team of the authenticated user's primary club.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
YouthLeagueDetails

The parsed data from the youth_league_details.xml file.

xml_youth_league_fixtures

xml_youth_league_fixtures(
    youth_league_id=None, season=None, **kwargs
)

Request the youth_league_fixtures.xml file from the CHPP API.

Parameters:

Name Type Description Default
youth_league_id Optional[int]

Specifies the 'series' (league) to look for data on. If None (the default), Hattrick uses LeagueID of the youth team of the authenticated user's primary club.

None
season Optional[int]

The season number for the league. If None (the default), Hattrick uses the current season for the YouthLeagueID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
YouthLeagueFixtures

The parsed data from the youth_league_fixtures.xml file.

xml_youth_player_details

xml_youth_player_details(
    action_type=None,
    youth_player_id=None,
    show_scout_call=None,
    show_last_match=None,
    **kwargs,
)

Request the youth_player_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
action_type Optional[str]

Indicates what type of action the page should perform. Allowed values: 'details' (Show the player information), 'unlockskills' (Unlock the skills of the player before showing the player information).

None
youth_player_id Optional[int]

The player to get information for.

None
show_scout_call Optional[bool]

Set it to 'true' to get the information the scout provided when the player was scouted. If None (the default), Hattrick uses false.

None
show_last_match Optional[bool]

Set it to 'true' to get LastMatch container. If None (the default), Hattrick uses false.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
YouthPlayerDetails

The parsed data from the youth_player_details.xml file.

xml_youth_player_list

xml_youth_player_list(
    action_type="list",
    order_by=None,
    youth_team_id=None,
    show_scout_call=None,
    show_last_match=None,
    **kwargs,
)

Request the youth_player_list.xml file from the CHPP API.

Parameters:

Name Type Description Default
action_type str

Indicates what type of action the page should perform. Allowed values: 'list' (List the players, containing only PlayerID and Name-containers), 'details' (Show detailed players information), 'unlockskills' (Unlock the skills of the entire team before showing the players information).

'list'
order_by Optional[str]

The field that the outdata PlayerList should be sorted by. If None (the default), Hattrick uses PlayerNumber.

None
youth_team_id Optional[int]

The youth team for which the data should apply to. If None (the default), Hattrick uses the authenticated user's youth team ID.

None
show_scout_call Optional[bool]

Set it to 'true' to get the information the scout provided when the player was scouted. Only available if actionType=details or actionType=unlockskills. If None (the default), Hattrick uses false.

None
show_last_match Optional[bool]

Set it to 'true' to get LastMatch container. Only available if actionType=details or actionType=unlockskills. If None (the default), Hattrick uses false.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
YouthPlayerListList | YouthPlayerListDetails

The parsed data from the youth_player_list.xml file.

xml_youth_team_details

xml_youth_team_details(
    youth_team_id=None, show_scouts=None, **kwargs
)

Request the youth_team_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
youth_team_id Optional[int]

Which team/user to show data for. If None (the default), Hattrick uses the authenticated user's youth team ID.

None
show_scouts Optional[bool]

Set it to 'true' to get ScoutList container. If None (the default), Hattrick uses false.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
YouthTeamDetails

The parsed data from the youth_team_details.xml file.

youth_player

youth_player(id_, **kwargs)

Get a youth player by their Hattrick ID.

Parameters:

Name Type Description Default
id_ int

Hattrick ID of the requested youth player.

required
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

youth_team

youth_team(id_=None, **kwargs)

Get a youth team by its Hattrick ID.

If no id_ is provided, the youth primary team of the connected user is returned.

Parameters:

Name Type Description Default
id_ Optional[int]

Hattrick ID of the requested youth team.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

CHPPBase

CHPPBase(
    consumer_key,
    consumer_secret,
    access_token_key=None,
    access_token_secret=None,
)

Manage the connection and the requests with the Hattrick CHPP API.

Parameters:

Name Type Description Default
consumer_key str

Consumer key of the application.

required
consumer_secret str

Consumer secret of the application.

required
access_token_key Optional[str]

Access token key for the current user. If not defined, the instance can be used to obtain tokens from Hattrick.

None
access_token_secret Optional[str]

Access token secret for the current user.

None

check_token

check_token()

Check the token key and secret validity.

Returns:

Type Description

Validity and other information about the current token.

get_access_token

get_access_token(request_token, request_token_secret, code)

Query the access token from Hattrick once the user granted the application.

The access token has to be stored by the application in order to be used for further use of the CHPP class.

Parameters:

Name Type Description Default
request_token

Request token returned by get_auth().

required
request_token_secret

Request token secret returned by get_auth().

required
code

Code returned by Hattrick after the user granted the application, sent to callback_url by Hattrick or shown directly on Hattrick if callback_url was "oob".

required

Returns:

Type Description

A dict with "key" and "secret" keys.

Raises:

Type Description
ValueError

If request_token, request_token_secret or code is not a string.

get_auth

get_auth(callback_url='oob', scope='')

Get the url, request_token and request_token_secret to authenticate a user.

Parameters:

Name Type Description Default
callback_url

Url that has to be requested by Hattrick after the user has entered their credentials.

'oob'
scope str | list

Authorization granted by the user to the application. Can be one or more of "", "manage_challenges", "set_matchorder", "manage_youthplayers", "set_training", "place_bid".

''

Returns:

Type Description

A dict with "request_token", "request_token_secret" and "url" keys.

Raises:

Type Description
ValueError

If callback_url or scope is invalid.

invalidate_token

invalidate_token()

Invalidate the current token.

Returns:

Type Description

Information about the invalidated token.

open_session

open_session()

Open the OAuth session.

request

request(**kwargs)

Send a request to the CHPP API endpoint.

Parameters:

Name Type Description Default
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
Element

The parsed XML data fetched on Hattrick.

Raises:

Type Description
HTError

If the CHPP API returns an error.

CHPPXml

CHPPXml(
    consumer_key,
    consumer_secret,
    access_token_key=None,
    access_token_secret=None,
)

Bases: CHPPBase

Wrapper exposing one method per CHPP XML file.

Each xml_<file>() method fetches and parses the corresponding <file>.xml file from the Hattrick CHPP API. If Hattrick returns an error, a ht_error.HTError subclass is raised.

check_token

check_token()

Check the token key and secret validity.

Returns:

Type Description

Validity and other information about the current token.

get_access_token

get_access_token(request_token, request_token_secret, code)

Query the access token from Hattrick once the user granted the application.

The access token has to be stored by the application in order to be used for further use of the CHPP class.

Parameters:

Name Type Description Default
request_token

Request token returned by get_auth().

required
request_token_secret

Request token secret returned by get_auth().

required
code

Code returned by Hattrick after the user granted the application, sent to callback_url by Hattrick or shown directly on Hattrick if callback_url was "oob".

required

Returns:

Type Description

A dict with "key" and "secret" keys.

Raises:

Type Description
ValueError

If request_token, request_token_secret or code is not a string.

get_auth

get_auth(callback_url='oob', scope='')

Get the url, request_token and request_token_secret to authenticate a user.

Parameters:

Name Type Description Default
callback_url

Url that has to be requested by Hattrick after the user has entered their credentials.

'oob'
scope str | list

Authorization granted by the user to the application. Can be one or more of "", "manage_challenges", "set_matchorder", "manage_youthplayers", "set_training", "place_bid".

''

Returns:

Type Description

A dict with "request_token", "request_token_secret" and "url" keys.

Raises:

Type Description
ValueError

If callback_url or scope is invalid.

invalidate_token

invalidate_token()

Invalidate the current token.

Returns:

Type Description

Information about the invalidated token.

open_session

open_session()

Open the OAuth session.

request

request(**kwargs)

Send a request to the CHPP API endpoint.

Parameters:

Name Type Description Default
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
Element

The parsed XML data fetched on Hattrick.

Raises:

Type Description
HTError

If the CHPP API returns an error.

xml_achievements

xml_achievements(user_id=None, **kwargs)

Request the achievements.xml file from the CHPP API.

Parameters:

Name Type Description Default
user_id Optional[int]

Which user to show achievements for. If None (the default), Hattrick uses the authenticated user's ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
Achievements

The parsed data from the achievements.xml file.

xml_alliance_details

xml_alliance_details(
    action_type="view",
    subset=None,
    alliance_id=None,
    **kwargs,
)

Request the alliance_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
action_type str

Indicates what type of action the page should perform. Allowed values: 'view' (Federation info), 'roles' (View the roles of a federation), 'members' (List the members of a federation), 'membersSubset' (List a subset of the members of a federation).

'view'
subset Optional[int]

Starting character names to show A = 65.... Z = 90. Use 0 for other than english starting characters. Only relevant for actionType membersSubset.

None
alliance_id Optional[int]

ID of the federation to search information for.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
AllianceDetailsView | AllianceDetailsRoles | AllianceDetailsMembers | AllianceDetailsMembersSubset

The parsed data from the alliance_details.xml file.

xml_alliances

xml_alliances(
    search_for,
    search_type=None,
    search_language_id=None,
    page_index=None,
    user_id=None,
    **kwargs,
)

Request the alliances.xml file from the CHPP API.

Parameters:

Name Type Description Default
search_for str

What to search for (length ≥ 3 characters).

required
search_type Optional[int]

Which field to search in. Allowed values: '1' (Let the list include only federations with names beginning with search string), '2' (Let the list include only federations with abbreviation including search string), '3' (Let the list include only federations with description including search string), '4' (Search for a specific AllianceID), '5' (Get the federations of the currently authenticated manager, or of another user).

None
search_language_id Optional[int]

Specifies a language to restrict the federations on the list to. If None (the default), Hattrick uses 0 (all languages).

None
page_index Optional[int]

Zero based pageindex to retrieve. If the search result spans more than one page, the total number of pages is returned. Each result may not return more than 25 rows. If None (the default), Hattrick uses 0.

None
user_id Optional[int]

The user to show the federations for. Gives AccessDenied if the user does not exist or has no team. If None (the default), Hattrick uses the authenticated user's ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
Alliances

The parsed data from the alliances.xml file.

xml_arena_details

xml_arena_details(
    stats_type=None,
    arena_id=None,
    team_id=None,
    match_type=None,
    first_date=None,
    last_date=None,
    stats_league_id=None,
)

Request the arena_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
stats_type Optional[str]

Statistics type to show. Allowed values: '(empty)' (Default view), 'MyArena' (Show supporter statistics for the users own arena), 'OtherArenas' (Shows supporter statistics over biggest arenas).

None
arena_id Optional[int]

Which arena to show details for. If None (the default), Hattrick uses the authenticated user's arena ID, if no team ID is supplied.

None
team_id Optional[int]

Which of the authenticated user's teams' arenas to show details for, only used when no arena ID is supplied. If None (the default), Hattrick uses the authenticated user's primary team's ID.

None
match_type Optional[str]

Which type of matches that will be included in the statistics. If None (the default), Hattrick uses All.

None
first_date Optional[datetime]

The first date the statistics should cover. If None (the default), Hattrick uses Date of first match in arena.

None
last_date Optional[datetime]

The last date the statistics should cover. If None (the default), Hattrick uses DateTime.Now.

None
stats_league_id Optional[int]

Which league to show statistics for. 0 = global statistic. Defaults to 0.

None

Returns:

Type Description
ArenaDetailsDefault | ArenaDetailsMyArena | ArenaDetailsLeagueArenaStats

The parsed data from the arena_details.xml file.

xml_avatars

xml_avatars(action_type=None, team_id=None, **kwargs)

Request the avatars.xml file from the CHPP API.

Parameters:

Name Type Description Default
action_type Optional[str]

Indicates what type of action the page should perform. Allowed values: 'players' (View the avatars of players for the team of the currently authenticated user), 'hof' (View the avatars of Hall of Fame players for the team of the currently authenticated user).

None
team_id Optional[int]

What team/user to show the avatars for. If None (the default), Hattrick uses the authenticated user's senior team ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
Avatars

The parsed data from the avatars.xml file.

xml_bookmarks

xml_bookmarks(bookmark_type_id=None, **kwargs)

Request the bookmarks.xml file from the CHPP API.

Parameters:

Name Type Description Default
bookmark_type_id Optional[int]

Bookmark Type.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
Bookmarks

The parsed data from the bookmarks.xml file.

xml_challenges

xml_challenges(
    action_type="view",
    team_id=None,
    is_weekend_friendly=0,
    suggested_team_ids=None,
    opponent_team_id=None,
    match_type=None,
    match_place=None,
    neutral_arena_id=None,
    training_match_id=None,
    **kwargs,
)

Request the challenges.xml file from the CHPP API.

Parameters:

Name Type Description Default
action_type str

Indicates what type of action the page should perform. Allowed values: 'view' (Returns data on the challenges made by the authenticated user and the offers received), 'challengeable' (Check if it is possible to challenge the teams specified in parameter suggestedTeamIDs), 'challenge' (Challenge an opponent to a friendly match. (Requires "manage_challenges" scope.)), 'accept' (Accept a challenge from an opponent. (Requires "manage_challenges" scope.)), 'decline' (Decline a challenge from an opponent. (Requires "manage_challenges" scope.)), 'withdraw' (Withdraw a not yet accepted challenge. (Requires "manage_challenges" scope.)).

'view'
team_id Optional[int]

Team ID to manage challenges for. Must refer to a senior team managed by requesting user. If None (the default), Hattrick uses the authenticated user's primary team ID.

None
is_weekend_friendly int

Show weekend Friendly match and use it to set data for weekend friendly. Defaults to 0.

0
suggested_team_ids Optional[str]

A comma-separated list of teamID numbers for the teams to check the challengeable status for.

None
opponent_team_id Optional[int]

The ID of the team to challenge.

None
match_type Optional[int]

Specifies whether to challenge for a normal friendly (0) or a friendly with cup rules (1). If None (the default), Hattrick uses 0.

None
match_place Optional[int]

Defines if challenger wants to play home (0), away (1) or on a neutral arena (2). If None (the default), Hattrick uses 0.

None
neutral_arena_id Optional[int]

ArenaID for arena where friendly on neutral ground should be played. If None (the default), Hattrick uses 0.

None
training_match_id Optional[int]

Specifies the training match ID for the friendly offer to accept.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
ChallengesView | ChallengesChallengeable | ChallengesChallenge | ChallengesAccept | ChallengesDecline | ChallengesWithdraw

The parsed data from the challenges.xml file.

xml_club

xml_club(team_id=None, **kwargs)

Request the club.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

Team ID to get data for. Must refer to a senior team managed by requesting user. If None (the default), Hattrick uses the authenticated user's primary team ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
Club

The parsed data from the club.xml file.

xml_cup_matches

xml_cup_matches(
    cup_id,
    season=None,
    cup_round=None,
    start_after_match_id=None,
    **kwargs,
)

Request the cup_matches.xml file from the CHPP API.

Parameters:

Name Type Description Default
cup_id int

What cup to show the matches for.

required
season Optional[int]

What season to show the matches for. If None (the default), Hattrick uses Latest Season.

None
cup_round Optional[int]

What cupround to show the matches for. If None (the default), Hattrick uses Latest CupRound.

None
start_after_match_id Optional[int]

For large cups in the first round, there will be more than 256 matches to display. To be able to fetch the next 256 matches, take the last MatchID received from the XML output. Send it as StartAfterMatchID=matchID. This will return the next 256 matches with MatchID > StartAfterMatchID. Matches are sorted by MatchID ascending. If None (the default), Hattrick uses 0.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
CupMatches

The parsed data from the cup_matches.xml file.

xml_current_bids

xml_current_bids(
    action_type="view",
    team_id=None,
    transfer_id=None,
    tracking_type_id=None,
    **kwargs,
)

Request the current_bids.xml file from the CHPP API.

Parameters:

Name Type Description Default
action_type str

Indicates what type of action the page should perform. Allowed values: 'view' (Shows all active, recently finished or hotlisted transfers for the specified team), 'ignoreTransfer' (Removes the tracking of a specific transfer, for Supporters only), 'deleteAllFinished' (Removes the tracking of all finished transfers in one go, for Supporters only).

'view'
team_id Optional[int]

Team ID to show the transfers for. Must refer to a senior team managed by requesting user. If None (the default), Hattrick uses the authenticated user's primary team ID.

None
transfer_id Optional[int]

ID of the transfer to be ignored.

None
tracking_type_id Optional[int]

Tracking type (category) of the transfer to be ignored. Only values 5, 8 and 9 are allowed.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
CurrentBids

The parsed data from the current_bids.xml file.

xml_economy

xml_economy(team_id=None, **kwargs)

Request the economy.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

Team ID to get data for. Must refer to a senior team managed by requesting user. If None (the default), Hattrick uses the authenticated user's primary team ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
Economy

The parsed data from the economy.xml file.

xml_fans

xml_fans(team_id=None, **kwargs)

Request the fans.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

Team ID to get data for. Must refer to a senior team managed by requesting user. If None (the default), Hattrick uses the authenticated user's primary team ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
Fans

The parsed data from the fans.xml file.

xml_hof_players

xml_hof_players(team_id=None, **kwargs)

Request the hof_players.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

Team ID for HoF. If None (the default), Hattrick uses the authenticated user's ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
HallOfFamePlayers

The parsed data from the hof_players.xml file.

xml_ladder_details

xml_ladder_details(
    team_id=None, page_size=None, page_index=None, **kwargs
)

Request the ladder_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

If pageindex is -1, the page where this team is positioned will be shown. If None (the default), Hattrick uses the authenticated user's primary team ID.

None
page_size Optional[int]

How many results to be shown in each page, the maximum value is 100. If None (the default), Hattrick uses 25.

None
page_index Optional[int]

What page to be shown, starts from 0. If None (the default), Hattrick uses -1.

None
ladder_id

Ladder ID to get data for.

required
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
LadderDetails

The parsed data from the ladder_details.xml file.

xml_ladder_list

xml_ladder_list(team_id=None, **kwargs)

Request the ladder_list.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

Team ID to get data for. If None (the default), Hattrick uses the authenticated user's primary team ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
LadderList

The parsed data from the ladder_list.xml file.

xml_league_details

xml_league_details(league_level_unit_id=None, **kwargs)

Request the league_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
league_level_unit_id Optional[int]

Specifies the 'series' (leagueLevelUnit) to look for data on. If None (the default), Hattrick uses LeaguelevelUnitID of the team of the currently authenticated user's primary club.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
LeagueDetails

The parsed data from the league_details.xml file.

xml_league_fixtures

xml_league_fixtures(
    league_level_unit_id=None, season=None, **kwargs
)

Request the league_fixtures.xml file from the CHPP API.

Parameters:

Name Type Description Default
league_level_unit_id Optional[int]

Specifies the 'series' (leagueLevelUnit) to look for data on. If None (the default), Hattrick uses LeaguelevelUnitID of the team of the currently authenticated user's primary club.

None
season Optional[int]

Specifies the season to look for data on. If None (the default), Hattrick uses the current season.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
LeagueFixtures

The parsed data from the league_fixtures.xml file.

xml_league_levels

xml_league_levels(league_id=None, **kwargs)

Request the league_levels.xml file from the CHPP API.

Parameters:

Name Type Description Default
league_id Optional[int]

The ID number of the League (for instance Sverige, USA, England...). If None (the default), Hattrick uses league ID of the team of the authenticated user's primary club.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
LeagueLevels

The parsed data from the league_levels.xml file.

xml_live

xml_live(
    action_type="view",
    match_id=None,
    source_system="hattrick",
    include_starting_lineup=False,
    use_live_events_and_texts=False,
    last_shown_indexes=None,
    **kwargs,
)

Request the live.xml file from the CHPP API.

Parameters:

Name Type Description Default
action_type str

Indicates what type of action the page should perform. Allowed values: 'view' (Show the latest event(s) for all tracked matches. If matchID is supplied), 'viewNew' (Show those matches where new events have occured since last request of the page), 'viewAll' (Show all the events for all matches), 'clearAll' (Remove all tracked matches from the tracking session), 'addMatch' (Add a new match to be tracked), 'deleteMatch' (Remove a particular match from the session).

'view'
match_id Optional[int]

The globally unique matchID.

None
source_system str

Specifies which source system the match belongs to. Defaults to hattrick.

'hattrick'
include_starting_lineup bool

Should StartingLineup and Substitutions be included in the response? Defaults to false.

False
use_live_events_and_texts bool

Should the events and texts be as on the live page on the site? Defaults to false.

False
last_shown_indexes Optional[str]

JSON formatted array of last shown indexes for each match.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
Live

The parsed data from the live.xml file.

xml_manager_compendium

xml_manager_compendium(user_id=None, **kwargs)

Request the manager_compendium.xml file from the CHPP API.

Parameters:

Name Type Description Default
user_id Optional[int]

What user to show the data for. If None (the default), Hattrick uses the authenticated user's ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
ManagerCompendium

The parsed data from the manager_compendium.xml file.

xml_match_details

xml_match_details(
    match_id,
    source_system=None,
    match_events=None,
    **kwargs,
)

Request the match_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
match_id int

Which match to show details for.

required
source_system Optional[str]

Specifies which source system the match belongs to.

None
match_events Optional[bool]

Whether match events shall be shown or not. Allowed values: 'false' (Show no match events), 'true' (Show match events).

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
MatchDetails

The parsed data from the match_details.xml file.

xml_match_lineup

xml_match_lineup(
    match_id=None,
    team_id=None,
    source_system=None,
    **kwargs,
)

Request the match_lineup.xml file from the CHPP API.

Parameters:

Name Type Description Default
match_id Optional[int]

Specifies which particular match data is requested for. If None (the default), Hattrick uses the last match.

None
team_id Optional[int]

Specifies which of the two participating teams data should be shown for. If None (the default), Hattrick uses the authenticated user's team.

None
source_system Optional[str]

Specifies which source system the match belongs to. If None (the default), Hattrick uses Hattrick.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
MatchLineup

The parsed data from the match_lineup.xml file.

xml_match_orders

xml_match_orders(
    match_id,
    action_type="view",
    team_id=None,
    source_system="Hattrick",
    lineup=None,
    **kwargs,
)

Request the match_orders.xml file from the CHPP API.

Parameters:

Name Type Description Default
match_id int

Specifies which particular match data is requested for.

required
action_type str

Indicates what type of action the page should perform. Allowed values: 'view' (Returns data on the matchorder for the match requested), 'setmatchorder' (Sets a matchorder for the match specified. Requests to set matchorder), 'predictratings' (Predicts the sector and tactic ratings for the match specified).

'view'
team_id Optional[int]

Team ID to get/set orders for. Must refer to a senior or youth team managed by requesting user. If None (the default), Hattrick uses the authenticated user's primary team ID.

None
source_system str

Specifies which source system the match belongs to. Defaults to Hattrick.

'Hattrick'
lineup Optional[str]

JSON formatted match orders to set for the match specified or to predict ratings. Must be specified as request body for POST. Required for actionType=setmatchorder and optional for actionType=predictratings, otherwise not used.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
MatchOrdersView | MatchOrdersSetMatchOrder | MatchOrdersPredictRatings

The parsed data from the match_orders.xml file.

xml_matches

xml_matches(team_id=None, is_youth=None, **kwargs)

Request the matches.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

What team to show the matches for: Either teamID or youthTeamID depending on isYouth. If None (the default), Hattrick uses the authenticated user's senior or youth team ID.

None
is_youth Optional[bool]

Is request for youth or not. If None (the default), Hattrick uses false.

None
last_match_date

Last date to show matches to. If more than 50 matches are affected, only the 50 first will be returned. If None (the default), Hattrick uses Datetime.Now + 28 days.

required
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
Matches

The parsed data from the matches.xml file.

xml_matches_archive

xml_matches_archive(
    team_id=None,
    is_youth=None,
    first_match_date=None,
    last_match_date=None,
    season=None,
    include_hto=None,
    **kwargs,
)

Request the matches_archive.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

What team to show the matches for: Either teamID or youthTeamID depending on isYouth. If None (the default), Hattrick uses the authenticated user's senior or youth team ID.

None
is_youth Optional[bool]

Is request for youth or not. If None (the default), Hattrick uses false.

None
first_match_date Optional[datetime]

First date to show matches in archive from. If None (the default), Hattrick uses Datetime.Now - 3 months.

None
last_match_date Optional[datetime]

Last date to show matches to. For performance reasons, only an interval of 2 seasons back in time can be specified. If None (the default), Hattrick uses Datetime.Now - 1 day.

None
season Optional[int]

Season to show matches for. (Only valid for senior teams, not for youth!).

None
include_hto Optional[bool]

If HTO matches (tournaments, ladders, preparation, and single matches) should be included. If None (the default), Hattrick uses false.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
MatchesArchive

The parsed data from the matches_archive.xml file.

xml_national_players

xml_national_players(
    team_id,
    action_type="view",
    match_type_category=None,
    show_all=None,
    **kwargs,
)

Request the national_players.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id int

What national team type to list.

required
action_type str

Indicates what type of action the page should perform. Allowed values: 'view' (View the national team players of a specific type ('regular' or 'U-20')), 'SupporterStats' (View the number of matches that players have played in the national team).

'view'
match_type_category Optional[int]

What national team type to list ('NT' = all matches played in this National Team, 'WC' = World Cup matches played in this National Team). If None (the default), Hattrick uses NT.

None
show_all Optional[bool]

Whether to show all players (true) or a maximum of 20 players ordered by number of matches played (false). If None (the default), Hattrick uses false.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
NationalPlayersView | NationalPlayersStats

The parsed data from the national_players.xml file.

xml_national_prospect_players

xml_national_prospect_players(
    team_id, player_category_id=None, **kwargs
)

Request the national_prospect_players.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id int

The nationalTeamID to list prospect players for.

required
player_category_id Optional[int]

Only list the prospect players in this category. Use 0 for players with no category set. If None (the default), Hattrick uses All categories.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
NationalProspectPlayers

The parsed data from the national_prospect_players.xml file.

xml_national_team_details

xml_national_team_details(team_id, **kwargs)

Request the national_team_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id int

What national team type to list.

required
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
NationalTeamDetails

The parsed data from the national_team_details.xml file.

xml_national_team_matches

xml_national_team_matches(
    league_office_type_id=None, **kwargs
)

Request the national_team_matches.xml file from the CHPP API.

Parameters:

Name Type Description Default
league_office_type_id Optional[int]

What national team type to list (2 = National teams, 4 = U-20 Teams). If None (the default), Hattrick uses 2.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
NationalTeamMatches

The parsed data from the national_team_matches.xml file.

xml_national_teams

xml_national_teams(league_office_type_id=None, **kwargs)

Request the national_teams.xml file from the CHPP API.

Parameters:

Name Type Description Default
league_office_type_id Optional[int]

What national team type to list (2 = National teams, 4 = U-20 Teams). If None (the default), Hattrick uses 2.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
NationalTeams

The parsed data from the national_teams.xml file.

xml_player_details

xml_player_details(
    action_type=None,
    player_id=None,
    include_match_info=None,
    team_id=None,
    bid_amount=None,
    max_bid_amount=None,
    **kwargs,
)

Request the player_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
action_type Optional[str]

Indicates what type of action the page should perform. Allowed values: 'view' (Shows information for the player with the corresponding playerID), 'placeBid' (Places a bid on the player and then shows all the information, for Supporters).

None
player_id Optional[int]

The player to get information for.

None
include_match_info Optional[bool]

Set it to 'true' to get LastMatch Container. If None (the default), Hattrick uses false.

None
team_id Optional[int]

Team ID of the team placing the bid. Must refer to a senior team managed by requesting user.

None
bid_amount Optional[int]

Bid amount in SEK.

None
max_bid_amount Optional[int]

Maximum bid amount in SEK (autobid).

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
PlayerDetails

The parsed data from the player_details.xml file.

xml_player_events

xml_player_events(player_id=None, **kwargs)

Request the player_events.xml file from the CHPP API.

Parameters:

Name Type Description Default
player_id Optional[int]

The player to get information for.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
PlayerEvents

The parsed data from the player_events.xml file.

xml_player_stats

xml_player_stats(player_id=None, **kwargs)

Request the player_stats.xml file from the CHPP API.

Parameters:

Name Type Description Default
player_id Optional[int]

The player to get statistics for.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
PlayerStats

The parsed data from the player_stats.xml file.

xml_players

xml_players(
    action_type="view",
    order_by=None,
    team_id=None,
    include_match_info=None,
    **kwargs,
)

Request the players.xml file from the CHPP API.

Parameters:

Name Type Description Default
action_type str

Indicates what type of action the page should perform. Allowed values: 'view' (View the list of players belonging to a team), 'viewOldies' (View the list of players who no longer belong to the club but were promoted from the youth team), 'viewOldCoaches' (View list of former players that now are coaches).

'view'
order_by Optional[str]

The field that the outdata PlayerList should be sorted by. If None (the default), Hattrick uses PlayerNumber.

None
team_id Optional[int]

The team for which the data should apply to. If None (the default), Hattrick uses the authenticated user's team ID.

None
include_match_info Optional[bool]

Include LastMatch container for all players. If None (the default), Hattrick uses false.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
PlayersView | PlayersViewOldies | PlayersViewOldCoaches

The parsed data from the players.xml file.

xml_region_details

xml_region_details(region_id=None, **kwargs)

Request the region_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
region_id Optional[int]

The region to get information for.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
RegionDetails

The parsed data from the region_details.xml file.

xml_search(
    search_type=None,
    search_string=None,
    search_string_2=None,
    search_id=None,
    search_league_id=None,
    page_index=None,
    **kwargs,
)

Request the search.xml file from the CHPP API.

Parameters:

Name Type Description Default
search_type Optional[int]

Which type of search to perform. Allowed values: '0' (Search for players), '1' (Search for arenas), '2' (Search for managers), '3' (Search for series), '4' (Search for teams), '5' (Search for regions), '6' (Search for match).

None
search_string Optional[str]

The string to search for. Must be >= 3 characters long.

None
search_string_2 Optional[str]

The second string to search for. Must be >= 3 characters long.

None
search_id Optional[int]

The specific ID to search for.

None
search_league_id Optional[int]

The specific LeagueID to search in. -1 searches in ALL leagues. If None (the default), Hattrick uses the authenticated user's league ID.

None
page_index Optional[int]

The zerobased PageIndex to retrieve. Will only have effect when resultset has more than 25 rows.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
Search

The parsed data from the search.xml file.

xml_staff_avatars

xml_staff_avatars(team_id=None, **kwargs)

Request the staff_avatars.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

Team ID to get data for. If None (the default), Hattrick uses the authenticated user's primary team ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
StaffAvatars

The parsed data from the staff_avatars.xml file.

xml_staff_list

xml_staff_list(team_id=None, **kwargs)

Request the staff_list.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

Team ID to get data for. If None (the default), Hattrick uses the authenticated user's primary team ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
StaffList

The parsed data from the staff_list.xml file.

xml_supporters

xml_supporters(
    action_type="supportedteams",
    user_id=None,
    team_id=None,
    page_index=None,
    page_size=None,
    **kwargs,
)

Request the supporters.xml file from the CHPP API.

Parameters:

Name Type Description Default
action_type str

Indicates what type of action the page should perform. Allowed values: 'supportedteams' (See the teams the user support), 'mysupporters' (See the teams supporting the team).

'supportedteams'
user_id Optional[int]

User ID to get data for. If None (the default), Hattrick uses the authenticated user's ID.

None
team_id Optional[int]

Team ID to get data for. If None (the default), Hattrick uses the authenticated user's primary team ID.

None
page_index Optional[int]

Zero based pageindex to retrieve. If None (the default), Hattrick uses 0.

None
page_size Optional[int]

How many results to be shown in each page, the maximum value is 500.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
SupportersSupportedTeams | SupportersMySupporters

The parsed data from the supporters.xml file.

xml_team_details

xml_team_details(
    team_id=None,
    user_id=None,
    include_domestics_flags=None,
    include_flags=None,
    include_supporters=None,
    **kwargs,
)

Request the team_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

Which team/user to show data for. teamID and userID give the same result, except that ownerless teams can only be accessed if submitting a teamID and that users without a team can only be accessed if userID is submitted. If None (the default), Hattrick uses the authenticated user's senior team ID.

None
user_id Optional[int]

Which team/user to show data for. If neither user_id nor team_id is supplied, user_id defaults to the authenticated user's ID.

None
include_domestics_flags Optional[bool]

Whether or not the teams own country should be included in the flag collections (provided games against domestic opponents have been played). If None (the default), Hattrick uses false.

None
include_flags Optional[bool]

Whether or not the flag collection should be provided. If None (the default), Hattrick uses false.

None
include_supporters Optional[bool]

Whether or not the supported teams and the teams supporters should be included. If None (the default), Hattrick uses false.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
TeamDetails

The parsed data from the team_details.xml file.

xml_team_history

xml_team_history(team_id=None, **kwargs)

Request the team_history.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

The ID of the team to fetch the history for. If None (the default), Hattrick uses the authenticated user's primary team ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
TeamHistory

The parsed data from the team_history.xml file.

xml_tournament_details

xml_tournament_details(
    tournament_id, season=None, **kwargs
)

Request the tournament_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
tournament_id int

The ID for the tournament to get data for.

required
season Optional[int]

The season of the tournament.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
TournamentDetails

The parsed data from the tournament_details.xml file.

xml_tournament_fixtures

xml_tournament_fixtures(
    tournament_id, season=None, match_round=None, **kwargs
)

Request the tournament_fixtures.xml file from the CHPP API.

Parameters:

Name Type Description Default
tournament_id int

The ID for the tournament to get data for.

required
season Optional[int]

The starting season of the tournament. This is available only for National Teams cups.

None
match_round Optional[int]

Specific match round for this tournament. It will pick the last match round if the selected round is greater than the tournament's last round.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
TournamentFixtures

The parsed data from the tournament_fixtures.xml file.

xml_tournament_league_tables

xml_tournament_league_tables(
    tournament_id,
    season=None,
    world_cup_round=None,
    **kwargs,
)

Request the tournament_league_tables.xml file from the CHPP API.

Parameters:

Name Type Description Default
tournament_id int

The ID for the tournament to get data for.

required
season Optional[int]

The season of the tournament.

None
world_cup_round Optional[int]

Specifies which particular world cup stage data is requested for. Used only for World Cup tournaments. Otherwise, not used.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
TournamentLeagueTables

The parsed data from the tournament_league_tables.xml file.

xml_tournament_list

xml_tournament_list(team_id=None, **kwargs)

Request the tournament_list.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

Team ID to get data for. If None (the default), Hattrick uses the authenticated user's primary team ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
TournamentList

The parsed data from the tournament_list.xml file.

xml_training

xml_training(
    action_type="view",
    team_id=None,
    training_type=None,
    training_level=None,
    training_level_stamina=None,
    league_id=None,
    from_date=None,
    **kwargs,
)

Request the training.xml file from the CHPP API.

Parameters:

Name Type Description Default
action_type str

Indicates what type of action the page should perform. Allowed values: 'view' (Training information for the authenticated user's team), 'stats' (Shows the distribution among training types for all leagues or for a specific league), 'setTraining' (Set the training settings for the authenticated user's team. (Requires "set_training" scope)), 'history' (The training changes of a senior team since a given date. Requires Gold supporter).

'view'
team_id Optional[int]

Team ID to view training information for. Must refer to a senior team managed by requesting user. For actionType=history, it can also be a team the user mentors. If None (the default), Hattrick uses the authenticated user's primary team ID, except in action setTraining.

None
training_type Optional[int]

Type of training to be set for the specified team if action is setTraining.

None
training_level Optional[int]

Training level to be set for the specified team (0-100) if action is setTraining.

None
training_level_stamina Optional[int]

Stamina level to be set for the specified team (5-100) if action is setTraining.

None
league_id Optional[int]

What LeagueID to retrieve statistics for (empty for global stats in version 1.7 or above). If None (the default), Hattrick uses the authenticated user's league ID.

None
from_date Optional[datetime]

The date to start the training history from. A date before the first Hattrick season or in the future is moved to the nearest valid date. If None (the default), Hattrick uses 16 weeks before today.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
TrainingView | TrainingSetTraining | TrainingStats | TrainingHistoryView

The parsed data from the training.xml file.

xml_training_events

xml_training_events(player_id, **kwargs)

Request the training_events.xml file from the CHPP API.

Parameters:

Name Type Description Default
player_id int

What player to show training events for.

required
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
TrainingEvents

The parsed data from the training_events.xml file.

xml_transfer_search(
    age_min,
    age_max,
    skill_type_1,
    min_skill_value_1,
    max_skill_value_1,
    age_days_min=None,
    age_days_max=None,
    skill_type_2=None,
    min_skill_value_2=None,
    max_skill_value_2=None,
    skill_type_3=None,
    min_skill_value_3=None,
    max_skill_value_3=None,
    skill_type_4=None,
    min_skill_value_4=None,
    max_skill_value_4=None,
    specialty=None,
    native_country_id=None,
    tsi_min=None,
    tsi_max=None,
    price_min=None,
    price_max=None,
    salary_min=None,
    salary_max=None,
    transfer_compare_avg_min=None,
    transfer_compare_avg_max=None,
    page_size=None,
    page_index=None,
    **kwargs,
)

Request the transfer_search.xml file from the CHPP API.

Parameters:

Name Type Description Default
age_min int

Minimum age value (years) to search for.

required
age_max int

Maximum age value (years) to search for.

required
skill_type_1 int

Main skill to search for.

required
min_skill_value_1 int

Minimum value for the main skill (skillType1) to search for. The difference between min and max can be up to 4 levels. Set pieces, leadership and experience need a minimum level of 5 and keeper of 3.

required
max_skill_value_1 int

Maximum value for the main skill (skillType1) to search for. The difference between min and max can be up to 4 levels.

required
age_days_min Optional[int]

Minimum age value (days) to search for. If None (the default), Hattrick uses 0.

None
age_days_max Optional[int]

Maximum age value (days) to search for. If None (the default), Hattrick uses 111.

None
skill_type_2 Optional[int]

Secondary skill to search for. If None (the default), Hattrick uses 'Not specified'.

None
min_skill_value_2 Optional[int]

Minimum value for the secondary skill (skillType2) to search for. If None (the default), Hattrick uses 'Not specified'.

None
max_skill_value_2 Optional[int]

Maximum value for the secondary skill (skillType2) to search for. If None (the default), Hattrick uses 'Not specified'.

None
skill_type_3 Optional[int]

Secondary skill to search for. If None (the default), Hattrick uses 'Not specified'.

None
min_skill_value_3 Optional[int]

Minimum value for the secondary skill (skillType3) to search for. If None (the default), Hattrick uses 'Not specified'.

None
max_skill_value_3 Optional[int]

Maximum value for the secondary skill (skillType3) to search for. If None (the default), Hattrick uses 'Not specified'.

None
skill_type_4 Optional[int]

Secondary skill to search for. If None (the default), Hattrick uses 'Not specified'.

None
min_skill_value_4 Optional[int]

Minimum value for the secondary skill (skillType4) to search for. If None (the default), Hattrick uses 'Not specified'.

None
max_skill_value_4 Optional[int]

Maximum value for the secondary skill (skillType4) to search for. If None (the default), Hattrick uses 'Not specified'.

None
specialty Optional[int]

The specialty of the players to search for. If None (the default), Hattrick uses 'Not specified'.

None
native_country_id Optional[int]

CountryID where the players to search for where born. If None (the default), Hattrick uses Not specified.

None
tsi_min Optional[int]

Minimum TSI value to search for. If None (the default), Hattrick uses 'Not specified'.

None
tsi_max Optional[int]

Maximum TSI value to search for. If None (the default), Hattrick uses 'Not specified'.

None
price_min Optional[int]

Minimum price to search for. If None (the default), Hattrick uses 'Not specified'.

None
price_max Optional[int]

Maximum price to search for. If None (the default), Hattrick uses 'Not specified'.

None
salary_min Optional[int]

Minimum weekly salary to search for. It is the player's base salary, without the extra 20% for foreign players, the same value as Salary in the results. If None (the default), Hattrick uses 'Not specified'.

None
salary_max Optional[int]

Maximum weekly salary to search for. It is the player's base salary, without the extra 20% for foreign players, the same value as Salary in the results. If None (the default), Hattrick uses 'Not specified'.

None
transfer_compare_avg_min Optional[int]

Minimum transfer estimate to search for. It is the estimate saved when the player was put on the market. Players without an estimate are left out when this is set. If None (the default), Hattrick uses 'Not specified'.

None
transfer_compare_avg_max Optional[int]

Maximum transfer estimate to search for. It is the estimate saved when the player was put on the market. Players without an estimate are included. If None (the default), Hattrick uses 'Not specified'.

None
page_size Optional[int]

How many results to be shown in each page, the maximum value is 100. If None (the default), Hattrick uses 25.

None
page_index Optional[int]

What page to be shown, starts from 0. If None (the default), Hattrick uses 0.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
TransferSearch

The parsed data from the transfer_search.xml file.

xml_transfers_player

xml_transfers_player(player_id, **kwargs)

Request the transfers_player.xml file from the CHPP API.

Parameters:

Name Type Description Default
player_id int

The player to get the transfers for.

required
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
TransfersPlayer

The parsed data from the transfers_player.xml file.

xml_transfers_team

xml_transfers_team(team_id=None, page_index=None, **kwargs)

Request the transfers_team.xml file from the CHPP API.

Parameters:

Name Type Description Default
team_id Optional[int]

What team to show the transfers for. If None (the default), Hattrick uses the authenticated user's team ID.

None
page_index Optional[int]

What page in the list to retrieve. Each page consists of 25 records unless last page which may contain 25 or less. To get the last page, specify 0. Defaults to 1.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
TransfersTeam

The parsed data from the transfers_team.xml file.

xml_translations

xml_translations(language_id=None, **kwargs)

Request the translations.xml file from the CHPP API.

Parameters:

Name Type Description Default
language_id Optional[int]

The ID of the language to get the translations for.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
Translations

The parsed data from the translations.xml file.

xml_world_cup

xml_world_cup(
    action_type="viewMatches",
    cup_id=None,
    season=None,
    match_round=None,
    cup_series_unit_id=None,
    **kwargs,
)

Request the world_cup.xml file from the CHPP API.

Parameters:

Name Type Description Default
action_type str

Indicates what type of action the page should perform. Allowed values: 'viewMatches' (View a list of the matches of a particular group), 'viewGroups' (View a list of the groups (with points, place, etc.) of a particular round, season).

'viewMatches'
cup_id Optional[int]

The globally unique cupID. If None (the default), Hattrick uses 137 (the World Cup).

None
season Optional[int]

The starting season of the cup.

None
match_round Optional[int]

A key that indicates a certain round (typically 10 weeks or 9 days). Qualifications are always matchRound 1. If None (the default), Hattrick uses the last initialized round of the chosen cup.

None
cup_series_unit_id Optional[int]

The globally unique identifier of the CupSeriesUnit (a 'group' of 4-6 teams).

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
WorldCupViewMatches | WorldCupViewGroups

The parsed data from the world_cup.xml file.

xml_world_details

xml_world_details(
    league_id=None,
    country_id=None,
    include_regions=None,
    **kwargs,
)

Request the world_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
league_id Optional[int]

The leagueID to get information for.

None
country_id Optional[int]

The countryID to get information for.

None
include_regions Optional[bool]

Indicates if regions should be shown or not.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
WorldDetails

The parsed data from the world_details.xml file.

xml_world_languages

xml_world_languages(**kwargs)

Request the world_languages.xml file from the CHPP API.

Parameters:

Name Type Description Default
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
WorldLanguages

The parsed data from the world_languages.xml file.

xml_youth_avatars

xml_youth_avatars(youth_team_id=None, **kwargs)

Request the youth_avatars.xml file from the CHPP API.

Parameters:

Name Type Description Default
youth_team_id Optional[int]

Youth team ID to get data for. Must refer to a youth team managed by requesting user. If None (the default), Hattrick uses the authenticated user's primary youth team ID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
YouthAvatars

The parsed data from the youth_avatars.xml file.

xml_youth_league_details

xml_youth_league_details(youth_league_id=None, **kwargs)

Request the youth_league_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
youth_league_id Optional[int]

Specifies the 'series' (league) to look for data on. If None (the default), Hattrick uses LeagueID of the youth team of the authenticated user's primary club.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
YouthLeagueDetails

The parsed data from the youth_league_details.xml file.

xml_youth_league_fixtures

xml_youth_league_fixtures(
    youth_league_id=None, season=None, **kwargs
)

Request the youth_league_fixtures.xml file from the CHPP API.

Parameters:

Name Type Description Default
youth_league_id Optional[int]

Specifies the 'series' (league) to look for data on. If None (the default), Hattrick uses LeagueID of the youth team of the authenticated user's primary club.

None
season Optional[int]

The season number for the league. If None (the default), Hattrick uses the current season for the YouthLeagueID.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
YouthLeagueFixtures

The parsed data from the youth_league_fixtures.xml file.

xml_youth_player_details

xml_youth_player_details(
    action_type=None,
    youth_player_id=None,
    show_scout_call=None,
    show_last_match=None,
    **kwargs,
)

Request the youth_player_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
action_type Optional[str]

Indicates what type of action the page should perform. Allowed values: 'details' (Show the player information), 'unlockskills' (Unlock the skills of the player before showing the player information).

None
youth_player_id Optional[int]

The player to get information for.

None
show_scout_call Optional[bool]

Set it to 'true' to get the information the scout provided when the player was scouted. If None (the default), Hattrick uses false.

None
show_last_match Optional[bool]

Set it to 'true' to get LastMatch container. If None (the default), Hattrick uses false.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
YouthPlayerDetails

The parsed data from the youth_player_details.xml file.

xml_youth_player_list

xml_youth_player_list(
    action_type="list",
    order_by=None,
    youth_team_id=None,
    show_scout_call=None,
    show_last_match=None,
    **kwargs,
)

Request the youth_player_list.xml file from the CHPP API.

Parameters:

Name Type Description Default
action_type str

Indicates what type of action the page should perform. Allowed values: 'list' (List the players, containing only PlayerID and Name-containers), 'details' (Show detailed players information), 'unlockskills' (Unlock the skills of the entire team before showing the players information).

'list'
order_by Optional[str]

The field that the outdata PlayerList should be sorted by. If None (the default), Hattrick uses PlayerNumber.

None
youth_team_id Optional[int]

The youth team for which the data should apply to. If None (the default), Hattrick uses the authenticated user's youth team ID.

None
show_scout_call Optional[bool]

Set it to 'true' to get the information the scout provided when the player was scouted. Only available if actionType=details or actionType=unlockskills. If None (the default), Hattrick uses false.

None
show_last_match Optional[bool]

Set it to 'true' to get LastMatch container. Only available if actionType=details or actionType=unlockskills. If None (the default), Hattrick uses false.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
YouthPlayerListList | YouthPlayerListDetails

The parsed data from the youth_player_list.xml file.

xml_youth_team_details

xml_youth_team_details(
    youth_team_id=None, show_scouts=None, **kwargs
)

Request the youth_team_details.xml file from the CHPP API.

Parameters:

Name Type Description Default
youth_team_id Optional[int]

Which team/user to show data for. If None (the default), Hattrick uses the authenticated user's youth team ID.

None
show_scouts Optional[bool]

Set it to 'true' to get ScoutList container. If None (the default), Hattrick uses false.

None
**kwargs Any

Additional keyword arguments forwarded to the model class.

{}

Returns:

Type Description
YouthTeamDetails

The parsed data from the youth_team_details.xml file.

HTXml

Gather the different methods used to parse the xml files fetched on Hattrick.

ht_bool staticmethod

ht_bool(data, attrib=None)

Return the text of an xml element as a bool.

Parameters:

Name Type Description Default
data Optional[Element]

Xml element to read.

required
attrib Optional[str]

Name of the attribute to read instead of the text.

None

ht_date_to_text staticmethod

ht_date_to_text(_datetime)

Convert a datetime object to a date string.

Parameters:

Name Type Description Default
_datetime

A datetime or HTDatetime object.

required

Returns:

Type Description

A string representing a date, e.g. "2006-02-23".

ht_datetime_from_text staticmethod

ht_datetime_from_text(data, attrib=None)

Convert a string from xml data to a HTDatetime object.

Parameters:

Name Type Description Default
data Optional[Element]

Xml data representing a date and a time.

required
attrib Optional[str]

Name of the attribute to fetch instead of the text.

None

Returns:

Type Description

A HTDatetime object.

ht_datetime_to_text staticmethod

ht_datetime_to_text(_datetime)

Convert a datetime object to a string.

Parameters:

Name Type Description Default
_datetime

A datetime or HTDatetime object.

required

Returns:

Type Description

A string representing a date and a time, e.g. "2006-02-23 20:00:00".

ht_float staticmethod

ht_float(data, attrib=None)

Return the text of an xml element as a float (comma replaced by dot).

Parameters:

Name Type Description Default
data Optional[Element]

Xml element to read.

required
attrib Optional[str]

Name of the attribute to read instead of the text.

None

ht_goals staticmethod

ht_goals(data)

Parse the goals of a match xml node.

Parameters:

Name Type Description Default
data

Xml node containing the Goal elements.

required

Returns:

Type Description

A list of dicts describing each goal.

ht_int staticmethod

ht_int(data, attrib=None)

Return the text of an xml element as an int ('Not available' becomes None).

Parameters:

Name Type Description Default
data Optional[Element]

Xml element to read.

required
attrib Optional[str]

Name of the attribute to read instead of the text.

None

ht_match_events staticmethod

ht_match_events(data)

Parse the events of a match xml node.

Parameters:

Name Type Description Default
data

Xml node containing the Event elements.

required

Returns:

Type Description

A list of dicts describing each event.

ht_str staticmethod

ht_str(data, attrib=None)

Return the text of an xml element, or one of its attributes, as a string.

Parameters:

Name Type Description Default
data Optional[Element]

Xml element to read.

required
attrib Optional[str]

Name of the attribute to read instead of the text.

None

ht_str_items staticmethod

ht_str_items(data, item_tag)

Return the texts of all the children of an xml element with the given tag.

Parameters:

Name Type Description Default
data Element

Xml element to read.

required
item_tag str

Tag of the children to read.

required

iter_data_items staticmethod

iter_data_items(data, item_tag)

Iterate over the children of an xml element with the given tag.

Parameters:

Name Type Description Default
data

Xml element to read.

required
item_tag

Tag of the children to iterate over.

required

Yields:

Type Description

The matching child elements.

opt_ht_datetime_from_text staticmethod

opt_ht_datetime_from_text(data, attrib=None)

Convert a string from xml data to a HTDatetime object, or None if empty.

Parameters:

Name Type Description Default
data Optional[Element]

Xml data representing a date and a time.

required
attrib Optional[str]

Name of the attribute to fetch instead of the text.

None

Returns:

Type Description

A HTDatetime object, or None if the data is empty or cannot be parsed.

to_string staticmethod

to_string(data)

Serialize an xml element to a string.

Parameters:

Name Type Description Default
data

Xml element to serialize.

required