User¶
Information for the User
is taken from the following endpoint:
An example of what information a User
contains is shown below:
{
"entry": {
"id": 3808385,
"player_first_name": "Amos",
"player_last_name": "Bastian",
"player_region_id": 152,
"player_region_name": "Netherlands",
"player_region_short_iso": "NL",
"summary_overall_points": 1404,
"summary_overall_rank": 49225,
"summary_event_points": 65,
"summary_event_rank": 1480275,
"joined_seconds": 18267,
"current_event": 23,
"total_transfers": 21,
"total_loans": 0,
"total_loans_active": 0,
"transfers_or_loans": "transfers",
"deleted": false,
"email": false,
"joined_time": "2018-08-09T22:44:21Z",
"name": "( \u0361\u00b0 \u035c\u0296 \u0361\u00b0)",
"bank": 22,
"value": 1037,
"kit": "{\"kit_shirt_type\":\"plain\",\"kit_shirt_base\":\"#ff0000\",\"kit_shirt_sleeves\":\"#ff0000\",\"kit_shirt_secondary\":\"#e1e1e1\",\"kit_shirt_logo\":\"none\",\"kit_shorts\":\"#000000\",\"kit_socks_type\":\"plain\",\"kit_socks_base\":\"#ffffff\",\"kit_socks_secondary\":\"#e1e1e1\"}",
"event_transfers": 0,
"event_transfers_cost": 0,
"extra_free_transfers": 0,
"strategy": null,
"favourite_team": 14,
"started_event": 1,
"player": 7425806
},
"leagues": {
"cup": [
],
"h2h": [
],
"classic": [
{
"id": 14,
"entry_rank": 8454,
"entry_last_rank": 7255,
"entry_movement": "down",
"entry_change": 1199,
"entry_can_leave": false,
"entry_can_admin": false,
"entry_can_invite": false,
"entry_can_forum": false,
"entry_code": null,
"name": "Man Utd",
"short_name": "team-14",
"created": "2018-07-05T12:12:23Z",
"closed": false,
"forum_disabled": false,
"make_code_public": false,
"rank": null,
"size": null,
"league_type": "s",
"_scoring": "c",
"reprocess_standings": false,
"admin_entry": null,
"start_event": 1
},
...,
{
"id": 890172,
"entry_rank": 2,
"entry_last_rank": 2,
"entry_movement": "same",
"entry_change": null,
"entry_can_leave": true,
"entry_can_admin": false,
"entry_can_invite": false,
"entry_can_forum": true,
"entry_code": null,
"name": "AJ's Angels",
"short_name": null,
"created": "2018-08-10T08:15:37Z",
"closed": false,
"forum_disabled": false,
"make_code_public": false,
"rank": null,
"size": null,
"league_type": "x",
"_scoring": "c",
"reprocess_standings": false,
"admin_entry": 9346,
"start_event": 1
}
]
}
}
-
class
fpl.models.user.
User
(user_information, session)[source]¶ A class representing a user of the Fantasy Premier League.
Basic usage:
from fpl import FPL import aiohttp import asyncio async def main(): async with aiohttp.ClientSession() as session: fpl = FPL(session) user = await fpl.get_user(3808385) print(user) ... # Python 3.7+ asyncio.run(main()) ... # Python 3.6 loop = asyncio.get_event_loop() loop.run_until_complete(main()) Amos Bastian - Netherlands
-
captain
(captain)[source]¶ Set the captain of the user’s team.
Parameters: captain (int) – ID of the captain.
-
get_active_chips
(gameweek=None)[source]¶ Returns a list containing the user’s active chip for each gameweek, or the active chip of the given gameweek.
- Information is taken from e.g.:
- https://fantasy.premierleague.com/api/entry/91928/event/1/picks/
Parameters: gameweek – (optional): The gameweek. Defaults to None
.Return type: list
-
get_automatic_substitutions
(gameweek=None)[source]¶ Returns a list containing the user’s automatic substitutions each gameweek.
- Information is taken from e.g.:
- https://fantasy.premierleague.com/api/entry/91928/event/1/picks/
Parameters: gameweek – (optional): The gameweek. Defaults to None
.Return type: list
-
get_chips
()[source]¶ Returns a logged in user’s list of chips. Requires the user to have logged in using
fpl.login()
.- Information is taken from e.g.:
- https://fantasy.premierleague.com/api/my-team/91928/
Return type: list
-
get_chips_history
(gameweek=None)[source]¶ Returns a list containing the chip history of the user.
- Information is taken from e.g.:
- https://fantasy.premierleague.com/api/entry/91928/history
Parameters: gameweek – (optional): The gameweek. Defaults to None
.Return type: list
-
get_cup_matches
(gameweek=None)[source]¶ Returns either a list of all the user’s cup matches, dictionary of the cup match in the given gameweek (gameweek 17 and onwards).
- Information is taken from e.g.:
- https://fantasy.premierleague.com/api/entry/91928/cup/
Parameters: gameweek – (optional): The gameweek. Defaults to None
.Return type: list or dict
-
get_cup_status
()[source]¶ Returns the user’s cup status.
- Information is taken from e.g.:
- https://fantasy.premierleague.com/api/entry/91928/cup/
Return type: dict
-
get_gameweek_history
(gameweek=None)[source]¶ Returns a list containing the gameweek history of the user.
- Information is taken from e.g.:
- https://fantasy.premierleague.com/api/entry/91928/history
Parameters: gameweek – (optional): The gameweek. Defaults to None
.Return type: list if gameweek is None
, otherwise dict.
-
get_latest_transfers
()[source]¶ Returns a list of transfers made by the user in the current gameweek. Requires the user to have logged in using
fpl.login()
.- Information is taken from e.g.:
- https://fantasy.premierleague.com/api/entry/91928/transfers-latest/
Return type: list
-
get_picks
(gameweek=None)[source]¶ Returns a dict containing the user’s picks each gameweek.
Key is the gameweek number, value contains picks of the gameweek.
- Information is taken from e.g.:
- https://fantasy.premierleague.com/api/entry/91928/event/1/picks/
Parameters: gameweek – (optional): The gameweek. Defaults to None
.Return type: dict
-
get_season_history
()[source]¶ Returns a list containing the seasonal history of the user.
- Information is taken from e.g.:
- https://fantasy.premierleague.com/api/entry/91928/history
Return type: list
-
get_team
()[source]¶ Returns a logged in user’s current team. Requires the user to have logged in using
fpl.login()
.- Information is taken from e.g.:
- https://fantasy.premierleague.com/api/my-team/91928/
Return type: list
-
get_transfers
(gameweek=None)[source]¶ Returns either a list of all the user’s transfers, or a list of transfers made in the given gameweek.
- Information is taken from e.g.:
- https://fantasy.premierleague.com/api/entry/91928/transfers/
Parameters: gameweek – (optional): The gameweek. Defaults to None
.Return type: list
-
get_transfers_status
()[source]¶ Returns a logged in user’s transfer status, which is a dictionary containing their bank value, how many free transfers they have left and so on. Requires the user to have logged in using
fpl.login()
.- Information is taken from e.g.:
- https://fantasy.premierleague.com/api/my-team/91928/
Return type: dict
-
get_user_history
(gameweek=None)[source]¶ Returns a list containing the user’s history for each gameweek, or a dictionary of the user’s history for the given gameweek.
Return type: list or dict
-
get_watchlist
()[source]¶ Returns the user’s watchlist. Requires the user to have logged in using
fpl.login()
.- Information is taken from here:
- https://fantasy.premierleague.com/api/me/
Return type: list
-
substitute
(players_in, players_out, captain=None, vice_captain=None)[source]¶ Substitute players on the bench for players in the starting eleven. Also allows the user to simultaneously set the new (vice) captain(s). A maximum of 4 substitutes is set to force proper usage.
Parameters: - players_in (list) – List of IDs of players who will be substituted in.
- players_out (list) – List of IDS of players who will be substituted out.
- captain – ID of the captain, defaults to None.
- captain – int, optional
- vice_captain – ID of the vice captain, defaults to None.
- vice_captain – int, optional
-
transfer
(players_out, players_in, max_hit=60, wildcard=False, free_hit=False)[source]¶ Transfers given players out and transfers given players in.
Parameters: - players_out (list) – List of IDs of players who will be transferred out.
- players_in (list) – List of IDs of players who will be transferred in.
- max_hit – Maximum hit that should be taken by making the transfer(s), defaults to 60
- max_hit – int, optional
- wildcard – Boolean for playing wildcard, defaults to False
- wildcard – bool, optional
- free_hit – Boolean for playing free hit, defaults to False
- free_hit – bool, optional
Returns: Returns the response given by a succesful transfer.
Return type: dict
-