API Reference¶
This module implements a variety of classes used to hold the data parsed from Tibia.com.
These objects are generally obtained from their respective from_content
methods.
It is possible to create and edit these objects as desired, but it may lead to unexpected behaviour if not done properly.
Client¶
-
class
tibiapy.
Client
(loop=None, session=None, *, proxy_url=None)[source]¶ An asynchronous client that fetches information from Tibia.com
The client uses a
aiohttp.ClientSession
to request the information. A single session is shared across all operations.If desired, a custom ClientSession instance may be passed, instead of creating a new one.
New in version 2.0.0.
-
loop
¶ asyncio.AbstractEventLoop
– The event loop to use. The default one will be used if not defined.
-
session
¶ aiohttp.ClientSession
– The client session that will be used for the requests. One will be created by default.
-
proxy_url
¶ str
– The URL of the SOCKS proxy to use for requests. Note that if a session is passed, the SOCKS proxy won’t be used and must be applied when creating the session.
-
coroutine
fetch_boosted_creature
()[source]¶ Fetches today’s boosted creature.
New in version 2.1.0.
Returns: The boosted creature of the day.
Return type: Raises: Forbidden
– If a 403 Forbidden error was returned. This usually means that Tibia.com is rate-limiting the client because of too many requests.NetworkError
– If there’s any connection errors during the request.
-
coroutine
fetch_character
(name)[source]¶ Fetches a character by its name from Tibia.com
Parameters: name (
str
) – The name of the character.Returns: The character if found, else
None
.Return type: Raises: Forbidden
– If a 403 Forbidden error was returned. This usually means that Tibia.com is rate-limiting the client because of too many requests.NetworkError
– If there’s any connection errors during the request.
-
coroutine
fetch_guild
(name)[source]¶ Fetches a guild by its name from Tibia.com
Parameters: name (
str
) – The name of the guild. The case must match exactly.Returns: The guild if found, else
None
.Return type: Raises: Forbidden
– If a 403 Forbidden error was returned. This usually means that Tibia.com is rate-limiting the client because of too many requests.NetworkError
– If there’s any connection errors during the request.
-
coroutine
fetch_highscores_page
(world, category=Category.EXPERIENCE, vocation=<VocationFilter.ALL: 0>, page=1)[source]¶ Fetches a single highscores page from Tibia.com
Parameters: - world (
str
) – The world to search the highscores in. - category (
Category
) – The highscores category to search, by default Experience. - vocation (
VocationFilter
) – The vocation filter to use. No filter used by default. - page (
int
) – The page to fetch, by default the first page is fetched.
Returns: The highscores information or
None
if not found.Return type: Raises: Forbidden
– If a 403 Forbidden error was returned. This usually means that Tibia.com is rate-limiting the client because of too many requests.NetworkError
– If there’s any connection errors during the request.
- world (
-
coroutine
fetch_house
(house_id, world)[source]¶ Fetches a house in a specific world by its id.
Parameters: Returns: The house if found,
None
otherwise.Return type: Raises: Forbidden
– If a 403 Forbidden error was returned. This usually means that Tibia.com is rate-limiting the client because of too many requests.NetworkError
– If there’s any connection errors during the request.
-
coroutine
fetch_kill_statistics
(world)[source]¶ Fetches the kill statistics of a world from Tibia.com.
Parameters: world (
str
) – The name of the world.Returns: The kill statistics of the world if found.
Return type: Raises: Forbidden
– If a 403 Forbidden error was returned. This usually means that Tibia.com is rate-limiting the client because of too many requests.NetworkError
– If there’s any connection errors during the request.
-
coroutine
fetch_news
(news_id)[source]¶ Fetches a news entry by its id from Tibia.com
Parameters: news_id (
int
) – The id of the news entry.Returns: The news entry if found,
None
otherwise.Return type: Raises: Forbidden
– If a 403 Forbidden error was returned. This usually means that Tibia.com is rate-limiting the client because of too many requests.NetworkError
– If there’s any connection errors during the request.
-
coroutine
fetch_news_archive
(begin_date, end_date, categories=None, types=None)[source]¶ Fetches news from the archive meeting the search criteria.
Parameters: - begin_date (
datetime.date
) – The beginning date to search dates in. - end_date (
datetime.date
) – The end date to search dates in. - categories (list of
NewsCategory
) – The allowed categories to show. If left blank, all categories will be searched. - types (list of
ListedNews
) – The allowed news types to show. if unused, all types will be searched.
Returns: The news meeting the search criteria.
Return type: list of
ListedNews
Raises: - ValueError: – If
begin_date
is more recent thanend_date
. Forbidden
– If a 403 Forbidden error was returned. This usually means that Tibia.com is rate-limiting the client because of too many requests.NetworkError
– If there’s any connection errors during the request.
- begin_date (
-
coroutine
fetch_recent_news
(days=30, categories=None, types=None)[source]¶ Fetches all the published news in the last specified days.
This is a shortcut for
fetch_news_archive()
, to handle dates more easily.Parameters: - days (
int
) – The number of days to search, by default 30. - categories (list of
NewsCategory
) – The allowed categories to show. If left blank, all categories will be searched. - types (list of
ListedNews
) – The allowed news types to show. if unused, all types will be searched.
Returns: The news posted in the last specified days.
Return type: list of
ListedNews
Raises: Forbidden
– If a 403 Forbidden error was returned. This usually means that Tibia.com is rate-limiting the client because of too many requests.NetworkError
– If there’s any connection errors during the request.
- days (
-
coroutine
fetch_world
(name)[source]¶ Fetches a world from Tibia.com
Parameters: name (
str
) – The name of the world.Returns: The world’s information if found,
`None
otherwise.Return type: Raises: Forbidden
– If a 403 Forbidden error was returned. This usually means that Tibia.com is rate-limiting the client because of too many requests.NetworkError
– If there’s any connection errors during the request.
-
coroutine
fetch_world_guilds
(world: str)[source]¶ Fetches the list of guilds in a world from Tibia.com
Parameters: world (
str
) – The name of the world.Returns: The lists of guilds in the world.
Return type: list of
ListedGuild
Raises: Forbidden
– If a 403 Forbidden error was returned. This usually means that Tibia.com is rate-limiting the client because of too many requests.NetworkError
– If there’s any connection errors during the request.
-
coroutine
fetch_world_houses
(world, town, house_type=HouseType.HOUSE, status: tibiapy.enums.HouseStatus = None, order=HouseOrder.NAME)[source]¶ Fetches the house list of a world and type.
Parameters: - world (
str
) – The name of the world. - town (
str
) – The name of the town. - house_type (
HouseType
) – The type of building. House by default. - status (
HouseStatus
, optional) – The house status to filter results. By default no filters will be applied. - order (
HouseOrder
, optional) – The ordering to use for the results. By default they are sorted by name.
Returns: The lists of houses meeting the criteria if found.
Return type: list of
ListedHouse
Raises: Forbidden
– If a 403 Forbidden error was returned. This usually means that Tibia.com is rate-limiting the client because of too many requests.NetworkError
– If there’s any connection errors during the request.
- world (
-
coroutine
fetch_world_list
()[source]¶ Fetches the world overview information from Tibia.com.
Returns: The world overview information.
Return type: Raises: Forbidden
– If a 403 Forbidden error was returned. This usually means that Tibia.com is rate-limiting the client because of too many requests.NetworkError
– If there’s any connection errors during the request.
-
Enumerations¶
Enumerations are provided for various values in order to avoid depending on strings.
-
class
tibiapy.
AccountStatus
[source]¶ Possible account statuses.
-
FREE_ACCOUNT
= 'Free Account'¶
-
PREMIUM_ACCOUNT
= 'Premium Account'¶
-
-
class
tibiapy.
Category
[source]¶ The different highscores categories.
-
ACHIEVEMENTS
= 'achievements'¶
-
AXE_FIGHTING
= 'axe'¶
-
CLUB_FIGHTING
= 'club'¶
-
DISTANCE_FIGHTING
= 'distance'¶
-
EXPERIENCE
= 'experience'¶
-
FISHING
= 'fishing'¶
-
FIST_FIGHTING
= 'fist'¶
-
LOYALTY_POINTS
= 'loyalty'¶
-
MAGIC_LEVEL
= 'magic'¶
-
SHIELDING
= 'shielding'¶
-
SWORD_FIGHTING
= 'sword'¶
-
-
class
tibiapy.
HouseOrder
[source]¶ The possible ordering methods for house lists in Tibia.com
-
NAME
= 'name'¶
-
SIZE
= 'size'¶
-
RENT
= 'rent'¶
-
BID
= 'bid'¶
-
AUCTION_END
= 'end'¶
-
-
class
tibiapy.
HouseStatus
[source]¶ Renting statuses of a house.
-
RENTED
= 'rented'¶
-
AUCTIONED
= 'auctioned'¶
-
-
class
tibiapy.
HouseType
[source]¶ The types of house available.
-
HOUSE
= 'house'¶
-
GUILDHALL
= 'guildhall'¶
-
-
class
tibiapy.
NewsCategory
[source]¶ The different news categories.
-
CIPSOFT
= 'cipsoft'¶
-
COMMUNITY
= 'community'¶
-
DEVELOPMENT
= 'development'¶
-
SUPPORT
= 'support'¶
-
TECHNICAL_ISSUES
= 'technical'¶
-
-
class
tibiapy.
NewsType
[source]¶ The different types of new entries.
-
NEWS_TICKER
= 'News Ticker'¶
-
FEATURED_ARTICLE
= 'Featured Article'¶
-
NEWS
= 'News'¶
-
-
class
tibiapy.
PvpType
[source]¶ The possible PvP types a World can have.
-
OPEN_PVP
= 'Open PvP'¶
-
OPTIONAL_PVP
= 'Optional PvP'¶
-
RETRO_OPEN_PVP
= 'Retro Open PvP'¶
-
RETRO_HARDCORE_PVP
= 'Retro Hardcore PvP'¶
-
HARDCORE_PVP
= 'Hardcore PvP'¶
-
-
class
tibiapy.
TournamentWorldType
[source]¶ The possible types of tournament worlds.
-
REGUlAR
= 'Regular'¶
-
RESTRICTED
= 'Restricted Store'¶
-
-
class
tibiapy.
TransferType
[source]¶ The possible special transfer restrictions a world may have.
-
REGULAR
= 'regular'¶ No special transfer restrictions
-
BLOCKED
= 'blocked'¶ Can’t transfer to this world, but can transfer out of this world.
-
LOCKED
= 'locked'¶ Can transfer to this world, but can’t transfer out of this world.
-
-
class
tibiapy.
Vocation
[source]¶ The possible vocation types.
-
NONE
= 'None'¶
-
DRUID
= 'Druid'¶
-
KNIGHT
= 'Knight'¶
-
PALADIN
= 'Paladin'¶
-
SORCERER
= 'Sorcerer'¶
-
ELDER_DRUID
= 'Elder Druid'¶
-
ELITE_KNIGHT
= 'Elite Knight'¶
-
ROYAL_PALADIN
= 'Royal Paladin'¶
-
MASTER_SORCERER
= 'Master Sorcerer'¶
-
-
class
tibiapy.
VocationFilter
[source]¶ The vocation filters available for Highscores.
-
classmethod
from_name
(name, all_fallback=True)[source]¶ Gets a vocation filter from a vocation’s name.
Parameters: Returns: The matching vocation filter.
Return type: VocationFilter, optional
-
ALL
= 0¶
-
KNIGHTS
= 1¶
-
PALADINS
= 2¶
-
SORCERERS
= 3¶
-
DRUIDS
= 4¶
-
classmethod
Main Models¶
The following models all contain their respective from_content
methods.
They all have their respective section in Tibia.com
BoostedCreature¶
-
class
tibiapy.
BoostedCreature
(name, image_url)[source]¶ Represents a boosted creature entry.
This creature changes every server save and applies to all Game Worlds. Boosted creatures yield twice the amount of experience points, carry more loot and respawn at a faster rate.
-
classmethod
from_content
(content)[source]¶ Gets the boosted creature from any Tibia.com page.
Parameters: content ( str
) – The HTML content of a Tibia.com page.Returns: The boosted article shown. Return type: News
Raises: InvalidContent
– If content is not the HTML of a Tibia.com’s page.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
classmethod
Character¶
-
class
tibiapy.
Character
(name=None, world=None, vocation=None, level=0, sex=None, **kwargs)[source]¶ Represents a Tibia character.
-
deletion_date
¶ datetime.datetime
, optional – The date when the character will be deleted if it is scheduled for deletion.
-
houses
¶ list
ofCharacterHouse
– The houses currently owned by the character.
-
guild_membership
¶ GuildMembership
, optional – The guild the character is a member of.
-
last_login
¶ datetime.datetime
, optional – The last time the character logged in. It will beNone
if the character has never logged in.
-
account_status
¶ AccountStatus
– Whether the character’s account is Premium or Free.
-
account_badges
¶ list
ofAccountBadge
– The displayed account badges.
-
achievements
¶ list
ofAchievement
– The achievements chosen to be displayed.
-
deaths_truncated
¶ bool
– Whether the character’s deaths are truncated or not.In some cases, there are more deaths in the last 30 days than what can be displayed.
-
account_information
¶ AccountInformation
, optional – The character’s account information, if visible.
-
other_characters
¶ list
ofOtherCharacter
– Other characters in the same account.It will be empty if the character is hidden, otherwise, it will contain at least the character itself.
bool
– Whether this is a hidden character or not.
-
house
¶ CharacterHouse
– The house currently owned by the character.Deprecated since version 2.4.0: Characters may have more than one house. This will only return the first if any. Use
houses
instead.Only kept for backwards compatibility and may be removed in the next major update.
-
classmethod
from_content
(content)[source]¶ Creates an instance of the class from the html content of the character’s page.
Parameters: content ( str
) – The HTML content of the page.Returns: The character contained in the page, or None if the character doesn’t exist Return type: Character
Raises: InvalidContent
– If content is not the HTML of a character’s page.
-
classmethod
from_tibiadata
(content)[source]¶ Builds a character object from a TibiaData character response.
Parameters: content ( str
) – The JSON content of the response.Returns: The character contained in the page, or None if the character doesn’t exist Return type: Character
Raises: InvalidContent
– If content is not a JSON string of the Character response.
-
classmethod
get_url
(name)¶ Gets the Tibia.com URL for a given character name.
Parameters: name ( str
) – The name of the character.Returns: The URL to the character’s page. Return type: str
-
classmethod
get_url_tibiadata
(name)¶ Gets the TibiaData.com URL for a given character name.
Parameters: name ( str
) – The name of the character.Returns: The URL to the character’s page on TibiaData.com. Return type: str
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
Guild¶
-
class
tibiapy.
Guild
(name=None, world=None, **kwargs)[source]¶ Represents a Tibia guild.
-
founded
¶ datetime.date
– The day the guild was founded.
-
guildhall
¶ GuildHouse
, optional – The guild’s guildhall if any.
-
disband_date
¶ datetime.datetime
, optional – The date when the guild will be disbanded if the condition hasn’t been meet.
-
members
¶ list
ofGuildMember
– List of guild members.
-
invites
¶ list
ofGuildInvite
– List of invited characters.
-
online_members
¶ list
ofGuildMember
– List of currently online members.
-
classmethod
from_content
(content)[source]¶ Creates an instance of the class from the HTML content of the guild’s page.
Parameters: content ( str
) – The HTML content of the page.Returns: The guild contained in the page or None if it doesn’t exist. Return type: Guild
Raises: InvalidContent
– If content is not the HTML of a guild’s page.
-
classmethod
from_tibiadata
(content)[source]¶ Builds a guild object from a TibiaData character response.
Parameters: content ( str
) – The json string from the TibiaData response.Returns: The guild contained in the description or None
.Return type: Guild
Raises: InvalidContent
– If content is not a JSON response of a guild’s page.
-
classmethod
get_url
(name)¶ Gets the Tibia.com URL for a given guild name.
Parameters: name ( str
) – The name of the guild.Returns: The URL to the guild’s page Return type: str
-
classmethod
get_url_tibiadata
(name)¶ Gets the TibiaData.com URL for a given guild name.
Parameters: name ( str
) – The name of the guild.Returns: The URL to the guild’s page on TibiaData.com. Return type: str
-
classmethod
get_world_list_url
(world)¶ Gets the Tibia.com URL for the guild section of a specific world.
Parameters: world ( str
) – The name of the world.Returns: The URL to the guild’s page Return type: str
-
classmethod
get_world_list_url_tibiadata
(world)¶ Gets the TibiaData.com URL for the guild list of a specific world.
Parameters: world ( str
) – The name of the world.Returns: The URL to the guild’s page. Return type: str
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
Highscores¶
-
class
tibiapy.
Highscores
(world, category, **kwargs)[source]¶ Represents the highscores of a world.
Tibia.com only shows 25 entries per page. TibiaData.com shows all results at once.
New in version 1.1.0.
-
vocation
¶ VocationFilter
– The selected vocation to filter out values.
-
entries
¶ list
ofHighscoresEntry
– The highscores entries found.
-
results_count
¶ int
– The total amount of highscores entries in this category. These may be shown in another page.
-
classmethod
from_content
(content)[source]¶ Creates an instance of the class from the html content of a highscores page.
Notes
Tibia.com only shows up to 25 entries per page, so in order to obtain the full highscores, all 12 pages must be parsed and merged into one.
Parameters: content ( str
) – The HTML content of the page.Returns: The highscores results contained in the page. Return type: Highscores
Raises: InvalidContent
– If content is not the HTML of a highscore’s page.
-
classmethod
from_tibiadata
(content, vocation=None)[source]¶ Builds a highscores object from a TibiaData highscores response.
Notes
Since TibiaData.com’s response doesn’t contain any indication of the vocation filter applied,
vocation
can’t be determined from the response, so the attribute must be assigned manually.If the attribute is known, it can be passed for it to be assigned in this method.
Parameters: - content (
str
) – The JSON content of the response. - vocation (
VocationFilter
, optional) – The vocation filter to assign to the results. Note that this won’t affect the parsing.
Returns: The highscores contained in the page, or None if the content is for the highscores of a nonexistent world.
Return type: Raises: InvalidContent
– If content is not a JSON string of the highscores response.- content (
-
classmethod
get_url
(world, category=Category.EXPERIENCE, vocation=<VocationFilter.ALL: 0>, page=1)[source]¶ Gets the Tibia.com URL of the highscores for the given parameters.
Parameters: Returns: Return type: The URL to the Tibia.com highscores.
-
classmethod
get_url_tibiadata
(world, category=Category.EXPERIENCE, vocation=<VocationFilter.ALL: 0>)[source]¶ Gets the TibiaData.com URL of the highscores for the given parameters.
Parameters: Returns: Return type: The URL to the TibiaData.com highscores.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
House¶
-
class
tibiapy.
House
(name, world=None, **kwargs)[source]¶ Represents a house in a specific world.
-
status
¶ HouseStatus
– The current status of the house.
-
paid_until
¶ datetime.datetime
, optional – The date the last paid rent is due.
-
transfer_date
¶ datetime.datetime
, optional – The date when the owner will move out of the house, if applicable.
-
transferee
¶ str
, optional – The character who will receive the house when the owner moves, if applicable.
-
transfer_price
¶ int
– The price that will be paid from the transferee to the owner for the house transfer.
-
auction_end
¶ datetime.datetime
, optional – The date when the auction will end.
-
transferee_url
¶ str
– The URL to the Tibia.com page of the character receiving the house, if applicable.
-
highest_bidder_url
¶ str
– The URL to the Tibia.com page of the character with the highest bid, if applicable.
-
classmethod
from_content
(content)[source]¶ Parses a Tibia.com response into a House object.
Parameters: content ( str
) – HTML content of the page.Returns: The house contained in the page, or None if the house doesn’t exist. Return type: House
Raises: InvalidContent
– If the content is not the house section on Tibia.com
-
classmethod
from_tibiadata
(content)[source]¶ Parses a TibiaData response into a House object.
Parameters: content ( str
) – The JSON content of the TibiaData response.Returns: The house contained in the response, if found. Return type: House
Raises: InvalidContent
– If the content is not a house JSON response from TibiaData
-
classmethod
get_list_url
(world, town, house_type: tibiapy.enums.HouseType = HouseType.HOUSE, status: tibiapy.enums.HouseStatus = None, order=HouseOrder.NAME)¶ Gets the URL to the house list on Tibia.com with the specified parameters.
Parameters: - world (
str
) – The name of the world. - town (
str
) – The name of the town. - house_type (
HouseType
) – Whether to search for houses or guildhalls. - status (
HouseStatus
, optional) – The house status to filter results. By default no filters will be applied. - order (
HouseOrder
, optional) – The ordering to use for the results. By default they are sorted by name.
Returns: The URL to the list matching the parameters.
Return type: - world (
-
classmethod
get_list_url_tibiadata
(world, town, house_type: tibiapy.enums.HouseType = HouseType.HOUSE)¶ Gets the URL to the house list on Tibia.com with the specified parameters.
Parameters: Returns: The URL to the list matching the parameters.
Return type:
-
classmethod
get_url
(house_id, world)¶ Gets the Tibia.com URL for a house with the given id and world.
Parameters: Returns: Return type: The URL to the house in Tibia.com
-
classmethod
get_url_tibiadata
(house_id, world)¶ Gets the TibiaData.com URL for a house with the given id and world.
Parameters: Returns: Return type: The URL to the house in TibiaData.com
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
KillStatistics¶
-
class
tibiapy.
KillStatistics
(world, entries=None, total=None)[source]¶ Represents the kill statistics of a world.
-
classmethod
get_url
(world)[source]¶ Gets the Tibia.com URL of the kill statistics of a world.
Parameters: world ( str
) – The game world of the desired kill statistics.Returns: Return type: The URL to the Tibia.com kill statistics for this world.
-
classmethod
from_content
(content)[source]¶ Creates an instance of the class from the HTML content of the kill statistics’ page.
Parameters: content ( str
) – The HTML content of the page.Returns: The kill statistics contained in the page or None if it doesn’t exist. Return type: KillStatistics
Raises: InvalidContent
– If content is not the HTML of a kill statistics’ page.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
classmethod
ListedGuild¶
-
class
tibiapy.
ListedGuild
(name, world, logo_url=None, description=None, active=False)[source]¶ Represents a Tibia guild in the guild list of a world.
-
classmethod
list_from_content
(content)[source]¶ Gets a list of guilds from the HTML content of the world guilds’ page.
Parameters: content ( str
) – The HTML content of the page.Returns: List of guilds in the current world. None
if it’s the list of a world that doesn’t exist.Return type: list
ofListedGuild
Raises: InvalidContent
– If content is not the HTML of a guild’s page.
-
classmethod
list_from_tibiadata
(content)[source]¶ Builds a character object from a TibiaData character response.
Parameters: content ( str
) – A string containing the JSON response from TibiaData.Returns: The list of guilds contained. Return type: list
ofListedGuild
Raises: InvalidContent
– If content is not a JSON response of TibiaData’s guild list.
-
classmethod
get_url
(name)¶ Gets the Tibia.com URL for a given guild name.
Parameters: name ( str
) – The name of the guild.Returns: The URL to the guild’s page Return type: str
-
classmethod
get_url_tibiadata
(name)¶ Gets the TibiaData.com URL for a given guild name.
Parameters: name ( str
) – The name of the guild.Returns: The URL to the guild’s page on TibiaData.com. Return type: str
-
classmethod
get_world_list_url
(world)¶ Gets the Tibia.com URL for the guild section of a specific world.
Parameters: world ( str
) – The name of the world.Returns: The URL to the guild’s page Return type: str
-
classmethod
get_world_list_url_tibiadata
(world)¶ Gets the TibiaData.com URL for the guild list of a specific world.
Parameters: world ( str
) – The name of the world.Returns: The URL to the guild’s page. Return type: str
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
classmethod
ListedHouse¶
-
class
tibiapy.
ListedHouse
(name, world, houseid, **kwargs)[source]¶ Represents a house from the house list in Tibia.com.
-
status
¶ HouseStatus
– The current status of the house.
-
time_left
¶ datetime.timedelta
, optional – The number of days or hours left until the bid ends, if it has started. This is not an exact measure, it is rounded to hours or days.
-
classmethod
list_from_content
(content)[source]¶ Parses the content of a house list from Tibia.com into a list of houses
Parameters: content ( str
) – The raw HTML response from the house list.Returns: Return type: list
ofListedHouse
Raises: InvalidContent` – Content is not the house list from Tibia.com
-
classmethod
list_from_tibiadata
(content)[source]¶ Parses the content of a house list from TibiaData.com into a list of houses
Parameters: content ( str
) – The raw JSON response from TibiaDataReturns: Return type: list
ofListedHouse
Raises: InvalidContent` – Content is not the house list from TibiaData.com
-
classmethod
get_list_url
(world, town, house_type: tibiapy.enums.HouseType = HouseType.HOUSE, status: tibiapy.enums.HouseStatus = None, order=HouseOrder.NAME)¶ Gets the URL to the house list on Tibia.com with the specified parameters.
Parameters: - world (
str
) – The name of the world. - town (
str
) – The name of the town. - house_type (
HouseType
) – Whether to search for houses or guildhalls. - status (
HouseStatus
, optional) – The house status to filter results. By default no filters will be applied. - order (
HouseOrder
, optional) – The ordering to use for the results. By default they are sorted by name.
Returns: The URL to the list matching the parameters.
Return type: - world (
-
classmethod
get_list_url_tibiadata
(world, town, house_type: tibiapy.enums.HouseType = HouseType.HOUSE)¶ Gets the URL to the house list on Tibia.com with the specified parameters.
Parameters: Returns: The URL to the list matching the parameters.
Return type:
-
classmethod
get_url
(house_id, world)¶ Gets the Tibia.com URL for a house with the given id and world.
Parameters: Returns: Return type: The URL to the house in Tibia.com
-
classmethod
get_url_tibiadata
(house_id, world)¶ Gets the TibiaData.com URL for a house with the given id and world.
Parameters: Returns: Return type: The URL to the house in TibiaData.com
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
ListedNews¶
-
class
tibiapy.
ListedNews
(news_id, title, news_type, category, date, **kwargs)[source]¶ Represents a news entry.
-
category
¶ NewsCategory
– The category this belongs to.
-
date
¶ datetime.date
– The date when the news were published.
-
classmethod
list_from_content
(content)[source]¶ Gets a list of news from the HTML content of the news search page.
Parameters: content ( str
) – The HTML content of the page.Returns: List of news in the search results. Return type: list
ofListedNews
Raises: InvalidContent
– If content is not the HTML of a news search’s page.
-
classmethod
get_list_url
()¶ Gets the URL to Tibia.com’s news archive page.
Notes
It is not possible to perform a search using query parameters. News searches can only be performed using POST requests sending the parameters as form-data.
Returns: The URL to the news archive page on Tibia.com. Return type: str
-
classmethod
get_url
(news_id)¶ Gets the Tibia.com URL for a news entry by its id.
Parameters: news_id ( int
) – The id of the news entry.Returns: The URL to the news’ page Return type: str
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
ListedWorld¶
-
class
tibiapy.
ListedWorld
(name, location=None, pvp_type=None, **kwargs)[source]¶ Represents a game server listed in the World Overview section.
-
location
¶ WorldLocation
– The physical location of the game servers.
-
transfer_type
¶ TransferType
– The type of transfer restrictions this world has.
-
battleye_date
¶ datetime.date
– The date when BattlEye was added to this world. If this isNone
and the world is protected, it means the world was protected from the beginning.
bool
– Whether only premium account players are allowed to play in this server.
-
tournament_world_type
¶ TournamentWorldType
– The type of tournament world.None
if this is not a tournament world.
-
classmethod
get_list_url
()[source]¶ Gets the URL to the World Overview page in Tibia.com
Returns: The URL to the World Overview’s page. Return type: str
-
classmethod
get_list_url_tibiadata
()[source]¶ Gets the URL to the World Overview page in Tibia.com
Returns: The URL to the World Overview’s page. Return type: str
-
classmethod
list_from_content
(content)[source]¶ Parses the content of the World Overview section from Tibia.com and returns only the list of worlds.
Parameters: content ( str
) – The HTML content of the World Overview page in Tibia.comReturns: A list of the worlds and their current information. Return type: list
ofListedWorld
Raises: InvalidContent
– If the provided content is not the HTML content of the worlds section in Tibia.com
-
classmethod
list_from_tibiadata
(content)[source]¶ Parses the content of the World Overview section from TibiaData.com.
Notes
Due to TibiaData limitations, the listed worlds lack some information. The following attributes are unavailable:
status
is alwaysOnline
.battleye_protected
is alwaysFalse
battleye_date
is alwaysNone
.
Parameters: content ( str
) – The JSON response of the worlds section in TibiaData.comReturns: A list of the worlds and their current information. Return type: list
ofListedWorld
Raises: InvalidContent
– If the provided content is the json content of the world section in TibiaData.com
-
classmethod
get_url
(name)¶ Gets the URL to the World’s information page on Tibia.com.
Parameters: name ( str
) – The name of the world.Returns: The URL to the world’s information page. Return type: str
-
classmethod
get_url_tibiadata
(name)¶ Gets the URL to the World’s information page on TibiaData.com.
Parameters: name ( str
) – The name of the world.Returns: The URL to the world’s information page on TibiaData.com. Return type: str
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
News¶
-
class
tibiapy.
News
(news_id, title, content, date, category, **kwargs)[source]¶ Represents a news entry.
-
category
¶ NewsCategory
– The category this belongs to.
-
date
¶ datetime.date
– The date when the news were published.
-
classmethod
from_content
(content, news_id=0)[source]¶ Gets a news entry by its HTML content from Tibia.com
Notes
Since there’s no way to obtain the entry’s Id from the page contents, it will always be 0. A news_id can be passed to set the news_id of the resulting object.
Parameters: Returns: The news article found in the page.
Return type: Raises: InvalidContent
– If content is not the HTML of a news’ page.
-
classmethod
get_list_url
()¶ Gets the URL to Tibia.com’s news archive page.
Notes
It is not possible to perform a search using query parameters. News searches can only be performed using POST requests sending the parameters as form-data.
Returns: The URL to the news archive page on Tibia.com. Return type: str
-
classmethod
get_url
(news_id)¶ Gets the Tibia.com URL for a news entry by its id.
Parameters: news_id ( int
) – The id of the news entry.Returns: The URL to the news’ page Return type: str
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
World¶
-
class
tibiapy.
World
(name, location=None, pvp_type=None, **kwargs)[source]¶ Represents a Tibia game server.
-
record_date
¶ datetime.datetime
– The date when the online record was achieved.
-
location
¶ WorldLocation
– The physical location of the game servers.
-
transfer_type
¶ TransferType
– The type of transfer restrictions this world has.
-
battleye_date
¶ datetime.date
– The date when BattlEye was added to this world. If this isNone
and the world is protected, it means the world was protected from the beginning.
-
tournament_world_type
¶ TournamentWorldType
– The type of tournament world.None
if this is not a tournament world.
-
online_players
¶ list
ofOnlineCharacter
. – A list of characters currently online in the server.
bool
– Whether only premium account players are allowed to play in this server.
-
creation_month
¶ ìnt
– Returns the month when the world was created.
-
classmethod
from_content
(content)[source]¶ Parses a Tibia.com response into a
World
.Parameters: content ( str
) – The raw HTML from the server’s information page.Returns: The World described in the page, or None
.Return type: World
Raises: InvalidContent
– If the provided content is not the html content of the world section in Tibia.com
-
classmethod
from_tibiadata
(content)[source]¶ Parses a TibiaData.com response into a
World
Parameters: content ( str
) – The raw JSON content from TibiaDataReturns: The World described in the page, or None
.Return type: World
Raises: InvalidContent
– If the provided content is not a TibiaData world response.
-
classmethod
get_url
(name)¶ Gets the URL to the World’s information page on Tibia.com.
Parameters: name ( str
) – The name of the world.Returns: The URL to the world’s information page. Return type: str
-
classmethod
get_url_tibiadata
(name)¶ Gets the URL to the World’s information page on TibiaData.com.
Parameters: name ( str
) – The name of the world.Returns: The URL to the world’s information page on TibiaData.com. Return type: str
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
WorldOverview¶
-
class
tibiapy.
WorldOverview
(**kwargs)[source]¶ Container class for the World Overview section.
-
record_date
¶ datetime.datetime
– The date when the record was achieved.
-
worlds
¶ list
ofListedWorld
– List of worlds, with limited info.
-
tournament_worlds
¶ list
ofGuildMember
– List of tournament worlds.Note that tournament worlds are not listed when there are no active or upcoming tournaments.
-
regular_worlds
¶ list
ofListedWorld
– List of worlds that are not tournament worlds.
-
classmethod
get_url
()[source]¶ Gets the URL to the World Overview page in Tibia.com
Returns: The URL to the World Overview’s page. Return type: str
-
classmethod
get_url_tibiadata
()[source]¶ Gets the URL to the World Overview page in Tibia.com
Returns: The URL to the World Overview’s page. Return type: str
-
classmethod
from_content
(content)[source]¶ Parses the content of the World Overview section from Tibia.com into an object of this class.
Parameters: content ( str
) – The HTML content of the World Overview page in Tibia.comReturns: An instance of this class containing all the information. Return type: WorldOverview
Raises: InvalidContent
– If the provided content is not the HTML content of the worlds section in Tibia.com
-
classmethod
from_tibiadata
(content)[source]¶ Parses the content of the World Overview section from TibiaData.com into an object of this class.
Notes
Due to TibiaData limitations,
record_count
andrecord_date
are unavailable object.Additionally, the listed worlds in
worlds
lack some information when obtained from TibiaData. The following attributes are unavailable:ListedWorld.status
is alwaysOnline
.ListedWorld.battleye_protected
is alwaysFalse
ListedWorld.battleye_date
is alwaysNone
.
Parameters: content ( str
) – The JSON response of the worlds section in TibiaData.comReturns: An instance of this class containing only the available worlds. Return type: WorldOverview
Raises: InvalidContent
– If the provided content is the json content of the world section in TibiaData.com
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
Auxiliary Classes¶
Auxiliary classes are used to hold certain data in a standardized way, in some cases, introducing additional methods and properties for their use.
AccountBadge¶
AccountInformation¶
-
class
tibiapy.
AccountInformation
(created, loyalty_title=None, position=None)[source]¶ Represents the account information of a character.
-
created
¶ datetime.datetime
– The date when the account was created.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
Achievement¶
-
class
tibiapy.
Achievement
(name, grade, secret=False)[source]¶ Represents an achievement listed on a character’s page.
-
secret
¶ :class:´bool´ – Whether the achievement is secret or not.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
CharacterHouse¶
-
class
tibiapy.
CharacterHouse
(_id, name, world=None, town=None, owner=None, paid_until_date=None)[source]¶ Represents a House owned by a character.
-
status
¶ HouseStatus
– The current status of the house.
-
paid_until_date
¶ datetime.date
– The date the last paid rent is due.
-
classmethod
get_list_url
(world, town, house_type: tibiapy.enums.HouseType = HouseType.HOUSE, status: tibiapy.enums.HouseStatus = None, order=HouseOrder.NAME)¶ Gets the URL to the house list on Tibia.com with the specified parameters.
Parameters: - world (
str
) – The name of the world. - town (
str
) – The name of the town. - house_type (
HouseType
) – Whether to search for houses or guildhalls. - status (
HouseStatus
, optional) – The house status to filter results. By default no filters will be applied. - order (
HouseOrder
, optional) – The ordering to use for the results. By default they are sorted by name.
Returns: The URL to the list matching the parameters.
Return type: - world (
-
classmethod
get_list_url_tibiadata
(world, town, house_type: tibiapy.enums.HouseType = HouseType.HOUSE)¶ Gets the URL to the house list on Tibia.com with the specified parameters.
Parameters: Returns: The URL to the list matching the parameters.
Return type:
-
classmethod
get_url
(house_id, world)¶ Gets the Tibia.com URL for a house with the given id and world.
Parameters: Returns: Return type: The URL to the house in Tibia.com
-
classmethod
get_url_tibiadata
(house_id, world)¶ Gets the TibiaData.com URL for a house with the given id and world.
Parameters: Returns: Return type: The URL to the house in TibiaData.com
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
ExpHighscoresEntry¶
-
class
tibiapy.
ExpHighscoresEntry
(name, rank, vocation, value, level)[source]¶ Represents an entry for the highscores’s experience category.
This is a subclass of
HighscoresEntry
, adding an extra field for level.-
classmethod
get_url
(name)¶ Gets the Tibia.com URL for a given character name.
Parameters: name ( str
) – The name of the character.Returns: The URL to the character’s page. Return type: str
-
classmethod
get_url_tibiadata
(name)¶ Gets the TibiaData.com URL for a given character name.
Parameters: name ( str
) – The name of the character.Returns: The URL to the character’s page on TibiaData.com. Return type: str
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
classmethod
Death¶
-
class
tibiapy.
Death
(name=None, level=0, **kwargs)[source]¶ Represents a death by a character
-
time
¶ datetime.datetime
– The time at which the death occurred.
-
killer
¶ Killer
– The first killer in the list.This is usually the killer that gave the killing blow.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
GuildHouse¶
-
class
tibiapy.
GuildHouse
(name, world=None, owner=None, paid_until_date=None)[source]¶ Represents a House owned by a guild.
-
status
¶ HouseStatus
– The current status of the house.
-
paid_until_date
¶ datetime.date
– The date the last paid rent is due.
-
classmethod
get_list_url
(world, town, house_type: tibiapy.enums.HouseType = HouseType.HOUSE, status: tibiapy.enums.HouseStatus = None, order=HouseOrder.NAME)¶ Gets the URL to the house list on Tibia.com with the specified parameters.
Parameters: - world (
str
) – The name of the world. - town (
str
) – The name of the town. - house_type (
HouseType
) – Whether to search for houses or guildhalls. - status (
HouseStatus
, optional) – The house status to filter results. By default no filters will be applied. - order (
HouseOrder
, optional) – The ordering to use for the results. By default they are sorted by name.
Returns: The URL to the list matching the parameters.
Return type: - world (
-
classmethod
get_list_url_tibiadata
(world, town, house_type: tibiapy.enums.HouseType = HouseType.HOUSE)¶ Gets the URL to the house list on Tibia.com with the specified parameters.
Parameters: Returns: The URL to the list matching the parameters.
Return type:
-
classmethod
get_url
(house_id, world)¶ Gets the Tibia.com URL for a house with the given id and world.
Parameters: Returns: Return type: The URL to the house in Tibia.com
-
classmethod
get_url_tibiadata
(house_id, world)¶ Gets the TibiaData.com URL for a house with the given id and world.
Parameters: Returns: Return type: The URL to the house in TibiaData.com
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
GuildInvite¶
-
class
tibiapy.
GuildInvite
(name=None, date=None)[source]¶ Represents an invited character
-
date
¶ datetime.date
– The day when the character was invited.
-
classmethod
get_url
(name)¶ Gets the Tibia.com URL for a given character name.
Parameters: name ( str
) – The name of the character.Returns: The URL to the character’s page. Return type: str
-
classmethod
get_url_tibiadata
(name)¶ Gets the TibiaData.com URL for a given character name.
Parameters: name ( str
) – The name of the character.Returns: The URL to the character’s page on TibiaData.com. Return type: str
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
GuildMember¶
-
class
tibiapy.
GuildMember
(name=None, rank=None, title=None, level=0, vocation=None, **kwargs)[source]¶ Represents a guild member.
-
joined
¶ datetime.date
– The day the member joined the guild.
-
classmethod
get_url
(name)¶ Gets the Tibia.com URL for a given character name.
Parameters: name ( str
) – The name of the character.Returns: The URL to the character’s page. Return type: str
-
classmethod
get_url_tibiadata
(name)¶ Gets the TibiaData.com URL for a given character name.
Parameters: name ( str
) – The name of the character.Returns: The URL to the character’s page on TibiaData.com. Return type: str
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
GuildMembership¶
-
class
tibiapy.
GuildMembership
(name, rank)[source]¶ Represents the guild information of a character.
-
classmethod
get_url
(name)¶ Gets the Tibia.com URL for a given guild name.
Parameters: name ( str
) – The name of the guild.Returns: The URL to the guild’s page Return type: str
-
classmethod
get_url_tibiadata
(name)¶ Gets the TibiaData.com URL for a given guild name.
Parameters: name ( str
) – The name of the guild.Returns: The URL to the guild’s page on TibiaData.com. Return type: str
-
classmethod
get_world_list_url
(world)¶ Gets the Tibia.com URL for the guild section of a specific world.
Parameters: world ( str
) – The name of the world.Returns: The URL to the guild’s page Return type: str
-
classmethod
get_world_list_url_tibiadata
(world)¶ Gets the TibiaData.com URL for the guild list of a specific world.
Parameters: world ( str
) – The name of the world.Returns: The URL to the guild’s page. Return type: str
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
classmethod
HighscoresEntry¶
-
class
tibiapy.
HighscoresEntry
(name, rank, vocation, value)[source]¶ Represents a entry for the highscores.
-
classmethod
get_url
(name)¶ Gets the Tibia.com URL for a given character name.
Parameters: name ( str
) – The name of the character.Returns: The URL to the character’s page. Return type: str
-
classmethod
get_url_tibiadata
(name)¶ Gets the TibiaData.com URL for a given character name.
Parameters: name ( str
) – The name of the character.Returns: The URL to the character’s page on TibiaData.com. Return type: str
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
classmethod
Killer¶
-
class
tibiapy.
Killer
(name, player=False, summon=None)[source]¶ Represents a killer.
A killer can be:
- A creature.
- A character.
- A creature summoned by a character.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
LoyaltyHighscoresEntry¶
-
class
tibiapy.
LoyaltyHighscoresEntry
(name, rank, vocation, value, title)[source]¶ Represents a entry for the highscores loyalty points category.
This is a subclass of
HighscoresEntry
, adding an extra field for title.-
classmethod
get_url
(name)¶ Gets the Tibia.com URL for a given character name.
Parameters: name ( str
) – The name of the character.Returns: The URL to the character’s page. Return type: str
-
classmethod
get_url_tibiadata
(name)¶ Gets the TibiaData.com URL for a given character name.
Parameters: name ( str
) – The name of the character.Returns: The URL to the character’s page on TibiaData.com. Return type: str
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
classmethod
OnlineCharacter¶
-
class
tibiapy.
OnlineCharacter
(name, world, level, vocation)[source]¶ Represents an online character.
-
classmethod
get_url
(name)¶ Gets the Tibia.com URL for a given character name.
Parameters: name ( str
) – The name of the character.Returns: The URL to the character’s page. Return type: str
-
classmethod
get_url_tibiadata
(name)¶ Gets the TibiaData.com URL for a given character name.
Parameters: name ( str
) – The name of the character.Returns: The URL to the character’s page on TibiaData.com. Return type: str
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
classmethod
OtherCharacter¶
-
class
tibiapy.
OtherCharacter
(name, world, online=False, deleted=False, main=False)[source]¶ Represents other characters displayed in the Character’s information page.
-
classmethod
get_url
(name)¶ Gets the Tibia.com URL for a given character name.
Parameters: name ( str
) – The name of the character.Returns: The URL to the character’s page. Return type: str
-
classmethod
get_url_tibiadata
(name)¶ Gets the TibiaData.com URL for a given character name.
Parameters: name ( str
) – The name of the character.Returns: The URL to the character’s page on TibiaData.com. Return type: str
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
classmethod
RaceEntry¶
-
class
tibiapy.
RaceEntry
(last_day_killed=0, last_day_players_killed=0, last_week_killed=0, last_week_players_killed=0)[source]¶ Represents the statistics of a race.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
Base Classes¶
The following classes are not meant to be used or instantiated, but are documented here for informational purposes.
They implement methods and properties that can be inherited by other classes to implement their functionality.
-
class
tibiapy.abc.
BaseCharacter
[source]¶ Base class for all character classes.
Implements common properties methods for characters.
The following implement this class:
-
classmethod
get_url
(name)[source]¶ Gets the Tibia.com URL for a given character name.
Parameters: name ( str
) – The name of the character.Returns: The URL to the character’s page. Return type: str
-
classmethod
get_url_tibiadata
(name)[source]¶ Gets the TibiaData.com URL for a given character name.
Parameters: name ( str
) – The name of the character.Returns: The URL to the character’s page on TibiaData.com. Return type: str
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
classmethod
-
class
tibiapy.abc.
BaseGuild
[source]¶ Base class for Guild classes.
The following implement this class:
-
classmethod
get_url
(name)[source]¶ Gets the Tibia.com URL for a given guild name.
Parameters: name ( str
) – The name of the guild.Returns: The URL to the guild’s page Return type: str
-
classmethod
get_url_tibiadata
(name)[source]¶ Gets the TibiaData.com URL for a given guild name.
Parameters: name ( str
) – The name of the guild.Returns: The URL to the guild’s page on TibiaData.com. Return type: str
-
classmethod
get_world_list_url
(world)[source]¶ Gets the Tibia.com URL for the guild section of a specific world.
Parameters: world ( str
) – The name of the world.Returns: The URL to the guild’s page Return type: str
-
classmethod
get_world_list_url_tibiadata
(world)[source]¶ Gets the TibiaData.com URL for the guild list of a specific world.
Parameters: world ( str
) – The name of the world.Returns: The URL to the guild’s page. Return type: str
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
classmethod
-
class
tibiapy.abc.
BaseHouse
[source]¶ Base class for all house classes
The following implement this class:
-
status
¶ HouseStatus
– The current status of the house.
-
type
¶ HouseType
– The type of the house.
-
classmethod
get_url
(house_id, world)[source]¶ Gets the Tibia.com URL for a house with the given id and world.
Parameters: Returns: Return type: The URL to the house in Tibia.com
-
classmethod
get_url_tibiadata
(house_id, world)[source]¶ Gets the TibiaData.com URL for a house with the given id and world.
Parameters: Returns: Return type: The URL to the house in TibiaData.com
-
classmethod
get_list_url
(world, town, house_type: tibiapy.enums.HouseType = HouseType.HOUSE, status: tibiapy.enums.HouseStatus = None, order=HouseOrder.NAME)[source]¶ Gets the URL to the house list on Tibia.com with the specified parameters.
Parameters: - world (
str
) – The name of the world. - town (
str
) – The name of the town. - house_type (
HouseType
) – Whether to search for houses or guildhalls. - status (
HouseStatus
, optional) – The house status to filter results. By default no filters will be applied. - order (
HouseOrder
, optional) – The ordering to use for the results. By default they are sorted by name.
Returns: The URL to the list matching the parameters.
Return type: - world (
-
classmethod
get_list_url_tibiadata
(world, town, house_type: tibiapy.enums.HouseType = HouseType.HOUSE)[source]¶ Gets the URL to the house list on Tibia.com with the specified parameters.
Parameters: Returns: The URL to the list matching the parameters.
Return type:
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
-
class
tibiapy.abc.
BaseHouseWithId
[source]¶ A derivative of
BaseHouse
Implements the
id
attribute and dependant functions and properties.The following implement this class:
-
status
¶ HouseStatus
– The current status of the house.
-
type
¶ HouseType
– The type of the house.
-
classmethod
get_list_url
(world, town, house_type: tibiapy.enums.HouseType = HouseType.HOUSE, status: tibiapy.enums.HouseStatus = None, order=HouseOrder.NAME)¶ Gets the URL to the house list on Tibia.com with the specified parameters.
Parameters: - world (
str
) – The name of the world. - town (
str
) – The name of the town. - house_type (
HouseType
) – Whether to search for houses or guildhalls. - status (
HouseStatus
, optional) – The house status to filter results. By default no filters will be applied. - order (
HouseOrder
, optional) – The ordering to use for the results. By default they are sorted by name.
Returns: The URL to the list matching the parameters.
Return type: - world (
-
classmethod
get_list_url_tibiadata
(world, town, house_type: tibiapy.enums.HouseType = HouseType.HOUSE)¶ Gets the URL to the house list on Tibia.com with the specified parameters.
Parameters: Returns: The URL to the list matching the parameters.
Return type:
-
classmethod
get_url
(house_id, world)¶ Gets the Tibia.com URL for a house with the given id and world.
Parameters: Returns: Return type: The URL to the house in Tibia.com
-
classmethod
get_url_tibiadata
(house_id, world)¶ Gets the TibiaData.com URL for a house with the given id and world.
Parameters: Returns: Return type: The URL to the house in TibiaData.com
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
-
class
tibiapy.abc.
BaseNews
[source]¶ Base class for all news classes
Implements the
id
attribute and common properties.The following implement this class:
-
category
¶ NewsCategory
– The category this belongs to.
-
date
¶ datetime.date
– The date when the news were published.
-
classmethod
get_url
(news_id)[source]¶ Gets the Tibia.com URL for a news entry by its id.
Parameters: news_id ( int
) – The id of the news entry.Returns: The URL to the news’ page Return type: str
-
classmethod
get_list_url
()[source]¶ Gets the URL to Tibia.com’s news archive page.
Notes
It is not possible to perform a search using query parameters. News searches can only be performed using POST requests sending the parameters as form-data.
Returns: The URL to the news archive page on Tibia.com. Return type: str
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
-
class
tibiapy.abc.
BaseWorld
[source]¶ Base class for all World classes.
The following implement this class:
-
location
¶ WorldLocation
– The physical location of the game servers.
-
pvp_type
¶ PvpType
– The type of PvP in the world.
-
transfer_type
¶ TransferType
– The type of transfer restrictions this world has.
-
battleye_date
¶ datetime.date
– The date when BattlEye was added to this world. If this isNone
and the world is protected, it means the world was protected from the beginning.
-
tournament_world_type
¶ TournamentWorldType
– The type of tournament world.None
if this is not a tournament world.
bool
– Whether only premium account players are allowed to play in this server.
-
classmethod
get_url
(name)[source]¶ Gets the URL to the World’s information page on Tibia.com.
Parameters: name ( str
) – The name of the world.Returns: The URL to the world’s information page. Return type: str
-
classmethod
get_url_tibiadata
(name)[source]¶ Gets the URL to the World’s information page on TibiaData.com.
Parameters: name ( str
) – The name of the world.Returns: The URL to the world’s information page on TibiaData.com. Return type: str
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
Parameters: Returns: JSON representation of the object.
Return type:
-
-
class
tibiapy.abc.
Serializable
[source]¶ Contains methods to make a class convertible to JSON.
Note
There’s no way to convert JSON strings back to their original object.Attempting to do so may result in data loss.
Exceptions¶
-
class
tibiapy.
TibiapyException
[source]¶ Base exception for the tibiapy module.
All exceptions thrown by the module are inherited from this.
-
class
tibiapy.
InvalidContent
[source]¶ Exception thrown when the provided content is unrelated for the calling function.
This usually means that the content provided belongs to a different website or section of the website. This serves as a way to differentiate those cases from a parsing that returned no results (e.g. Character not found)
In some cases this can mean that Tibia.com’s format has changed and the library needs updating.
-
class
tibiapy.
NetworkError
(message, original=None)[source]¶ Exception thrown when there was a network error trying to fetch a resource from the web.
-
class
tibiapy.
Forbidden
(message, original=None)[source]¶ A subclass of network error thrown when Tibia.com returns a 403 status code.
Tibia.com returns a 403 status code when it detects that too many requests are being done. This has its own subclass to let the user decide to treat this differently than other network errors.
Utility functions¶
These are functions used thorough the module and are not intended for public use.
-
tibiapy.utils.
parse_integer
(number: str, default=0)[source]¶ Parses a string representing an integer, ignoring commas or periods.
Parameters: Returns: The represented integer, or the default value if invalid.
Return type:
-
tibiapy.utils.
parse_tibia_datetime
(datetime_str) → Optional[datetime.datetime][source]¶ Parses date and time from the format used in Tibia.com
Accepted format:
MMM DD YYYY, HH:mm:ss ZZZ
, e.g.Dec 10 2018, 21:53:37 CET
.
Parameters: datetime_str ( str
) – The date and time as represented in Tibia.comReturns: The represented datetime, in UTC. Return type: datetime.datetime
, optional
-
tibiapy.utils.
parse_tibia_date
(date_str) → Optional[datetime.date][source]¶ Parses a date from the format used in Tibia.com
Accepted format:
MMM DD YYYY
, e.g.Jul 23 2015
Parameters: date_str ( str
) – The date as represented in Tibia.comReturns: The represented date. Return type: datetime.date
, optional
-
tibiapy.utils.
parse_tibia_full_date
(date_str) → Optional[datetime.date][source]¶ Parses a date in the fuller format used in Tibia.com
Accepted format:
MMMM DD, YYYY
, e.g.July 23, 2015
Parameters: date_str ( str
) – The date as represented in Tibia.comReturns: The represended date. Return type: datetime.date
, optional
-
tibiapy.utils.
parse_tibiadata_datetime
(date_dict) → Optional[datetime.datetime][source]¶ Parses time objects from the TibiaData API.
- Time objects are made of a dictionary with three keys:
- date: contains a string representation of the time timezone: a string representation of the timezone the date time is based on timezone_type: the type of representation used in the timezone key
Parameters: date_dict ( dict
) – Dictionary representing the time object.Returns: The represented datetime, in UTC. Return type: datetime.date
, optional
-
tibiapy.utils.
parse_tibiadata_date
(date_str) → Optional[datetime.date][source]¶ Parses a date from the format used in TibiaData.
Parameters: date_str ( str
) – The date as represented in Tibia.comReturns: The represended date. Return type: datetime.date
, optional
-
tibiapy.utils.
parse_number_words
(text_num)[source]¶ Parses the word representation of a number to a integer.
Parameters: text_num ( str
) – The text representation of a number.Returns: The number represented by the string. Return type: int
-
tibiapy.utils.
try_datetime
(obj) → Optional[datetime.datetime][source]¶ Attempts to convert an object into a datetime.
If the date format is known, it’s recommended to use the corresponding function This is meant to be used in constructors.
Parameters: obj ( str
,dict
,datetime.datetime
) – The object to convert.Returns: The represented datetime, or None
if conversion wasn’t possible.Return type: datetime.datetime
, optional
-
tibiapy.utils.
try_date
(obj) → Optional[datetime.date][source]¶ Attempts to convert an object into a date.
If the date format is known, it’s recommended to use the corresponding function This is meant to be used in constructors.
Parameters: obj ( str
,datetime.datetime
,datetime.date
) – The object to convert.Returns: The represented date. Return type: datetime.date
, optional
-
tibiapy.utils.
parse_tibiacom_content
(content, *, html_class='BoxContent', tag='div', builder='lxml')[source]¶ Parses HTML content from Tibia.com into a BeautifulSoup object.
Parameters: Returns: The parsed content.
Return type: bs4.BeautifulSoup
, optional
-
tibiapy.utils.
try_enum
(cls: Type[T], val, default: D = None) → Union[T, D][source]¶ Attempts to convert a value into their enum value
Parameters: - cls (
Enum
) – The enum to convert to. - val – The value to try to convert to Enum
- default (optional) – The value to return if no enum value is found.
Returns: The enum value if found, otherwise None.
Return type: obj
- cls (
-
tibiapy.utils.
parse_json
(content)[source]¶ Tries to parse a string into a json object.
This also performs a trim of all values, recursively removing leading and trailing whitespace.
Parameters: content ( str
) – A JSON format string.Returns: The object represented by the json string. Return type: obj Raises: InvalidContent
– If the content is not a valid json string.