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.
Enumerations¶
Enumerations are provided for various values in order to avoid depending on strings.
-
class
tibiapy.
HouseType
[source]¶ The types of house available.
-
HOUSE
= 'house'¶
-
GUILDHALL
= 'guildhall'¶
-
-
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.
HouseStatus
[source]¶ Renting statuses of a house.
-
RENTED
= 'rented'¶
-
AUCTIONED
= 'auctioned'¶
-
-
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.
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
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.
-
house
¶ CharacterHouse
, optional – The house 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.
-
achievements
¶ list
ofAchievement
– The achievements chosen to 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.
-
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
-
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.
-
vocation
¶ VocationFilter
– The selected vocation to filter out values.
-
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: '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: '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_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:
-
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
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
-
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
-
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: '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:
-
classmethod
get_list_url_tibiadata
(world, town, house_type: tibiapy.enums.HouseType = <HouseType.HOUSE: '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:
-
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:
-
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.
-
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:
-
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.
-
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.
-
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.
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¶
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_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 a entry for the highscores’s experience category.
-
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_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
-
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.
-
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)[source]¶ Represents other character’s 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
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
-
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
-
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_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.
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.
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.
Utility functions¶
-
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.
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 (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.