aiohypixel.session¶
Documentation¶
This defines a connection to the Hypixel API. All requests will pass through here and this will handle everything for you
-
class
aiohypixel.session.
HypixelSession
(api_keys, *, api_url=None, max_key_wait_time=10, loop=None)¶ Represents a connection to the Hypixel API. You can perform a check on your API keys with the
check_keys()
method.- Parameters
api_keys (
Iterable
[str
]) – The collection of API keys to use for making requests.api_url (
Optional
[str
]) – The base API URL to use. Defaults toDEFAULT_BASE_API_URL
.max_key_wait_time (
Union
[int
,float
]) – The maximum time in seconds the requester will wait for an available key. After that, :exc:asyncio.TimeoutError is raised. Defaults to 10.loop (
Optional
[AbstractEventLoop
]) – The event loop to use for any asynchronous task.
-
DEFAULT_BASE_API_URL
= 'https://api.hypixel.net/'¶ This is the base URL for all the requests regarding the Hypixel API. Also see
BASIC_API_URL
.
-
property
api_keys
¶ Set of all available keys in the pool.
-
api_url
¶ Base API URL to use
-
async
check_keys
(keys)¶ Validates the given keys by using the ‘/key’ endpoint, wrapped by
get_key()
.- Parameters
keys (
Union
[str
,Iterable
[str
]]) – Collection of keys to check.- Return type
- Returns
Collection of invalid keys.
- Raises
HypixelAPIError – In case the API didn’t give an OK response.
UnsuccessfulRequest – If the API rejected the request for some unkonwn reason.
-
async
get_achievements_resource
()¶ Gets the current achievements for the Hypixel Network.
- Return type
- Returns
A
Achievements
object containing the requested achievements.- Raises
InvalidAPIKey – If the used API key isn’t valid.
HypixelAPIError – In case the API didn’t give an OK response.
UnsuccessfulRequest – If the API rejected the request for some unkonwn reason.
-
async
get_all_skyblock_auctions
()¶ - Return type
-
async
get_all_skyblock_auctions_page
(index)¶ - Return type
-
async
get_boosters
()¶ Gets a tuple of Booster objects denoting the currently active boosters on the Hypixel Network.
- Return type
- Returns
A list containing the currently active boosters as well as the boosters state.
- Raises
InvalidAPIKey – If the used API key isn’t valid.
HypixelAPIError – In case the API didn’t give an OK response.
UnsuccessfulRequest – If the API rejected the request for some unkonwn reason.
-
async
get_challenges_resource
()¶ Gets the current challenges for the Hypixel Network.
- Return type
- Returns
A
Challenges
object containing the requested challenges.- Raises
InvalidAPIKey – If the used API key isn’t valid.
HypixelAPIError – In case the API didn’t give an OK response.
UnsuccessfulRequest – If the API rejected the request for some unkonwn reason.
-
async
get_friends
(query)¶ Gets a tuple of Friend objects that the player with the given name/UUID has.
- Parameters
query (
Union
[str
,UUID
]) – Either the UUID or the username of the player you want to get the friends for.- Return type
- Returns
A list of friends the given player has.
- Raises
InvalidAPIKey – If the used API key isn’t valid.
HypixelAPIError – In case the API didn’t give an OK response.
UnsuccessfulRequest – If the API rejected the request for some unkonwn reason.
-
async
get_guild
(query)¶ Gets a guild object from the given query.
- Parameters
query (
str
) – Either the ID or name of the guild you want to get.- Return type
- Returns
The requested guild or None if not found.
- Raises
InvalidAPIKey – If the used API key isn’t valid.
HypixelAPIError – In case the API didn’t give an OK response.
UnsuccessfulRequest – If the API rejected the request for some unkonwn reason.
-
async
get_guild_achievements_resource
()¶ Gets the current guild achievements for the Hypixel Network.
- Return type
- Returns
A
GuildAchievements
object containing the requested guild achievements.- Raises
InvalidAPIKey – If the used API key isn’t valid.
HypixelAPIError – In case the API didn’t give an OK response.
UnsuccessfulRequest – If the API rejected the request for some unkonwn reason.
-
async
get_guild_by_player
(query)¶ Gets a guild object to which the player with the given name/UUID belongs to.
- Parameters
query (
Union
[str
,UUID
]) – Either the ID or name of the player you want to get guild for.- Return type
- Returns
The requested guild or None if not found.
- Raises
InvalidAPIKey – If the used API key isn’t valid.
HypixelAPIError – In case the API didn’t give an OK response.
UnsuccessfulRequest – If the API rejected the request for some unkonwn reason.
-
async
get_guild_permissions_resource
()¶ Gets the current guild permissions for the Hypixel Network.
- Return type
- Returns
A
GuildPermissions
object containing the requested guild permissions.- Raises
InvalidAPIKey – If the used API key isn’t valid.
HypixelAPIError – In case the API didn’t give an OK response.
UnsuccessfulRequest – If the API rejected the request for some unkonwn reason.
-
async
get_key
(key)¶ Gets a Key object from the passed query.
- Parameters
- Return type
- Returns
The requested key.
- Raises
InvalidAPIKey – If the requested key does not exist.
HypixelAPIError – In case the API didn’t give an OK response.
UnsuccessfulRequest – If the API rejected the request for some unkonwn reason.
-
async
get_leaderboards
()¶ Gets the current state of the leaderboards on the Hypixel Network.
- Return type
- Returns
A
Leaderboards
object containing the requested leaderboards.- Raises
InvalidAPIKey – If the used API key isn’t valid.
HypixelAPIError – In case the API didn’t give an OK response.
UnsuccessfulRequest – If the API rejected the request for some unkonwn reason.
-
async
get_player
(query)¶ Gets a full player object (general info + game stats) with the given query.
- Parameters
query (
Union
[str
,UUID
]) – Either the UUID or username of the player you want to get.- Return type
- Returns
The requested player data or None if the player wasn’t found.
- Raises
InvalidAPIKey – If the used API key isn’t valid.
HypixelAPIError – In case the API didn’t give an OK response.
UnsuccessfulRequest – If the API rejected the request for some unkonwn reason.
-
async
get_player_info
(query)¶ Gets a player object with just the network info that does not relate to any stats.
- Parameters
query (
str
) – Either the UUID or username of the player you want to get info for.- Return type
- Returns
The requested player info or None if the player wasn’t found.
- Raises
InvalidAPIKey – If the used API key isn’t valid.
HypixelAPIError – In case the API didn’t give an OK response.
UnsuccessfulRequest – If the API rejected the request for some unkonwn reason.
-
async
get_player_stats
(query)¶ Gets a player’s stats with the given query.
- Parameters
query (
str
) – Either the UUID or username of the player you want to get the stats for.- Return type
- Returns
The requested player stats or None if the player wasn’t found.
- Raises
InvalidAPIKey – If the used API key isn’t valid.
HypixelAPIError – In case the API didn’t give an OK response.
UnsuccessfulRequest – If the API rejected the request for some unkonwn reason.
-
async
get_quests_resource
()¶ Gets the current quests for the Hypixel Network.
- Return type
- Returns
A
Quests
object containing the requested quests.- Raises
InvalidAPIKey – If the used API key isn’t valid.
HypixelAPIError – In case the API didn’t give an OK response.
UnsuccessfulRequest – If the API rejected the request for some unkonwn reason.
-
async
get_skyblock_auction
(uuid)¶ - Return type
-
async
get_skyblock_collections_resource
()¶ Gets the latest Skyblock collections on the Hypixel Network.
- Return type
- Returns
A
SkyblockCollections
object containing the requested Skyblock collections.- Raises
InvalidAPIKey – If the used API key isn’t valid.
HypixelAPIError – In case the API didn’t give an OK response.
UnsuccessfulRequest – If the API rejected the request for some unkonwn reason.
-
async
get_skyblock_news
()¶ - Return type
-
async
get_skyblock_player_auctions_by_uuid
(uuid)¶ - Return type
-
async
get_skyblock_profile
()¶ - Return type
-
async
get_skyblock_profile_auctions
(uuid)¶ - Return type
-
async
get_skyblock_skills_resource
()¶ - Return type
-
async
get_watchdog_stats
()¶ Gets the current WatchDog stats.
- Return type
- Returns
The current Watchdog stats.
- Raises
InvalidAPIKey – If the used API key isn’t valid.
HypixelAPIError – In case the API didn’t give an OK response.
UnsuccessfulRequest – If the API rejected the request for some unkonwn reason.
-
http_client
¶ Client to use for making requests to the API.
-
logger
¶ Client logger.
-
loop
¶ Event loop to use for any asynchronous process.
-
max_key_wait_time
¶ Maximum time (in seconds) allowed for the requester to wait for an available key before raising an error.
-
async
name_to_uuid
(query)¶ Gets the UUID for the player with the given name. Uses the Mojang API.