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.
Changed in version 3.0.0: All methods return a
TibiaResponse
instance, containing additional information such as cache age.-
loop
¶ The event loop to use. The default one will be used if not defined.
-
session
¶ The client session that will be used for the requests. One will be created by default.
-
proxy_url
¶ 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.
- Type
-
async
fetch_current_auctions
(page=1, filters=None)[source]¶ Fetches the current auctions in the bazaar
New in version 3.3.0.
- Parameters
page (
int
) – The desired page to display.filters (
AuctionFilters
) – The filtering criteria to use.
- Returns
The current auctions.
- 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.
ValueError – If the page number is not 1 or greater.
-
async
fetch_auction_history
(page=1)[source]¶ Fetches the auction history of the bazaar.
New in version 3.3.0.
- Parameters
page (
int
) – The page to display.- Returns
The character bazaar containing the auction history.
- 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.
ValueError – If the page number is not 1 or greater.
-
async
fetch_auction
(auction_id, *, fetch_items=False, fetch_mounts=False, fetch_outfits=False, skip_details=False)[source]¶ Fetches an auction by its ID.
New in version 3.3.0.
- Parameters
auction_id (
int
) – The ID of the auction.fetch_items (
bool
) – Whether to fetch all of the character’s items. By default only the first page is fetched.fetch_mounts (
bool
) – Whether to fetch all of the character’s mounts. By default only the first page is fetched.fetch_outfits (
bool
) – Whether to fetch all of the character’s outfits. By default only the first page is fetched.skip_details (
bool
, optional) –Whether to skip parsing the entire auction and only parse the information shown in lists. False by default.
This allows fetching basic information like name, level, vocation, world, bid and status, shaving off some parsing time.
- Returns
The auction matching the ID 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.
ValueError – If the auction id is not 1 or greater.
-
async
fetch_cm_post_archive
(start_date, end_date, page=1)[source]¶ Fetches the CM post archive.
New in version 3.0.0.
- Parameters
start_date – The start date to display.
end_date – The end date to display.
page (
int
) – The desired page to display.
- Returns
The CM Post Archive.
- 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.
ValueError – If the start_date is more recent than the end date or page number is not 1 or greater.
-
async
fetch_event_schedule
(month=None, year=None)[source]¶ Fetches the event calendar. By default, it gets the events for the current month.
New in version 3.0.0.
- Parameters
- Returns
The event calendar.
- 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.
ValueError – If only one of year or month are defined.
-
async
fetch_forum_community_boards
()[source]¶ Fetches the forum’s community boards.
New in version 3.0.0.
- Returns
The forum boards in the community section.
- Return type
TibiaResponse
of list ofListedBoard
- 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.
-
async
fetch_forum_support_boards
()[source]¶ Fetches the forum’s community boards.
New in version 3.0.0.
- Returns
The forum boards in the community section.
- Return type
TibiaResponse
of list ofListedBoard
- 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.
-
async
fetch_forum_world_boards
()[source]¶ Fetches the forum’s world boards.
New in version 3.0.0.
- Returns
The forum boards in the world section.
- Return type
TibiaResponse
of list ofListedBoard
- 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.
-
async
fetch_forum_trade_boards
()[source]¶ Fetches the forum’s trade boards.
New in version 3.0.0.
- Returns
The forum boards in the trade section.
- Return type
TibiaResponse
of list ofListedBoard
- 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.
-
async
fetch_forum_board
(board_id, page=1, age=30)[source]¶ Fetches a forum board with a given id.
New in version 3.0.0.
- Parameters
- Returns
A response containing the forum, 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.
-
async
fetch_forum_thread
(thread_id, page=1)[source]¶ Fetches a forum thread with a given id.
New in version 3.0.0.
- Parameters
- Returns
A response containing the forum, 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.
-
async
fetch_forum_post
(post_id)[source]¶ Fetches a forum post with a given id.
The thread that contains the post will be returned, containing the desired post in
ForumThread.anchored_post
.The displayed page will be the page where the post is located.
New in version 3.1.0.
- Parameters
post_id (
int
) – The id of the post.- Returns
A response containing the forum, 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.
-
async
fetch_forum_announcement
(announcement_id)[source]¶ Fetches a forum announcement.
New in version 3.0.0.
- Parameters
announcement_id (
int
) – The id of the desired announcement.- Returns
The forum announcement, 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.
-
async
fetch_boosted_creature
()[source]¶ Fetches today’s boosted creature.
New in version 2.1.0.
Changed in version 4.0.0: The return type of the data returned was changed to
Creature
, previous type was removed.- 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.
-
async
fetch_library_creatures
()[source]¶ Fetches the creatures from the library section.
New in version 4.0.0.
- Returns
The creature’s section in Tibia.com
- 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.
-
async
fetch_creature
(race)[source]¶ Fetches a creature’s information from the Tibia.com library.
New in version 4.0.0.
- Parameters
race (
str
) – The internal name of the race.- Returns
The creature’s section in Tibia.com
- 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.
-
async
fetch_character
(name)[source]¶ Fetches a character by its name from Tibia.com
- Parameters
name (
str
) – The name of the character.- Returns
A response containing the character, 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.
-
async
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
A response containing the found guild, if any.
- 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.
-
async
fetch_guild_wars
(name)[source]¶ Fetches a guild’s wars by its name from Tibia.com
New in version 3.0.0.
- Parameters
name (
str
) – The name of the guild. The case must match exactly.- Returns
A response containing the found guild’s wars.
If the guild doesn’t exist, the displayed data will show a guild with no wars instead of indicating the guild doesn’t exist.
- 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.
-
async
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.
-
async
fetch_highscores_page
(world=None, category=Category.EXPERIENCE, vocation=VocationFilter.ALL, page=1, battleye_type=None, pvp_types=None)[source]¶ Fetches a single highscores page from Tibia.com
Notes
It is not possible to use BattlEye or PvPType filters when requesting a specific world.
- 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.battleye_type (
BattlEyeFilter
) – The type of BattlEye protection to display results from.pvp_types (
list
ofPvpTypeFilter
) – The list of PvP types to filter the results for.
- 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.
ValueError – If an invalid filter combination is passed.
-
async
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.
-
async
fetch_world
(name)[source]¶ Fetches a world from Tibia.com
- Parameters
name (
str
) – The name of the world.- Returns
A response containig the he 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.
-
async
fetch_world_houses
(world, town, house_type=HouseType.HOUSE, status: Optional[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
A response containing the lists of houses meeting the criteria if found.
- Return type
TibiaResponse
of list ofListedHouse
- 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.
-
async
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
A response containing the lists of guilds in the world.
- Return type
TibiaResponse
of list ofListedGuild
- 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.
-
async
fetch_world_list
()[source]¶ Fetches the world overview information from Tibia.com.
- Returns
A response containing 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.
-
async
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
TibiaResponse
of list ofListedNews
- 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.
-
async
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
TibiaResponse
of list ofListedNews
- 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.
-
async
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.
-
async
fetch_tournament
(tournament_cycle=0)[source]¶ Fetches a tournament from Tibia.com
New in version 2.5.0.
- Parameters
tournament_cycle (
int
) – The cycle of the tournament. if unspecified, it will get the currently running tournament.- Returns
The tournament 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.
-
async
fetch_tournament_leaderboard
(tournament_cycle, world, page=1)[source]¶ Fetches a tournament leaderboard from Tibia.com
New in version 2.5.0.
- Parameters
- Returns
The tournament’s leaderboard 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.
-
-
class
tibiapy.
TibiaResponse
(raw_response, data: T, parsing_time=None)[source]¶ Represents a response from Tibia.com
-
timestamp
¶ The date and time when the page was fetched, in UTC.
- Type
-
data
¶ The data contained in the response.
- Type
T
-
property
time_left
¶ The time left for the cache of this response to expire.
- Type
-
Enumerations¶
Enumerations are provided for various values in order to avoid depending on strings.
-
class
tibiapy.
AccountStatus
(value)[source]¶ Possible account statuses.
-
FREE_ACCOUNT
= 'Free Account'¶
-
PREMIUM_ACCOUNT
= 'Premium Account'¶
-
-
class
tibiapy.
AuctionOrder
(value)[source]¶ The possible ordering directions for auctions.
The field or value used for the ordering is defined by
AuctionOrderBy
.-
HIGHEST_LATEST
= 0¶ Order by the highest or latest value.
-
LOWEST_EARLIEST
= 1¶ Order by the lowest or earliest value.
-
-
class
tibiapy.
AuctionOrderBy
(value)[source]¶ The possible values to order the auctions by.
-
BID
= 100¶ The currently displayed bid for the auction.
-
END_DATE
= 101¶ The end date of the auction.
-
LEVEL
= 102¶ The experience level of the auctioned character.
-
START_DATE
= 103¶ The start date of the auction.
-
AXE_FIGHTING
= 10¶
-
CLUB_FIGHTING
= 9¶
-
DISTANCE_FIGHTING
= 7¶
-
FISHING
= 13¶
-
FIST_FIGHTING
= 11¶
-
MAGIC_LEVEL
= 1¶
-
SHIELDING
= 6¶
-
SWORD_FIGHTING
= 8¶
-
-
class
tibiapy.
AuctionSearchType
(value)[source]¶ The possible search types.
-
ITEM_DEFAULT
= 0¶ Searches everything that includes the words on the search string.
-
ITEM_WILDCARD
= 1¶ Searches everything that includes the search string
-
CHARACTER_NAME
= 2¶ Searches a character’s name.
-
-
class
tibiapy.
AuctionStatus
(value)[source]¶ The possible values an auction might have.
-
IN_PROGRESS
= 'in progress'¶ The auction is currently active.
Notes
This status doesn’t exist in Tibia.com explicitly. It is given to all ongoing auctions.
-
CURRENTLY_PROCESSED
= 'currently processed'¶ The auction ended with a winner, but payment hasn’t been received yet.
-
PENDING_TRANSFER
= 'will be transferred at the next server save'¶ The auction was finished and was paid, but the character hasn’t been transferred to the new owner yet.
-
CANCELLED
= 'cancelled'¶ The auction was cancelled as no payment was received in time.
-
FINISHED
= 'finished'¶ The auction either finished with no bids or the character was transferred to the new owner already.
-
-
class
tibiapy.
BattlEyeType
(value)[source]¶ The possible BattlEye statuses a world can have.
New in version 4.0.0.
-
UNPROTECTED
= 0¶ Worlds without any BattlEye protection.
-
PROTECTED
= 1¶ Worlds protected after the world was created, represented by a yellow symbol.
-
INITIALLY_PROTECTED
= 2¶ Worlds protected from the beginning, represented by a green symbol.
-
YELLOW
= 1¶ Alias for protected worlds.
-
GREEN
= 2¶ Alias for initially protected worlds.
-
-
class
tibiapy.
BattlEyeHighscoresFilter
(value)[source]¶ The possible BattlEye filters that can be used for highscores.
-
INITIALLY_PROTECTED
= 2¶ Worlds protected from the beginning, represented by a green symbol.
-
PROTECTED
= 1¶ Worlds protected after the world was created, represented by a yellow symbol.
-
UNPROTECTED
= 0¶ Worlds without any BattlEye protection.
-
YELLOW
= 1¶ Alias for protected worlds.
New in version 4.0.0.
-
GREEN
= 2¶ Alias for initially protected worlds.
New in version 4.0.0.
-
-
class
tibiapy.
BattlEyeTypeFilter
(value)[source]¶ The possible BattlEye filters that can be used for auctions.
-
INITIALLY_PROTECTED
= 1¶ Worlds protected from the beginning, represented by a green symbol.
-
PROTECTED
= 2¶ Worlds protected after the world was created, represented by a yellow symbol.
-
NOT_PROTECTED
= 3¶ Worlds without any BattlEye protection.
-
YELLOW
= 2¶ Alias for protected worlds.
New in version 4.0.0.
-
GREEN
= 1¶ Alias for initially protected worlds.
New in version 4.0.0.
-
-
class
tibiapy.
BazaarType
(value)[source]¶ The possible bazaar types.
-
CURRENT
= 'Current Auctions'¶
-
HISTORY
= 'Auction History'¶
-
-
class
tibiapy.
BidType
(value)[source]¶ The possible bid types for an auction.
-
MINIMUM
= 'Minimum Bid'¶ The minimum bid set by the auction author, meaning the auction hasn’t received any bids or it finished without bids.
-
CURRENT
= 'Current Bid'¶ The current maximum bid, meaning the auction has received at least one bid.
-
WINNING
= 'Winning Bid'¶ The bid that won the auction.
-
-
class
tibiapy.
Category
(value)[source]¶ The different highscores categories.
-
ACHIEVEMENTS
= 1¶
-
AXE_FIGHTING
= 2¶
-
CHARM_POINTS
= 3¶
-
CLUB_FIGHTING
= 4¶
-
DISTANCE_FIGHTING
= 5¶
-
EXPERIENCE
= 6¶
-
FISHING
= 7¶
-
FIST_FIGHTING
= 8¶
-
GOSHNARS_TAINT
= 9¶
-
LOYALTY_POINTS
= 10¶
-
MAGIC_LEVEL
= 11¶
-
SHIELDING
= 12¶
-
SWORD_FIGHTING
= 13¶
-
-
class
tibiapy.
HouseOrder
(value)[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
(value)[source]¶ Renting statuses of a house.
-
RENTED
= 'rented'¶
-
AUCTIONED
= 'auctioned'¶
-
-
class
tibiapy.
HouseType
(value)[source]¶ The types of house available.
-
HOUSE
= 'house'¶
-
GUILDHALL
= 'guildhall'¶
-
-
class
tibiapy.
NewsCategory
(value)[source]¶ The different news categories.
-
CIPSOFT
= 'cipsoft'¶
-
COMMUNITY
= 'community'¶
-
DEVELOPMENT
= 'development'¶
-
SUPPORT
= 'support'¶
-
TECHNICAL_ISSUES
= 'technical'¶
-
-
class
tibiapy.
NewsType
(value)[source]¶ The different types of new entries.
-
NEWS_TICKER
= 'News Ticker'¶
-
FEATURED_ARTICLE
= 'Featured Article'¶
-
NEWS
= 'News'¶
-
-
class
tibiapy.
PvpTypeFilter
(value)[source]¶ The possible PVP filters that can be used for auctions.
-
OPEN_PVP
= 0¶
-
OPTIONAL_PVP
= 1¶
-
HARDCORE_PVP
= 2¶
-
RETRO_OPEN_PVP
= 3¶
-
RETRO_HARDCORE_PVP
= 4¶
-
-
class
tibiapy.
PvpType
(value)[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.
SkillFilter
(value)[source]¶ The different skill filters for auctions.
-
AXE_FIGHTING
= 10¶
-
CLUB_FIGHTING
= 9¶
-
DISTANCE_FIGHTING
= 7¶
-
FISHING
= 13¶
-
FIST_FIGHTING
= 11¶
-
MAGIC_LEVEL
= 1¶
-
SHIELDING
= 6¶
-
SWORD_FIGHTING
= 8¶
-
-
class
tibiapy.
ThreadStatus
(value)[source]¶ The possible status a thread can have.
Threads can have a combination of multiple status. The numeric values are arbitrary.
-
NONE
= 0¶
-
HOT
= 1¶ Thread has more than 16 replies.
-
NEW
= 2¶ Thread has new posts since last visit.
-
CLOSED
= 4¶ Thread is closed.
-
STICKY
= 8¶ Thread is stickied.
-
get_icon_name
()[source]¶ Generates an icon name, following the same ordering used in Tibia.com
- Returns
The name of the icon used in Tibia.com
- Return type
-
-
class
tibiapy.
TournamentWorldType
(value)[source]¶ The possible types of tournament worlds.
-
REGUlAR
= 'Regular'¶
-
RESTRICTED
= 'Restricted Store'¶
-
-
class
tibiapy.
TournamentPhase
(value)[source]¶ The possible tournament phases.
-
SIGN_UP
= 'sign up'¶
-
RUNNING
= 'running'¶
-
ENDED
= 'ended'¶
-
-
class
tibiapy.
TransferType
(value)[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
(value)[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.
VocationAuctionFilter
(value)[source]¶ The possible vocation filters for auctions.
-
NONE
= 1¶
-
DRUID
= 2¶
-
KNIGHT
= 3¶
-
PALADIN
= 4¶
-
SORCERER
= 5¶
-
-
class
tibiapy.
VocationFilter
(value)[source]¶ The vocation filters available for Highscores.
The numeric values are what the highscores form accepts.
-
ALL
= 0¶
-
NONE
= 1¶
-
KNIGHTS
= 2¶
-
PALADINS
= 3¶
-
SORCERERS
= 4¶
-
DRUIDS
= 5¶
-
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
-
Characters¶
The Character section consists of the Character
class and its auxiliary classes used to hold its data.
The entry points for this are:
Character.from_content()
- Parsing a character’s content.Client.fetch_character()
- Fetching and parsing a character’s content.
Character¶
-
class
tibiapy.
Character
(name=None, world=None, vocation=None, level=0, sex=None, **kwargs)[source]¶ Represents a Tibia character.
-
deletion_date
¶ The date when the character will be deleted if it is scheduled for deletion.
- Type
datetime.datetime
, optional
-
houses
¶ The houses currently owned by the character.
- Type
-
guild_membership
¶ The guild the character is a member of.
- Type
GuildMembership
, optional
-
last_login
¶ The last time the character logged in. It will be
None
if the character has never logged in.- Type
datetime.datetime
, optional
-
account_status
¶ Whether the character’s account is Premium or Free.
- Type
-
account_badges
¶ The displayed account badges.
- Type
list
ofAccountBadge
-
achievements
¶ The achievements chosen to be displayed.
- Type
list
ofAchievement
-
deaths_truncated
¶ 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.
- Type
-
account_information
¶ The character’s account information, if visible.
- Type
AccountInformation
, optional
-
other_characters
¶ Other characters in the same account.
It will be empty if the character is hidden, otherwise, it will contain at least the character itself.
- Type
Whether this is a hidden character or not.
- Type
-
property
married_to_url
¶ The URL to the husband/spouse information page on Tibia.com, if applicable.
- Type
-
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
- Raises
InvalidContent – If content is not the HTML of a character’s page.
-
classmethod
get_url
(name)¶ Gets the Tibia.com URL for a given character name.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
Auxiliary Classes¶
AccountBadge¶
AccountInformation¶
-
class
tibiapy.
AccountInformation
(created, loyalty_title=None, position=None)[source]¶ Represents the account information of a character.
This is only visible if the character is not marked as hidden.
-
created
¶ The date when the account was created.
- Type
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
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
¶ The current status of the house.
- Type
-
paid_until_date
¶ The date the last paid rent is due.
- Type
-
classmethod
get_list_url
(world, town, house_type: tibiapy.enums.HouseType = HouseType.HOUSE, status: Optional[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
-
classmethod
get_url
(house_id, world)¶ Gets the Tibia.com URL for a house with the given id and world.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
Death¶
-
class
tibiapy.
Death
(name=None, level=0, **kwargs)[source]¶ Represents a death by a character
-
time
¶ The time at which the death occurred.
- Type
-
property
killer
¶ The first killer in the list.
This is usually the killer that gave the killing blow.
- Type
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
GuildMembership¶
-
class
tibiapy.
GuildMembership
(name, rank, title=None)[source]¶ Represents the guild information of a character.
-
classmethod
get_url
(name)¶ Gets the Tibia.com URL for a given guild name.
-
classmethod
get_url_wars
(name)¶ Gets the Tibia.com URL for the guild wars of a guild with a given name.
New in version 3.0.0.
-
classmethod
get_world_list_url
(world)¶ Gets the Tibia.com URL for the guild section of a specific world.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
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.
-
property
url
¶ The URL of the character’s information page on Tibia.com, if applicable.
- Type
str
, optional
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
OtherCharacter¶
-
class
tibiapy.
OtherCharacter
(name, world, online=False, deleted=False, main=False, position=None, traded=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.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
classmethod
Worlds¶
Models related to Tibia.com’s World section. The WorldOverview
class contains the list of all worlds, while
the World
class contains the details of a single world.
WorldOverview¶
-
class
tibiapy.
WorldOverview
(**kwargs)[source]¶ Container class for the World Overview section.
-
record_date
¶ The date when the record was achieved.
- Type
-
worlds
¶ List of worlds, with limited info.
- Type
list
ofListedWorld
-
property
tournament_worlds
¶ List of tournament worlds.
Note that tournament worlds are not listed when there are no active or upcoming tournaments.
- Type
list
ofGuildMember
-
property
regular_worlds
¶ List of worlds that are not tournament worlds.
- Type
list
ofListedWorld
-
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
-
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.com- Returns
An instance of this class containing all the information.
- Return type
- Raises
InvalidContent – If the provided content is not the HTML content of the worlds section in Tibia.com
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
ListedWorld¶
-
class
tibiapy.
ListedWorld
(name, location=None, pvp_type=None, **kwargs)[source]¶ Represents a game server listed in the World Overview section.
-
location
¶ The physical location of the game servers.
- Type
-
transfer_type
¶ The type of transfer restrictions this world has.
- Type
-
battleye_date
¶ The date when BattlEye was added to this world. If this is
None
and the world is protected, it means the world was protected from the beginning.- Type
-
battleye_type
¶ The type of BattlEye protection this world has.
New in version 4.0.0.
- Type
Whether only premium account players are allowed to play in this server.
- Type
-
property
battleye_protected
¶ Whether the server is currently protected with BattlEye or not.
Changed in version 4.0.0: Now a calculated property instead of a field.
- Type
-
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
-
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.com- Returns
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
get_url
(name)¶ Gets the URL to the World’s information page on Tibia.com.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
World¶
-
class
tibiapy.
World
(name, location=None, pvp_type=None, **kwargs)[source]¶ Represents a Tibia game server.
-
record_date
¶ The date when the online record was achieved.
- Type
-
location
¶ The physical location of the game servers.
- Type
-
transfer_type
¶ The type of transfer restrictions this world has.
- Type
-
battleye_date
¶ The date when BattlEye was added to this world. If this is
None
and the world is protected, it means the world was protected from the beginning.- Type
-
battleye_type
¶ The type of BattlEye protection this world has.
New in version 4.0.0.
- Type
-
online_players
¶ A list of characters currently online in the server.
- Type
list
ofOnlineCharacter
.
Whether only premium account players are allowed to play in this server.
- Type
-
property
battleye_protected
¶ Whether the server is currently protected with BattlEye or not.
Changed in version 4.0.0: Now a calculated property instead of a field.
- Type
-
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
- Raises
InvalidContent – If the provided content is not the HTML content of the world section in Tibia.com
-
classmethod
get_url
(name)¶ Gets the URL to the World’s information page on Tibia.com.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
Guilds¶
Models related to Tibia.com’s Guilds section. The main model is Guild
, while ListedGuild
is the
previewed information in the guild list.
Guild¶
-
class
tibiapy.
Guild
(name=None, world=None, **kwargs)[source]¶ Represents a Tibia guild.
-
founded
¶ The day the guild was founded.
- Type
-
guildhall
¶ The guild’s guildhall if any.
- Type
GuildHouse
, optional
-
disband_date
¶ The date when the guild will be disbanded if the condition hasn’t been meet.
- Type
datetime.datetime
, optional
-
members
¶ List of guild members.
- Type
list
ofGuildMember
-
invites
¶ List of invited characters.
- Type
list
ofGuildInvite
-
property
online_members
¶ List of currently online members.
- Type
list
ofGuildMember
-
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
- Raises
InvalidContent – If content is not the HTML of a guild’s page.
-
classmethod
get_url
(name)¶ Gets the Tibia.com URL for a given guild name.
-
classmethod
get_url_wars
(name)¶ Gets the Tibia.com URL for the guild wars of a guild with a given name.
New in version 3.0.0.
-
classmethod
get_world_list_url
(world)¶ Gets the Tibia.com URL for the guild section of a specific world.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
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
get_url
(name)¶ Gets the Tibia.com URL for a given guild name.
-
classmethod
get_url_wars
(name)¶ Gets the Tibia.com URL for the guild wars of a guild with a given name.
New in version 3.0.0.
-
classmethod
get_world_list_url
(world)¶ Gets the Tibia.com URL for the guild section of a specific world.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
classmethod
Auxiliary Classes¶
GuildInvite¶
GuildHouse¶
-
class
tibiapy.
GuildHouse
(name, world=None, owner=None, paid_until_date=None)[source]¶ Represents a House owned by a guild.
-
status
¶ The current status of the house.
- Type
-
paid_until_date
¶ The date the last paid rent is due.
- Type
-
classmethod
get_list_url
(world, town, house_type: tibiapy.enums.HouseType = HouseType.HOUSE, status: Optional[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
-
classmethod
get_url
(house_id, world)¶ Gets the Tibia.com URL for a house with the given id and world.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
GuildMember¶
-
class
tibiapy.
GuildMember
(name=None, rank=None, title=None, level=0, vocation=None, **kwargs)[source]¶ Represents a guild member.
-
joined
¶ The day the member joined the guild.
- Type
-
classmethod
get_url
(name)¶ Gets the Tibia.com URL for a given character name.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
GuildWars¶
-
class
tibiapy.
GuildWars
(name, current=None, history=None)[source]¶ Represents a guild’s wars.
New in version 3.0.0.
-
current
¶ The current war the guild is involved in.
- Type
-
history
¶ The previous wars the guild has been involved in.
- Type
-
classmethod
get_url
(name)[source]¶ Gets the URL to the guild’s war page of a guild with the given name.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
GuildWarEntry¶
-
class
tibiapy.
GuildWarEntry
(**kwargs)[source]¶ Represents a guild war entry.
New in version 3.0.0.
-
opponent_name
¶ The name of the opposing guild. If the guild no longer exist, this will be
None
.- Type
-
start_date
¶ The date when the war started.
When a war is in progress, the start date is not visible.
- Type
-
duration
¶ The set duration of the war.
When a war is in progress, the duration is not visible.
- Type
-
end_date
¶ The deadline for the war to finish if the score is not reached for wars in progress, or the date when the war ended.
- Type
-
winner
¶ The name of the guild that won.
Note that if the winning guild is disbanded, this may be
None
.- Type
-
property
opponent_guild_url
¶ The URL to the opposing guild’s information page on Tibia.com.
- Type
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
Highscores¶
Models related to Tibia.com’s Highscores section.
Highscores¶
-
class
tibiapy.
Highscores
(world, category=Category.EXPERIENCE, **kwargs)[source]¶ Represents the highscores of a world.
New in version 1.1.0.
-
world
¶ The world the highscores belong to. If this is
None
, the highscores shown are for all worlds.- Type
-
vocation
¶ The selected vocation to filter out values.
- Type
-
battleye_filter
¶ The selected BattlEye filter. If
None
, all worlds will be displayed.Only applies for global highscores. Only characters from worlds with the matching BattlEye protection will be shown.
-
pvp_types_filter
¶ The selected PvP types filter. If
None
, all world will be displayed.Only applies for global highscores. Only characters from worlds with the matching PvP type will be shown.
- Type
-
results_count
¶ The total amount of highscores entries in this category. These may be shown in another page.
- Type
-
last_updated
¶ How long ago were this results updated. The resolution is 1 minute.
- Type
-
entries
¶ The highscores entries found.
- Type
-
property
previous_page_url
¶ The URL to the previous page of the current highscores, if there’s any.
- Type
-
property
next_page_url
¶ The URL to the next page of the current highscores, if there’s any.
- Type
-
get_page_url
(page)[source]¶ Gets the URL to a specific page for the current highscores.
- Parameters
page (
int
) – The page to get the URL for.- Returns
The URL to the page of the current highscores.
- Return type
- Raises
ValueError – The provided page is less or equals than zero.
-
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 50 entries per page, so in order to obtain the full highscores, all pages must be obtained individually and merged into one.
- Parameters
content (
str
) – The HTML content of the page.- Returns
The highscores results contained in the page.
- Return type
- Raises
InvalidContent – If content is not the HTML of a highscore’s page.
-
classmethod
get_url
(world=None, category=Category.EXPERIENCE, vocation=VocationFilter.ALL, page=1, battleye_type=None, pvp_types=None)[source]¶ Gets the Tibia.com URL of the highscores for the given parameters.
- Parameters
world (
str
, optional) – The game world of the desired highscores. If no world is passed, ALL worlds are shown.category (
Category
) – The desired highscores category.vocation (
VocationFilter
) – The vocation filter to apply. By default all vocations will be shown.page (
int
) – The page of highscores to show.battleye_type (
BattlEyeHighscoresFilter
, optional) – The battleEye filters to use.pvp_types (
list
ofPvpTypeFilter
, optional) – The list of PvP types to filter the results for.
- Returns
- Return type
The URL to the Tibia.com highscores.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
HighscoresEntry¶
LoyaltyHighscoresEntry¶
-
class
tibiapy.
LoyaltyHighscoresEntry
(rank, name, vocation, world, level, 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.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
classmethod
Houses¶
Models related to Tibia.com’s Houses section.
House¶
-
class
tibiapy.
House
(name, world=None, **kwargs)[source]¶ Represents a house in a specific world.
-
status
¶ The current status of the house.
- Type
-
paid_until
¶ The date the last paid rent is due.
- Type
datetime.datetime
, optional
-
transfer_date
¶ The date when the owner will move out of the house, if applicable.
- Type
datetime.datetime
, optional
-
transferee
¶ The character who will receive the house when the owner moves, if applicable.
- Type
str
, optional
-
transfer_price
¶ The price that will be paid from the transferee to the owner for the house transfer.
- Type
-
auction_end
¶ The date when the auction will end.
- Type
datetime.datetime
, optional
-
property
transferee_url
¶ The URL to the Tibia.com page of the character receiving the house, if applicable.
- Type
-
property
highest_bidder_url
¶ The URL to the Tibia.com page of the character with the highest bid, if applicable.
- Type
-
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
- Raises
InvalidContent – If the content is not the house section on Tibia.com
-
classmethod
get_list_url
(world, town, house_type: tibiapy.enums.HouseType = HouseType.HOUSE, status: Optional[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
-
classmethod
get_url
(house_id, world)¶ Gets the Tibia.com URL for a house with the given id and world.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
ListedHouse¶
-
class
tibiapy.
ListedHouse
(name, world, houseid, **kwargs)[source]¶ Represents a house from the house list in Tibia.com.
-
status
¶ The current status of the house.
- Type
-
time_left
¶ 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.
- Type
datetime.timedelta
, optional
-
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
get_list_url
(world, town, house_type: tibiapy.enums.HouseType = HouseType.HOUSE, status: Optional[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
-
classmethod
get_url
(house_id, world)¶ Gets the Tibia.com URL for a house with the given id and world.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
Tournaments¶
Models related to Tibia.com’s Tournaments section.
Tournament¶
-
class
tibiapy.
Tournament
(**kwargs)[source]¶ Represents a tournament’s information.
New in version 2.5.0.
-
cycle
¶ An internal number used to get direct access to a specific tournament in the archive.
This will only be present when viewing an archived tournament, otherwise it will default to 0.
- Type
-
phase
¶ The current phase of the tournament.
- Type
-
start_date
¶ The start date of the tournament.
- Type
-
end_date
¶ The end date of the tournament.
- Type
-
reward_set
¶ The list of rewards awarded for the specified ranges.
- Type
list
ofRewardEntry
-
archived_tournaments
¶ The list of other archived tournaments. This is only present when viewing an archived tournament.
- Type
-
property
duration
¶ The total duration of the tournament.
- Type
-
rewards_for_rank
(rank)[source]¶ Gets the rewards for a given rank, if any.
- Parameters
rank (
int
) – The rank to check.- Returns
The rewards for the given rank or None if there are no rewards.
- Return type
RewardEntry
, optional
-
classmethod
from_content
(content)[source]¶ Creates an instance of the class from the html content of the tournament’s page.
- Parameters
content (
str
) – The HTML content of the page.- Returns
The tournament contained in the page, or None if the tournament doesn’t exist.
- Return type
- Raises
InvalidContent – If content is not the HTML of a tournament’s page.
-
classmethod
get_url
(tournament_cycle)¶ Gets the URL to a tournament’s information page if its cycle is provided, otherwise it shows the current tournament.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
TournamentLeaderboard¶
-
class
tibiapy.
TournamentLeaderboard
(**kwargs)[source]¶ Represents a tournament’s leaderboards.
New in version 2.5.0.
-
tournament
¶ The tournament this leaderboard belongs to.
- Type
-
entries
¶ The leaderboard entries.
- Type
-
results_count
¶ The total number of leaderboard entries. These might be in a different page.
- Type
-
classmethod
get_url
(world, tournament_cycle, page=1)[source]¶ Gets the URL to the leaderboards of a specific world, tournament and page.
-
classmethod
from_content
(content)[source]¶ Creates an instance of the class from the html content of the tournament’s leaderboards page.
- Parameters
content (
str
) – The HTML content of the page.- Returns
The tournament contained in the page, or None if the tournament leaderboard doesn’t exist.
- Return type
- Raises
InvalidContent – If content is not the HTML of a tournament’s leaderboard page.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
Auxiliary Classes¶
ListedTournament¶
-
class
tibiapy.
ListedTournament
(title, start_date, end_date, **kwargs)[source]¶ Represents an tournament in the archived tournaments list.
start_date
andend_date
might beNone
when a tournament that is currently running is on the list (e.g. on the leaderboards tournament selection section).New in version 2.5.0.
-
cycle
¶ An internal number used to get direct access to a specific tournament in the archive.
- Type
-
start_date
¶ The start date of the tournament.
- Type
-
end_date
¶ The end date of the tournament.
- Type
-
property
duration
¶ The total duration of the tournament.
- Type
-
classmethod
get_url
(tournament_cycle)¶ Gets the URL to a tournament’s information page if its cycle is provided, otherwise it shows the current tournament.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
LeaderboardEntry¶
-
class
tibiapy.
LeaderboardEntry
(**kwargs)[source]¶ Represents a single tournament leaderboard’s entry.
New in version 2.5.0.
-
vocation
¶ The character’s vocation. This will always show the base vocation, without promotions.
- Type
-
classmethod
get_url
(name)¶ Gets the Tibia.com URL for a given character name.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
RewardEntry¶
RuleSet¶
-
class
tibiapy.
RuleSet
(**kwargs)[source]¶ Contains the tournament rule set.
-
pvp_type
¶ The PvP type of the tournament.
- Type
PvPType
-
daily_tournament_playtime
¶ The maximum amount of time participants can play each day.
- Type
-
total_tournament_playtime
¶ The total amount of time participants can play in the tournament.
- Type
-
playtime_reduced_only_in_combat
¶ Whether playtime will only be reduced while in combat or not.
- Type
Whether there is a bonus for sharing experience or not.
- Type
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
Forums¶
Models related to Tibia.com’s Forum section.
CMPostArchive¶
-
class
tibiapy.
CMPostArchive
(**kwargs)[source]¶ Represents the CM Post Archive.
The CM Post Archive is a collection of posts made in the forum by community managers.
New in version 3.0.0.
-
start_date
¶ The start date of the displayed posts.
- Type
-
end_date
¶ The end date of the displayed posts.
- Type
-
property
previous_page_url
¶ The URL to the previous page of the current CM Post Archive results, if there’s any.
- Type
-
property
next_page_url
¶ The URL to the next page of the current CM Post Archive results, if there’s any.
- Type
-
get_page_url
(page)[source]¶ Gets the URL of the CM Post Archive at a specific page, with the current date parameters.
-
classmethod
get_url
(start_date, end_date, page=1)[source]¶ Gets the URL to the CM Post Archive for the given date range.
- Parameters
start_date – The start date to display.
end_date – The end date to display.
page (
int
) – The desired page to display.
- Returns
The URL to the CM Post Archive
- Return type
- Raises
TypeError: – Either of the dates is not an instance of
datetime.date
ValueError: – If
start_date
is more recent thanend_date
.
-
classmethod
from_content
(content)[source]¶ Parses the content of the CM Post Archive page from Tibia.com
- Parameters
content (
str
) – The HTML content of the CM Post Archive in Tibia.com- Returns
The CM Post archive found in the page.
- Return type
- Raises
InvalidContent – If content is not the HTML content of the CM Post Archive in Tibia.com
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
ForumAnnouncement¶
-
class
tibiapy.
ForumAnnouncement
(**kwargs)[source]¶ Represent’s a forum announcement.
These are a special kind of thread that are shown at the top of boards. They cannot be replied to and they show no view counts.
New in version 3.0.0.
The author of the announcement.
- Type
-
start_date
¶ The starting date of the announcement.
- Type
-
end_date
¶ The end date of the announcement.
- Type
-
classmethod
from_content
(content, announcement_id=0)[source]¶ Parses the content of an announcement’s page from Tibia.com
- Parameters
- Returns
The announcement contained in the page or
None
if not found.- Return type
- Raises
InvalidContent – If content is not the HTML content of an announcement page in Tibia.com
-
classmethod
get_url
(announcement_id)¶ Gets the URL to an announcement with a given ID.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
ForumBoard¶
-
class
tibiapy.
ForumBoard
(**kwargs)[source]¶ Represents a forum’s board.
New in version 3.0.0.
-
age
¶ The maximum age of the displayed threads, in days.
-1 means all threads will be shown.
- Type
ìnt
-
announcements
¶ The list of announcements currently visible.
- Type
list of
ListedAnnouncement
-
threads
¶ The list of threads currently visible.
- Type
list of
ListedThread
-
classmethod
from_content
(content)[source]¶ Parses the board’s HTML content from Tibia.com.
- Parameters
content (
str
) – The HTML content of the board.- Returns
The forum board contained.
- Return type
- Raises
InvalidContent` – Content is not a board in Tibia.com
-
classmethod
get_community_boards_url
()¶ Gets the URL to the Community Boards section in Tibia.com
- Returns
The URL to the Community Boards.
- Return type
-
classmethod
get_support_boards_url
()¶ Gets the URL to the Support Boards section in Tibia.com
- Returns
The URL to the Support Boards.
- Return type
-
classmethod
get_trade_boards_url
()¶ Gets the URL to the Trade Boards section in Tibia.com
- Returns
The URL to the Trade Boards.
- Return type
-
classmethod
get_url
(board_id, page=1, age=30)¶ Gets the Tibia.com URL to a board with a given id.
-
classmethod
get_world_boards_url
()¶ Gets the URL to the World Boards section in Tibia.com
- Returns
The URL to the World Boards.
- Return type
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
ForumPost¶
-
class
tibiapy.
ForumPost
(**kwargs)[source]¶ Represents a forum post.
New in version 3.0.0.
The author of the post.
- Type
-
emoticon
¶ The emoticon selected for the post.
- Type
-
posted_date
¶ The date when the post was made.
- Type
-
edited_date
¶ The date when the post was last edited, if applicable.
- Type
datetime.datetime
, optional
-
edited_by
¶ The character that edited the post.
This is usually the same author, but in some occasions staff members edit the posts of others.
- Type
str
, optional
-
classmethod
get_url
(post_id)¶ Gets the URL to a specific post.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
ForumThread¶
-
class
tibiapy.
ForumThread
(**kwargs)[source]¶ Represents a forum thread.
New in version 3.0.0.
-
golden_frame
¶ Whether the thread has a golden frame or not.
In the Proposals board,a golden frame means the thread has a reply by a staff member.
- Type
-
anchored_post
¶ The post where the page is anchored to, if any.
When a post is fetched directly, the thread that contains it is displayed, anchored to the specific post.
- Type
-
classmethod
from_content
(content)[source]¶ Creates an instance of the class from the html content of the thread’s page.
- Parameters
content (
str
) – The HTML content of the page.- Returns
The thread contained in the page, or None if the thread doesn’t exist
- Return type
- Raises
InvalidContent – If content is not the HTML of a thread’s page.
-
classmethod
get_url
(thread_id, page=1)¶ Gets the URL to a thread with a given id.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
ListedAnnouncement¶
-
class
tibiapy.
ListedAnnouncement
(**kwargs)[source]¶ Represents an announcement in the forum boards.
New in version 3.0.0.
The character that made the announcement.
- Type
-
classmethod
get_url
(announcement_id)¶ Gets the URL to an announcement with a given ID.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
ListedBoard¶
-
class
tibiapy.
ListedBoard
(**kwargs)[source]¶ Represents a board in the list of boards.
This is the board information available when viewing a section (e.g. World, Trade, Community)
New in version 3.0.0.
-
classmethod
list_from_content
(content)[source]¶ Parses the content of a board list Tibia.com into a list of boards.
- Parameters
content (
str
) – The raw HTML response from the board list.- Returns
- Return type
list
ofListedBoard
- Raises
InvalidContent` – Content is not a board list in Tibia.com
-
classmethod
get_community_boards_url
()¶ Gets the URL to the Community Boards section in Tibia.com
- Returns
The URL to the Community Boards.
- Return type
-
classmethod
get_support_boards_url
()¶ Gets the URL to the Support Boards section in Tibia.com
- Returns
The URL to the Support Boards.
- Return type
-
classmethod
get_trade_boards_url
()¶ Gets the URL to the Trade Boards section in Tibia.com
- Returns
The URL to the Trade Boards.
- Return type
-
classmethod
get_url
(board_id, page=1, age=30)¶ Gets the Tibia.com URL to a board with a given id.
-
classmethod
get_world_boards_url
()¶ Gets the URL to the World Boards section in Tibia.com
- Returns
The URL to the World Boards.
- Return type
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
classmethod
ListedThread¶
-
class
tibiapy.
ListedThread
(**kwargs)[source]¶ Represents a thread in a forum board.
New in version 3.0.0.
-
status
¶ The status of the thread.
- Type
-
emoticon
¶ The emoticon used for the thread.
- Type
-
golden_frame
¶ Whether the thread has a gold frame or not.
In the Proposals board, the gold frame indicates that a staff member has replied in the thread.
- Type
-
classmethod
get_url
(thread_id, page=1)¶ Gets the URL to a thread with a given id.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
Auxiliary Classes¶
CMPost¶
ForumAuthor¶
-
class
tibiapy.
ForumAuthor
(name, **kwargs)[source]¶ Represents a post’s author.
New in version 3.0.0.
-
guild
¶ The guild the author belongs to, if any.
- Type
-
classmethod
get_url
(name)¶ Gets the Tibia.com URL for a given character name.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
ForumEmoticon¶
LastPost¶
-
class
tibiapy.
LastPost
(author, post_id, date, *, deleted=False)[source]¶ Represents a forum thread.
New in version 3.0.0.
The name of the character that made the last post.
- Type
-
date
¶ The date when the last post was made.
- Type
The URL to the author’s character information page.
- Type
-
classmethod
get_url
(post_id)¶ Gets the URL to a specific post.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
News¶
Models related to Tibia.com’s News section.
News¶
-
class
tibiapy.
News
(news_id, title, content, date, category, **kwargs)[source]¶ Represents a news entry.
-
category
¶ The category this belongs to.
- Type
-
date
¶ The date when the news were published.
- Type
-
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
-
classmethod
get_url
(news_id)¶ Gets the Tibia.com URL for a news entry by its id.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
ListedNews¶
-
class
tibiapy.
ListedNews
(news_id, title, news_type, category, date, **kwargs)[source]¶ Represents a news entry.
-
title
¶ The title of the news entry. News tickers have a fragment of their content as a title.
- Type
-
category
¶ The category this belongs to.
- Type
-
date
¶ The date when the news were published.
- Type
-
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
-
classmethod
get_url
(news_id)¶ Gets the Tibia.com URL for a news entry by its id.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
EventSchedule¶
-
class
tibiapy.
EventSchedule
(month, year, **kwargs)[source]¶ Represents the event’s calendar in Tibia.com
-
month
¶ The month being displayed.
Note that some days from the previous and next month may be included too.
- Type
-
events
¶ A list of events that happen during this month.
It might include some events from the previous and next months as well.
- Type
list
ofEventEntry
-
get_events_on
(date)[source]¶ Gets a list of events that are active during the specified desired_date.
- Parameters
date (
datetime.date
) – The date to check.- Returns
The events that are active during the desired_date, if any.
- Return type
list
ofEventEntry
Notes
Dates outside the calendar’s month and year may yield unexpected results.
-
classmethod
get_url
(month=None, year=None)[source]¶ Gets the URL to the Event Schedule or Event Calendar on Tibia.com
Notes
If no parameters are passed, it will show the calendar for the current month and year.
Tibia.com limits the dates that the calendar displays, passing a month and year far from the current ones may result in the response being for the current month and year instead.
-
classmethod
from_content
(content)[source]¶ Creates an instance of the class from the html content of the event’s calendar.
- Parameters
content (
str
) – The HTML content of the page.- Returns
The event calendar contained in the page
- Return type
- Raises
InvalidContent – If content is not the HTML of the event’s schedule page.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
EventEntry¶
-
class
tibiapy.
EventEntry
(title, description, **kwargs)[source]¶ Represents an event’s entry in the calendar.
-
start_date
¶ The day the event starts.
If the event is continuing from the previous month, this will be
None
.- Type
-
end_date
¶ The day the event ends.
If the event is continuing on the next month, this will be
None
.- Type
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
Bazaar¶
Models related to Tibia.com’s Bazaar section.
CharacterBazaar¶
-
class
tibiapy.
CharacterBazaar
(**kwargs)[source]¶ Represents the char bazaar.
-
entries
¶ The auctions displayed.
- Type
-
type
¶ The type of auctions being displayed, either current or auction history.
- Type
-
filters
¶ The currently set filtering options.
- Type
-
property
url
¶ Gets the URL to the bazaar.
- Type
st
-
classmethod
get_current_auctions_url
(page=1, filters=None)[source]¶ Gets the URL to the list of current auctions in Tibia.com
- Parameters
page (
int
) – The page to show the URL for.filters (
AuctionFilters
) – The filtering criteria to use.
- Returns
The URL to the current auctions section in Tibia.com
- Return type
-
classmethod
get_auctions_history_url
(page=1)[source]¶ Gets the URL to the auction history in Tibia.com
- Returns
The URL to the auction history section in Tibia.com
- Return type
-
classmethod
from_content
(content)[source]¶ Gets the bazaar’s information and list of auctions from Tibia.com
- Parameters
content (
str
) – The HTML content of the bazaar section at Tibia.com.- Returns
The character bazaar with the entries found.
- Return type
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
ListedAuction¶
-
class
tibiapy.
ListedAuction
(**kwargs)[source]¶ Represents an auction in the list, containing the summary.
-
outfit
¶ The current outfit selected by the user.
- Type
-
displayed_items
¶ The items selected to be displayed.
- Type
list
ofDisplayItem
-
sales_arguments
¶ The sale arguments selected for the auction.
- Type
-
auction_start
¶ The date when the auction started.
- Type
-
auction_end
¶ The date when the auction ends.
- Type
-
status
¶ The current status of the auction.
- Type
-
classmethod
get_url
(auction_id)[source]¶ Gets the URL to the Tibia.com detail page of an auction with a given id.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
AuctionDetails¶
-
class
tibiapy.
AuctionDetails
(**kwargs)[source]¶ Represents the details of an auction.
-
outfit
¶ The current outfit selected by the user.
- Type
-
displayed_items
¶ The items selected to be displayed.
- Type
list
ofDisplayItem
-
sales_arguments
¶ The sale arguments selected for the auction.
- Type
-
auction_start
¶ The date when the auction started.
- Type
-
auction_end
¶ The date when the auction ends.
- Type
-
status
¶ The current status of the auction.
- Type
-
skills
¶ The current skills of the character.
- Type
list
ofSkillEntry
-
creation_date
¶ The date when the character was created.
- Type
-
regular_world_transfer_available_date
¶ The date after regular world transfers will be available to purchase and use.
None
indicates it is available immediately.- Type
datetime.datetmie
-
items
¶ The items the character has across inventory, depot and item stash.
- Type
-
store_items
¶ The store items the character has.
- Type
-
blessings
¶ The blessings the character has.
- Type
-
charms
¶ The charms the character has unlocked.
- Type
list
ofCharmEntry
-
completed_cyclopedia_map_areas
¶ The cyclopedia map areas that the character has fully discovered.
-
achievements
¶ The achievements the character has unlocked.
- Type
-
bestiary_progress
¶ The bestiary progress of the character.
- Type
-
property
completed_bestiary_entries
¶ Gets a list of completed bestiary entries.
- Type
-
property
regular_world_transfer_available
¶ Whether regular world transfers are available immediately for this character.
- Type
-
property
skills_map
¶ A mapping of skills by their name.
- Type
dict
ofstr
,SkillEntry
-
classmethod
from_content
(content, auction_id=0, skip_details=False)[source]¶ Parses an auction detail page from Tibia.com and extracts its data.
- Parameters
content (
str
) – The HTML content of the auction detail page in Tibia.comauction_id (
int
, optional) –The ID of the auction.
It is not possible to extract the ID from the page’s content, so it may be passed to assign it manually.
skip_details (
bool
, optional) –Whether to skip parsing the entire auction and only parse the information shown in lists. False by default.
This allows fetching basic information like name, level, vocation, world, bid and status, shaving off some parsing time.
- Returns
The auction details if found,
None
otherwise.- Return type
- Raises
InvalidContent – If the content does not belong to a auction detail’s page.
-
classmethod
get_url
(auction_id)¶ Gets the URL to the Tibia.com detail page of an auction with a given id.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
Auxiliary Classes¶
AchievementEntry¶
AuctionFilters¶
-
class
tibiapy.
AuctionFilters
(**kwargs)[source]¶ Represents the auctions filters available in the current auctions section.
All attributes are optional.
-
pvp_type
¶ The PvP type of the character’s worlds to show.
- Type
-
battleye
¶ The type of BattlEye protection of the character’s worlds to show.
- Type
-
vocation
¶ The character vocation to show results for.
-
skill
¶ The skill to filter by its level range.
- Type
-
search_type
¶ The type of search to use. Defines the behaviour of
search_string
.- Type
-
property
item
¶ The name of the item to search for.
Deprecated since version 3.5.0: Use
search_string
instead.- Type
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
BestiaryEntry¶
BlessingEntry¶
CharmsEntry¶
DisplayFamiliar¶
DisplayItem¶
DisplayMount¶
DisplayOutfit¶
Familiars¶
-
class
tibiapy.
Familiars
(**kwargs)[source]¶ The familiars the character has unlocked or purchased.
-
entries
¶ The familiars the character has unlocked or purchased.
- Type
-
entry_class
¶ alias of
tibiapy.bazaar.DisplayFamiliar
-
get_by_id
(entry_id)[source]¶ Gets an outfit by its familiar id.
- Parameters
entry_id (
int
) – The ID of the outfit.- Returns
The outfit matching the id.
- Return type
-
get_by_name
(name)¶ Gets an entry by its name.
-
search
(value)¶ Searches an entry by its name
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
ItemSummary¶
-
class
tibiapy.
ItemSummary
(**kwargs)[source]¶ Items in a character’s inventory and depot.
-
entries
¶ The character’s items.
- Type
list
ofDisplayItem
-
entry_class
¶ alias of
tibiapy.bazaar.DisplayItem
-
get_by_id
(entry_id)[source]¶ Gets an item by its item id.
- Parameters
entry_id (
int
) – The ID of the item.- Returns
The item matching the id.
- Return type
-
get_by_name
(name)¶ Gets an entry by its name.
-
search
(value)¶ Searches an entry by its name
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
Mounts¶
-
class
tibiapy.
Mounts
(**kwargs)[source]¶ The mounts a character has unlocked or purchased.
-
entries
¶ The character’s mounts.
- Type
list
ofDisplayMount
-
entry_class
¶ alias of
tibiapy.bazaar.DisplayMount
-
get_by_id
(entry_id)[source]¶ Gets a mount by its mount id.
- Parameters
entry_id (
int
) – The ID of the mount.- Returns
The mount matching the id.
- Return type
-
get_by_name
(name)¶ Gets an entry by its name.
-
search
(value)¶ Searches an entry by its name
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
OutfitImage¶
Outfits¶
-
class
tibiapy.
Outfits
(**kwargs)[source]¶ The outfits the character has unlocked or purchased.
-
entries
¶ The outfits the character has unlocked or purchased.
- Type
-
entry_class
¶ alias of
tibiapy.bazaar.DisplayOutfit
-
get_by_id
(entry_id)[source]¶ Gets an outfit by its outfit id.
- Parameters
entry_id (
int
) – The ID of the outfit.- Returns
The outfit matching the id.
- Return type
-
get_by_name
(name)¶ Gets an entry by its name.
-
search
(value)¶ Searches an entry by its name
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
SalesArgument¶
Kill Statistics¶
KillStatistics¶
-
class
tibiapy.
KillStatistics
(world, entries=None, total=None)[source]¶ Represents the kill statistics of a world.
-
entries
¶ A dictionary of kills entries of every race, where the key is the name of the race.
- Type
-
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
- 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.
-
Library¶
CreaturesSection¶
-
class
tibiapy.
CreaturesSection
(boosted_creature, creatures)[source]¶ Represents the creature’s section in the Tibia.com library.
-
classmethod
get_url
()[source]¶ Gets the URL to the Tibia.com library section.
- Returns
The URL to the Tibia.com library section.
- Return type
-
classmethod
from_boosted_creature_header
(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 creature of the day.
- Return type
- Raises
InvalidContent – If content is not the HTML of a Tibia.com’s page.
-
classmethod
from_content
(content)[source]¶ Creates an instance of the class from the html content of the creature library’s page.
- Parameters
content (
str
) – The HTML content of the page.- Returns
The character contained in the page.
- Return type
- Raises
InvalidContent – If content is not the HTML of a creature library’s page.
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
classmethod
Creature¶
CreatureDetail¶
-
class
tibiapy.
CreatureDetail
(name, race, **kwargs)[source]¶ Represents a creature’s details on the Tibia.com library.
-
classmethod
from_content
(content)[source]¶ Creates an instance of the class from the html content of the creature library’s page.
- Parameters
content (
str
) – The HTML content of the page.- Returns
The character contained in the page.
- Return type
-
classmethod
get_url
(race)¶ Gets the URL to the creature’s detail page on Tibia.com
-
to_json
(*, indent=None, sort_keys=False)¶ Gets the object’s JSON representation.
-
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.
BaseAnnouncement
[source]¶ Base class for all announcement classes.
Implement common properties and methods for announcements.
The following implement this class:
-
class
tibiapy.abc.
BaseBoard
[source]¶ Base class for all board classes.
Implements common properties and methods for boards.
The following implement this class:
-
classmethod
get_url
(board_id, page=1, age=30)[source]¶ Gets the Tibia.com URL to a board with a given id.
-
classmethod
get_world_boards_url
()[source]¶ Gets the URL to the World Boards section in Tibia.com
- Returns
The URL to the World Boards.
- Return type
-
classmethod
get_trade_boards_url
()[source]¶ Gets the URL to the Trade Boards section in Tibia.com
- Returns
The URL to the Trade Boards.
- Return type
-
classmethod
-
class
tibiapy.abc.
BaseCharacter
[source]¶ Base class for all character classes.
Implements common properties methods for characters.
The following implement this class:
-
class
tibiapy.abc.
BaseGuild
[source]¶ Base class for Guild classes.
The following implement this class:
-
class
tibiapy.abc.
BaseHouse
[source]¶ Base class for all house classes
The following implement this class:
-
classmethod
get_url
(house_id, world)[source]¶ Gets the Tibia.com URL for a house with the given id and world.
-
classmethod
get_list_url
(world, town, house_type: tibiapy.enums.HouseType = HouseType.HOUSE, status: Optional[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
-
classmethod
-
class
tibiapy.abc.
HouseWithId
[source]¶ Implements the
id
attribute and dependant functions and properties.Subclasses mut also implement
BaseHouse
-
class
tibiapy.abc.
BaseNews
[source]¶ Base class for all news classes
Implements the
id
attribute and common properties.The following implement this class:
-
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
-
classmethod
-
class
tibiapy.abc.
BasePost
[source]¶ Base classs for post classes.
The following implement this class:
-
class
tibiapy.abc.
BaseThread
[source]¶ Base class for thread classes.
The following implement this class:
-
class
tibiapy.abc.
BaseTournament
[source]¶ Base class for tournament classes.
The following implement this class:
-
class
tibiapy.abc.
BaseWorld
[source]¶ Base class for all World classes.
The following implement this class:
-
class
tibiapy.abc.
Serializable
[source]¶ Contains methods to make a class convertible to JSON.
Only attributes defined in
__slots__
will be serialized.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
(message, original=None)[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.
SiteMaintenanceError
(message, original=None)[source]¶ A subclass of
NetworkError
thrown when Tibia.com is down for maintenance.When Tibia.com is under maintenance, all sections of the website redirect to maintenance.tibia.com.
-
class
tibiapy.
Forbidden
(message, original=None)[source]¶ A subclass of
NetworkError
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 that may not be intended for public use.
-
tibiapy.utils.
convert_line_breaks
(element)[source]¶ Converts the <br> tags in a HTML elements to actual line breaks.
- Parameters
element (
bs4.Tag
) – A BeautifulSoup object.
-
tibiapy.utils.
get_tibia_url
(section, subtopic=None, *args, anchor=None, **kwargs)[source]¶ Builds a URL to Tibia.com with the given parameters.
- Parameters
section (
str
) – The desired section (e.g. community, abouttibia, manual, library)subtopic (
str
, optional) – The desired subtopic (e.g. characters, guilds, houses, etc)anchor (
str
) – A link anchor to add to the link.args – A list of key-value pairs to add as query parameters. This allows passing multiple parameters with the same name.
kwargs – Additional parameters to pass to the url as query parameters (e.g name, world, houseid, etc)
- Returns
The generated Tibia.com URL.
- Return type
Examples
>>> get_tibia_url("community", "houses", page="view", houseid=55302, world="Gladera") https://www.tibia.com/community/?subtopic=houses&page=view&houseid=55302&world=Gladera
You can also build a dictionary and pass it like:
>>> params = {'world': "Gladera"} >>> get_tibia_url("community", "worlds", **params) https://www.tibia.com/community/?subtopic=worlds&world=Gladera
-
tibiapy.utils.
parse_integer
(number: str, default: Optional[int] = 0)[source]¶ Parses a string representing an integer, ignoring commas or periods.
-
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
.MMM DD YYYY, HH:mm ZZZ
, e.g.Dec 10 2018, 21:53 CET
.
- Parameters
datetime_str (
str
) – The date and time as represented in Tibia.com- Returns
The represented datetime, in UTC (timezone aware).
- 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.com- Returns
The represented date, in UTC (timezone aware).
- Return type
datetime.date
, optional
-
tibiapy.utils.
parse_tibia_forum_datetime
(datetime_str, utc_offset=1)[source]¶ Parses a date in the format used in the Tibia.com forums.
Accepted format:
DD.MM.YY HH:mm:ss
, e.g.23.07.2015 21:30:30
- Parameters
- Returns
The represented datetime, in UTC (timezone aware).
- Return type
datetime
-
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.com- Returns
The represented date, in UTC (timezone aware).
- Return type
datetime.date
, optional
-
tibiapy.utils.
parse_number_words
(text_num)[source]¶ Parses the word representation of a number to a integer.
-
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, in UTC (timezone aware), 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, in UTC (timezone aware).
- 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: Optional[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
-
tibiapy.utils.
parse_tibia_money
(argument)[source]¶ Parses a string that may contain ‘k’ as thousand suffix.
-
tibiapy.utils.
split_list
(items, separator=',', last_separator=' and ')[source]¶ Splits a string listing elements into an actual list.
-
tibiapy.utils.
parse_popup
(popup_content)[source]¶ Parses the information popups used through Tibia.com.