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 to DEFAULT_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

Iterable[str]

Returns

Collection of invalid keys.

Raises
async get_achievements_resource()

Gets the current achievements for the Hypixel Network.

Return type

Achievements

Returns

A Achievements object containing the requested achievements.

Raises
async get_all_skyblock_auctions()
Return type

SkyblockAuctionsIterator

async get_all_skyblock_auctions_page(index)
Return type

List[SkyblockAuction]

async get_boosters()

Gets a tuple of Booster objects denoting the currently active boosters on the Hypixel Network.

Return type

Tuple[List[Booster], dict]

Returns

A list containing the currently active boosters as well as the boosters state.

Raises
async get_challenges_resource()

Gets the current challenges for the Hypixel Network.

Return type

Challenges

Returns

A Challenges object containing the requested challenges.

Raises
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

List[Friend]

Returns

A list of friends the given player has.

Raises
async get_friends_by_name(name)
Return type

List[Friend]

async get_friends_by_uuid(uuid)
Return type

List[Friend]

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

Optional[Guild]

Returns

The requested guild or None if not found.

Raises
async get_guild_achievements_resource()

Gets the current guild achievements for the Hypixel Network.

Return type

GuildAchievements

Returns

A GuildAchievements object containing the requested guild achievements.

Raises
async get_guild_by_id(guild_id)
Return type

Optional[Guild]

async get_guild_by_name(name)
Return type

Optional[Guild]

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

Optional[Guild]

Returns

The requested guild or None if not found.

Raises
async get_guild_by_player_name(name)
Return type

Optional[Guild]

async get_guild_by_player_uuid(uuid)
Return type

Optional[Guild]

async get_guild_id(query)
Return type

Optional[str]

async get_guild_permissions_resource()

Gets the current guild permissions for the Hypixel Network.

Return type

GuildPermissions

Returns

A GuildPermissions object containing the requested guild permissions.

Raises
async get_key(key)

Gets a Key object from the passed query.

Parameters

key (Union[UUID, str]) – The key to get.

Return type

Key

Returns

The requested key.

Raises
async get_leaderboards()

Gets the current state of the leaderboards on the Hypixel Network.

Return type

Leaderboards

Returns

A Leaderboards object containing the requested leaderboards.

Raises
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

Optional[Player]

Returns

The requested player data or None if the player wasn’t found.

Raises
async get_player_by_name(name)
Return type

Optional[Player]

async get_player_by_uuid(uuid)
Return type

Optional[Player]

async get_player_count()
Return type

int

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

Optional[PlayerInfo]

Returns

The requested player info or None if the player wasn’t found.

Raises
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

Optional[PlayerStats]

Returns

The requested player stats or None if the player wasn’t found.

Raises
async get_quests_resource()

Gets the current quests for the Hypixel Network.

Return type

Quests

Returns

A Quests object containing the requested quests.

Raises
async get_skyblock_auction(uuid)
Return type

SkyblockAuction

async get_skyblock_collections_resource()

Gets the latest Skyblock collections on the Hypixel Network.

Return type

SkyblockCollections

Returns

A SkyblockCollections object containing the requested Skyblock collections.

Raises
async get_skyblock_news()
Return type

List[SkyblockNews]

async get_skyblock_player_auctions_by_uuid(uuid)
Return type

List[SkyblockAuction]

async get_skyblock_profile()
Return type

SkyblockProfile

async get_skyblock_profile_auctions(uuid)
Return type

List[SkyblockAuction]

async get_skyblock_skills_resource()
Return type

SkyblockSkills

async get_watchdog_stats()

Gets the current WatchDog stats.

Return type

WatchdogStats

Returns

The current Watchdog stats.

Raises
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.

Parameters

query (str) – The username you want to lookup the UUID of.

Return type

str

Returns

The player’s UUID.

Raises

aiohttp.ClientResponseError – In case something goes wrong with the request.

async uuid_to_name(query)

Gets the name for the player with the given UUID. Uses the Mojang API for that.

Parameters

query (str) – The player UUID to get the name of.

Return type

str

Returns

The player’s name.

Raises

aiohttp.ClientResponseError – In case something goes wrong with the request.

Inheritance Diagram

Inheritance diagram of aiohypixel.session