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.
- Type:
- 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, *, test=False)[source]¶
Fetch 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, filters=None, *, test=False)[source]¶
Fetch the auction history of the bazaar.
New in version 3.3.0.
- Parameters:
page (
int
) – The page to display.filters (
AuctionFilters
) – The filtering criteria to use.test (
bool
) – Whether to request the test website instead.
- 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, test=False)[source]¶
Fetch 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.
test (
bool
) – Whether to request the test website instead.
- 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, *, test=False)[source]¶
Fetch the CM post archive.
New in version 3.0.0.
- Parameters:
- 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, *, test=False)[source]¶
Fetch 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(*, test=False)[source]¶
Fetch the forum’s community boards.
New in version 3.0.0.
- Parameters:
test (
bool
) – Whether to request the test website instead.- Returns:
The forum boards in the community section.
- Return type:
TibiaResponse
of list ofBoardEntry
- 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(*, test=False)[source]¶
Fetch the forum’s community boards.
New in version 3.0.0.
- Parameters:
test (
bool
) – Whether to request the test website instead.- Returns:
The forum boards in the community section.
- Return type:
TibiaResponse
of list ofBoardEntry
- 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(*, test=False)[source]¶
Fetch the forum’s world boards.
New in version 3.0.0.
- Parameters:
test (
bool
) – Whether to request the test website instead.- Returns:
The forum boards in the world section.
- Return type:
TibiaResponse
of list ofBoardEntry
- 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(*, test=False)[source]¶
Fetch the forum’s trade boards.
New in version 3.0.0.
- Parameters:
test (
bool
) – Whether to request the test website instead.- Returns:
The forum boards in the trade section.
- Return type:
TibiaResponse
of list ofBoardEntry
- 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, *, test=False)[source]¶
Fetch 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, *, test=False)[source]¶
Fetch 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, *, test=False)[source]¶
Fetch 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:
- 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, *, test=False)[source]¶
Fetch a forum announcement.
New in version 3.0.0.
- Parameters:
- 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_and_boss(*, test=False)[source]¶
Fetch today’s boosted creature and boss.
New in version 5.3.0.
- Parameters:
test (
bool
) – Whether to request the test website instead.- Returns:
The boosted creature and boss 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_boosted_boss(*, test=False)[source]¶
Fetch today’s boosted boss.
New in version 5.3.0.
- Parameters:
test (
bool
) – Whether to request the test website instead.- Returns:
The boosted boss 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_bosses(*, test=False)[source]¶
Fetch the bosses from the library section.
New in version 4.0.0.
- Parameters:
test (
bool
) – Whether to request the test website instead.- 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_boosted_creature(*, test=False)[source]¶
Fetch 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.- Parameters:
test (
bool
) – Whether to request the test website instead.- 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(*, test=False)[source]¶
Fetch the creatures from the library section.
New in version 4.0.0.
- Parameters:
test (
bool
) – Whether to request the test website instead.- 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(identifier, *, test=False)[source]¶
Fetch a creature’s information from the Tibia.com library.
New in version 4.0.0.
- Parameters:
- 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, *, test=False)[source]¶
Fetch a character by its name from Tibia.com.
- Parameters:
- 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, *, test=False)[source]¶
Fetch a guild by its name from Tibia.com.
- Parameters:
- 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, *, test=False)[source]¶
Fetch a guild’s wars by its name from Tibia.com.
New in version 3.0.0.
- Parameters:
- 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, *, test=False)[source]¶
Fetch 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, *, test=False)[source]¶
Fetch 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.test (
bool
) – Whether to request the test website instead.
- 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, *, test=False)[source]¶
Fetch the kill statistics of a world from Tibia.com.
- Parameters:
- 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_leaderboard(world, rotation=None, page=1, *, test=False)[source]¶
Fetch the leaderboards for a specific world and rotation.
New in version 5.0.0.
- Parameters:
- Returns:
The leaderboards 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, *, test=False)[source]¶
Fetch a world from Tibia.com.
- Parameters:
- 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=None, order=None, *, test=False)[source]¶
Fetch the house list of a world and type.
Changed in version 5.0.0: The data attribute of the response contains an instance of
HousesSection
instead.- 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.test (
bool
) – Whether to request the test website instead.
- Returns:
A response containing the lists of houses meeting the criteria 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_guilds(world: str, *, test=False)[source]¶
Fetch the list of guilds in a world from Tibia.com.
If a world that does not exist is passed, the world attribute of the result will be
None
. If the world attribute is set, but the list is empty, it just means the world has no guilds.Changed in version 5.0.0: The data attribute of the response contains an instance of
GuildsSection
instead.- Parameters:
- Returns:
A response containing the guilds section for the specified world.
- 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_list(*, test=False)[source]¶
Fetch the world overview information from Tibia.com.
- Parameters:
test (
bool
) – Whether to request the test website instead.- 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(start_date, end_date, categories=None, types=None, *, test=False)[source]¶
Fetch news from the archive meeting the search criteria.
Changed in version 5.0.0: The data attribute of the response contains an instance of
NewsArchive
instead.- Parameters:
start_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
NewsType
) – The allowed news types to show. if unused, all types will be searched.test (
bool
) – Whether to request the test website instead.
- Returns:
The news meeting the search criteria.
- Return type:
- Raises:
ValueError: – If
begin_date
is more recent thanto_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, *, test=False)[source]¶
Fetch all the published news in the last specified days.
This is a shortcut for
fetch_news_archive()
, to handle dates more easily.Changed in version 5.0.0: The data attribute of the response contains an instance of
NewsArchive
instead.- 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
NewsType
) – The allowed news types to show. if unused, all types will be searched.test (
bool
) – Whether to request the test website instead.
- Returns:
The news posted in the last specified days.
- 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(news_id, *, test=False)[source]¶
Fetch a news entry by its id from Tibia.com.
- Parameters:
- 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_spells(*, vocation=None, group=None, spell_type=None, premium=None, sort=None, test=False)[source]¶
Fetch the spells section.
- Parameters:
vocation (
VocationSpellFilter
, optional) – The vocation to filter in spells for.group (
SpellGroup
, optional) – The spell’s primary cooldown group.spell_type (
SpellType
, optional) – The type of spells to show.premium (
bool
, optional) – The type of premium requirement to filter.None
means any premium requirement.sort (
SpellSorting
, optional) – The field to sort spells by.
- Returns:
The spells section with the results.
- 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_spell(identifier, *, test=False)[source]¶
Fetch a spell by its identifier.
- Parameters:
- Returns:
The spell 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, *, test=False)[source]¶
Fetch a tournament from Tibia.com.
New in version 2.5.0.
- Parameters:
- 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, *, test=False)[source]¶
Fetch a tournament leaderboard 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.world (
str
) – The name of the world to get the leaderboards for.page (
int
) – The desired leaderboards page, by default 1 is used.test (
bool
) – Whether to request the test website instead.
- 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.
Many of these enumerations correspond to available options in forms in Tibia.com
- 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.
- ANY_WORLD = -1¶
Show all worlds.
- 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¶
- DROME_SCORE = 14¶
- 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'¶
- property filter_name¶
- class tibiapy.NewsType(value)[source]¶
The different types of new entries.
- NEWS_TICKER = 'News Ticker'¶
- FEATURED_ARTICLE = 'Featured Article'¶
- NEWS = 'News'¶
- property filter_name¶
- 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.SpellGroup(value)[source]¶
The possible cooldown groups.
Note that secondary groups are not enumerated.
- ATTACK = 'Attack'¶
- HEALING = 'Healing'¶
- SUPPORT = 'Support'¶
- class tibiapy.SpellSorting(value)[source]¶
The different sorting options for the spells section.
- NAME = 'name'¶
- GROUP = 'group'¶
- TYPE = 'type'¶
- EXP_LEVEL = 'level'¶
- MANA = 'mana'¶
- PRICE = 'price'¶
- PREMIUM = 'premium'¶
- class tibiapy.SpellType(value)[source]¶
The possible spell types.
- INSTANT = 'Instant'¶
- RUNE = 'Rune'¶
- 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]¶
Generate 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]¶
Get 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]¶
A full character from Tibia.com, obtained from its character page.
- deletion_date¶
The date when the character will be deleted if it is scheduled for deletion. Will be
None
otherwise.- Type:
datetime.datetime
, optional
- houses¶
The houses currently owned by the character.
- Type:
- guild_membership¶
The guild the character is a member of. It will be
None
if the character is not in a guild.- 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 the character is hidden, this will be
None
.- 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:
- property guild_name: Optional[str]¶
The name of the guild the character belongs to, or
None
.- Type:
str
, optional
- property guild_rank: Optional[str]¶
The character’s rank in the guild they belong to, or
None
.- Type:
str
, optional
- property guild_url: Optional[str]¶
The character’s rank in the guild they belong to, or
None
.- Type:
str
, optional
Whether this is a hidden character or not.
- Type:
- property married_to_url: Optional[str]¶
The URL to the husband/spouse information page on Tibia.com, if applicable.
- Type:
str
, optional
- classmethod from_content(content)[source]¶
Create 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)¶
Get the Tibia.com URL for a given character name.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
Auxiliary Classes¶
AccountBadge¶
AccountInformation¶
- class tibiapy.AccountInformation(created, loyalty_title=None, position=None)[source]¶
Contains the information of a character’s account.
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)¶
Get 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]¶
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_url(house_id, world)¶
Get the Tibia.com URL for a house with the given id and world.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
Death¶
- class tibiapy.Death(name=None, level=0, **kwargs)[source]¶
A character’s death.
- 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)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
GuildMembership¶
- class tibiapy.GuildMembership(name, rank, title=None)[source]¶
The guild information of a character.
- title¶
The title of the member in the guild. This is only available for characters in the forums section.
- Type:
str
, optional
- classmethod get_url(name)¶
Get the Tibia.com URL for a given guild name.
- classmethod get_url_wars(name)¶
Get the Tibia.com URL for the guild wars of a guild with a given name.
New in version 3.0.0.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
Killer¶
- class tibiapy.Killer(name, player=False, summon=None, traded=False)[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)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
OtherCharacter¶
- class tibiapy.OtherCharacter(name, world, online=False, deleted=False, main=False, position=None, traded=False)[source]¶
A character listed in the characters section of a character’s page.
These are only shown if the character is not hidden, and only characters that are not hidden are shown here.
- classmethod get_url(name)¶
Get the Tibia.com URL for a given character name.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
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
ofWorldEntry
- 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
ofWorldEntry
- classmethod get_url()[source]¶
Get 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]¶
Parse 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)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
WorldEntry¶
- class tibiapy.WorldEntry(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]¶
Get 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]¶
Parse 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
ofWorldEntry
- Raises:
InvalidContent – If the provided content is not the HTML content of the worlds section in Tibia.com
- classmethod get_url(name)¶
Get the URL to the World’s information page on Tibia.com.
- to_json(*, indent=None, sort_keys=False)¶
Get 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¶
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]¶
Parse 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)¶
Get the URL to the World’s information page on Tibia.com.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
OnlineCharacter¶
- class tibiapy.OnlineCharacter(name, world, level, vocation)[source]¶
An online character in the world’s page.
- classmethod get_url(name)¶
Get the Tibia.com URL for a given character name.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
Guilds¶
Models related to Tibia.com’s Guilds section. The main model is Guild
, while GuildEntry
is the
previewed information in the guild list of the GuildsSection
.
GuildsSection¶
- class tibiapy.GuildsSection(world, entries=None, available_worlds=None)[source]¶
The guilds section in Tibia.com.
New in version 5.0.0.
- entries¶
The list of guilds in the world.
- Type:
list
ofGuildEntry
- property active_guilds¶
Get a list of the guilds that are active.
- Type:
list
ofGuildEntry
- property in_formation_guilds¶
Get a list of the guilds that are in course of formation.
- Type:
list
ofGuildEntry
- classmethod from_content(content)[source]¶
Get 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:
- Raises:
InvalidContent – If content is not the HTML of a guild’s page.
- classmethod get_url(world)[source]¶
Get the Tibia.com URL for the guild section of a specific world.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
Guild¶
- class tibiapy.Guild(name=None, world=None, **kwargs)[source]¶
A Tibia guild, viewed from its guild’s page.
- founded¶
The day the guild was founded.
- Type:
- guildhall¶
The guild’s guildhall if any.
- Type:
GuildHouse
, optional
- active_war¶
Whether the guild is currently in an active war or not.
New in version 3.0.0.
- Type:
- 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
- property members_by_rank: Dict[str, List[GuildMember]]¶
Get a mapping of members, grouped by their guild rank.
- Type:
- classmethod from_content(content)[source]¶
Create 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)¶
Get the Tibia.com URL for a given guild name.
- classmethod get_url_wars(name)¶
Get the Tibia.com URL for the guild wars of a guild with a given name.
New in version 3.0.0.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
GuildEntry¶
- class tibiapy.GuildEntry(name, world, logo_url=None, description=None, active=False)[source]¶
Represents a Tibia guild in the guild list of a world.
- classmethod get_url(name)¶
Get the Tibia.com URL for a given guild name.
- classmethod get_url_wars(name)¶
Get the Tibia.com URL for the guild wars of a guild with a given name.
New in version 3.0.0.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
Auxiliary Classes¶
GuildInvite¶
- class tibiapy.GuildInvite(name=None, date=None)[source]¶
Represents an invited character.
- date¶
The day when the character was invited.
- Type:
- classmethod get_url(name)¶
Get the Tibia.com URL for a given character name.
- to_json(*, indent=None, sort_keys=False)¶
Get 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]¶
A guildhall owned by a guild.
By limitation of Tibia.com, the ID of the guildhall is not available.
- status¶
The current status of the house.
This is kept for compatibility with house objects and will always be
HouseStatus.RENTED
.- Type:
- type¶
The type of the house.
This is kept for compatibility with house objects and will always be
HouseType.GUILDHALL
.- Type:
- paid_until_date¶
The date the last paid rent is due.
- Type:
- classmethod get_url(house_id, world)¶
Get the Tibia.com URL for a house with the given id and world.
- to_json(*, indent=None, sort_keys=False)¶
Get 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¶
The day the member joined the guild.
- Type:
- classmethod get_url(name)¶
Get the Tibia.com URL for a given character name.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
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]¶
Get the URL to the guild’s war page of a guild with the given name.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
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)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
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.
- Type:
- 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]¶
Get 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]¶
Create 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]¶
Get 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.
- Return type:
The URL to the Tibia.com highscores.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
HighscoresEntry¶
- class tibiapy.HighscoresEntry(rank, name, vocation, world, level, value)[source]¶
Represents a entry for the highscores.
- classmethod get_url(name)¶
Get the Tibia.com URL for a given character name.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
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)¶
Get the Tibia.com URL for a given character name.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
Houses¶
Models related to Tibia.com’s Houses section.
HousesSection¶
- class tibiapy.HousesSection(**kwargs)[source]¶
Represents the house section.
New in version 5.0.0.
- order¶
The ordering to use for the results.
- Type:
- entries¶
The houses matching the filters.
- Type:
list
ofHouseEntry
- classmethod get_url(world, town, house_type, status=None, order=None)[source]¶
Get the URL to the house list on Tibia.com with the specified filters.
- Parameters:
world (
str
) – The world to search in.town (
str
) – The town to show results for.house_type (
HouseType
) – The type of houses to show.status (
HouseStatus
) – The status of the houses to show.order (
HouseOrder
) – The sorting parameter to use for the results.
- Returns:
The URL to the list matching the parameters.
- Return type:
- classmethod from_content(content)[source]¶
Parse 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:
The houses found in the page.
- Return type:
HouseSection
- Raises:
InvalidContent` – Content is not the house list from Tibia.com
- to_json(*, indent=None, sort_keys=False)¶
Get 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¶
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]¶
Parse 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_url(house_id, world)¶
Get the Tibia.com URL for a house with the given id and world.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
HouseEntry¶
- class tibiapy.HouseEntry(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 get_url(house_id, world)¶
Get the Tibia.com URL for a house with the given id and world.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
Leaderboard¶
Models related to Tibia.com’s Leaderboard section.
Leaderboard¶
- class tibiapy.Leaderboard(world, rotation, **kwargs)[source]¶
Represents the Tibiadrome leaderboards.
New in version 5.0.0.
- rotation¶
The rotation this leaderboards’ entries are for.
- Type:
- available_rotations¶
The available rotations for selection.
- Type:
- entries¶
The list of entries in this leaderboard.
- Type:
list of
LeaderboardEntry
- last_update¶
How long ago was the currently displayed data updated. Only available for the current rotation.
- Type:
- results_count¶
The total amount of entries in this rotation. These may be shown in another page.
- Type:
- property previous_page_url¶
The URL to the previous page of the current leaderboard results, if there’s any.
- Type:
- property next_page_url¶
The URL to the next page of the current leaderboard results, if there’s any.
- Type:
- get_page_url(page)[source]¶
Get the URL of the leaderboard at a specific page, with the current date parameters.
- Parameters:
page (
int
) – The desired page.- Returns:
The URL to the desired page.
- Return type:
- Raises:
ValueError – If the specified page is zer or less.
- classmethod get_url(world, rotation_id=None, page=1)[source]¶
Get the URL to the leaderboards of a world.
- Parameters:
- Returns:
The URL to the leaderboard with the desired parameters.
- Return type:
- Raises:
ValueError – If the specified page is zer or less.
- classmethod from_content(content)[source]¶
Parse the content of the leaderboards page.
- Parameters:
content (
str
) – The HTML content of the leaderboards page.- Returns:
The ledaerboard if found.
- Return type:
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
Auxiliary Classes¶
LeaderboardRotation¶
- class tibiapy.LeaderboardRotation(rotation_id, end_date, current=False)[source]¶
A leaderboard rotation.
New in version 5.0.0.
- Parameters:
rotation_id (
int
) – The internal ID of the rotation.current (
bool
) – Whether this is the currently running rotation or not.end_date (
datetime.datetime
) – The date and time when this rotation ends.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
LeaderboardEntry¶
- class tibiapy.LeaderboardEntry(rank, name, drome_level)[source]¶
Represents a single leadeboard entry.
- Parameters:
- classmethod get_url(name)¶
Get the Tibia.com URL for a given character name.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
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]¶
Get 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]¶
Create 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)¶
Get 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)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
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]¶
Get the URL to the leaderboards of a specific world, tournament and page.
- classmethod from_content(content)[source]¶
Create 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)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
Auxiliary Classes¶
TournamentEntry¶
- class tibiapy.TournamentEntry(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)¶
Get 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)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
TournamentLeaderboardEntry¶
- class tibiapy.TournamentLeaderboardEntry(**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)¶
Get the Tibia.com URL for a given character name.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
RewardEntry¶
- class tibiapy.RewardEntry(**kwargs)[source]¶
Represents the rewards for a specific rank range.
- tibia_coins¶
The amount of tibia coins awarded.
- Type:
:class`int`
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
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)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
ScoreSet¶
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]¶
Get 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]¶
Get 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]¶
Parse 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)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
ForumAnnouncement¶
- class tibiapy.ForumAnnouncement(**kwargs)[source]¶
Represents 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.
- author¶
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]¶
Parse 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)¶
Get the URL to an announcement with a given ID.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
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
AnnouncementEntry
- threads¶
The list of threads currently visible.
- Type:
list of
ThreadEntry
- classmethod from_content(content)[source]¶
Parse 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()¶
Get the URL to the Community Boards section in Tibia.com.
- Returns:
The URL to the Community Boards.
- Return type:
- classmethod get_support_boards_url()¶
Get the URL to the Support Boards section in Tibia.com.
- Returns:
The URL to the Support Boards.
- Return type:
- classmethod get_trade_boards_url()¶
Get 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)¶
Get the Tibia.com URL to a board with a given id.
- classmethod get_world_boards_url()¶
Get 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)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
ForumPost¶
- class tibiapy.ForumPost(**kwargs)[source]¶
Represents a forum post.
New in version 3.0.0.
- author¶
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)¶
Get the URL to a specific post.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
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]¶
Create 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)¶
Get the URL to a thread with a given id.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
AnnouncementEntry¶
- class tibiapy.AnnouncementEntry(**kwargs)[source]¶
Represents an announcement in the forum boards.
New in version 3.0.0.
- classmethod get_url(announcement_id)¶
Get the URL to an announcement with a given ID.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
BoardEntry¶
- class tibiapy.BoardEntry(**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]¶
Parse the content of a board list Tibia.com into a list of boards.
- Parameters:
content (
str
) – The raw HTML response from the board list.- Return type:
list
ofBoardEntry
- Raises:
InvalidContent` – Content is not a board list in Tibia.com
- classmethod get_community_boards_url()¶
Get the URL to the Community Boards section in Tibia.com.
- Returns:
The URL to the Community Boards.
- Return type:
- classmethod get_support_boards_url()¶
Get the URL to the Support Boards section in Tibia.com.
- Returns:
The URL to the Support Boards.
- Return type:
- classmethod get_trade_boards_url()¶
Get 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)¶
Get the Tibia.com URL to a board with a given id.
- classmethod get_world_boards_url()¶
Get 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)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
ThreadEntry¶
- class tibiapy.ThreadEntry(**kwargs)[source]¶
Represents a thread in a forum board.
New in version 3.0.0.
- thread_starter_traded¶
Whether the thread starter was recently traded or not. .. versionadded:: 5.0.0
- Type:
- 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)¶
Get the URL to a thread with a given id.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
Auxiliary Classes¶
CMPost¶
- class tibiapy.CMPost(**kwargs)[source]¶
Represents a CM Post entry.
New in version 3.0.0.
- date¶
The date when the post was made.
- Type:
- classmethod get_url(post_id)¶
Get the URL to a specific post.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
ForumEmoticon¶
LastPost¶
- class tibiapy.LastPost(author, post_id, date, *, deleted=False, traded=False)[source]¶
Represents a forum thread.
New in version 3.0.0.
- date¶
The date when the last post was made.
- Type:
- classmethod get_url(post_id)¶
Get the URL to a specific post.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
News¶
Models related to Tibia.com’s News section. This also contains the Event Calendar
NewsArchive¶
- class tibiapy.NewsArchive(**kwargs)[source]¶
Represents the news archive.
New in version 5.0.0.
- start_date¶
The start date to show news for.
- Type:
- end_date¶
The end date to show news for.
- Type:
- categories¶
The categories to show.
- Type:
list
ofNewsCategory
.
- classmethod get_form_data(start_date, end_date, categories=None, types=None)[source]¶
Get the form data attributes to search news with specific parameters.
- Parameters:
start_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
NewsType
) – The allowed news types to show. if unused, all types will be searched.
- Returns:
A dictionary with the required form data to search news in the archive.
- Return type:
- classmethod get_url()[source]¶
Get 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 from_content(content)[source]¶
Get a list of news from the HTML content of the news search page.
- Parameters:
content (
str
) – The HTML content of the page.- Returns:
The news archive with the news found.
- Return type:
- Raises:
InvalidContent – If content is not the HTML of a news search’s page.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
News¶
- class tibiapy.News(news_id, title, content, date, category, **kwargs)[source]¶
Represents a news entry.
- category¶
The category this belongs to.
- Type:
- date¶
The date when the news were published.
- Type:
- classmethod from_content(content, news_id=0)[source]¶
Get 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()¶
Get 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)¶
Get the Tibia.com URL for a news entry by its id.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
NewsEntry¶
- class tibiapy.NewsEntry(news_id, title, news_type, category, date, **kwargs)[source]¶
A news entry from the news archive.
- 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 get_list_url()¶
Get 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)¶
Get the Tibia.com URL for a news entry by its id.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
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]¶
Get 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]¶
Get 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]¶
Create 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)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
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)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
Bazaar¶
Models related to Tibia.com’s Bazaar section.
CharacterBazaar¶
- class tibiapy.CharacterBazaar(**kwargs)[source]¶
Represents the char bazaar.
- entries¶
The auctions displayed.
- Type:
list
ofAuctionEntry
- type¶
The type of auctions being displayed, either current or auction history.
- Type:
- filters¶
The currently set filtering options.
- Type:
- classmethod get_current_auctions_url(page=1, filters=None)[source]¶
Get 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, filters=None)[source]¶
Get the URL to the auction history 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 auction history section in Tibia.com
- Return type:
- classmethod from_content(content)[source]¶
Get 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)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
AuctionEntry¶
- class tibiapy.AuctionEntry(**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]¶
Get the URL to the Tibia.com detail page of an auction with a given id.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
Auction¶
- class tibiapy.Auction(**kwargs)[source]¶
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¶
Get 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: Dict[str, SkillEntry]¶
A mapping of skills by their name.
- Type:
dict
ofstr
,SkillEntry
- classmethod from_content(content, auction_id=0, skip_details=False)[source]¶
Parse 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)¶
Get the URL to the Tibia.com detail page of an auction with a given id.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
Auxiliary Classes¶
AchievementEntry¶
AuctionFilters¶
- class tibiapy.AuctionFilters(**kwargs)[source]¶
The auction filters available in the 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.
- Type:
- 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:
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
BestiaryEntry¶
- class tibiapy.BestiaryEntry(name, kills, step)[source]¶
The bestiary progress for a specific creature.
- step¶
The current step to unlock this creature the character is in, where 4 is fully unlocked.
- Type:
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
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
DisplayFamiliar
- get_by_id(entry_id)[source]¶
Get 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)¶
Get an entry by its name.
- search(value)¶
Search an entry by its name.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
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
DisplayItem
- get_by_id(entry_id)[source]¶
Get 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)¶
Get an entry by its name.
- search(value)¶
Search an entry by its name.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
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
DisplayMount
- get_by_id(entry_id)[source]¶
Get 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)¶
Get an entry by its name.
- search(value)¶
Search an entry by its name.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
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
DisplayOutfit
- get_by_id(entry_id)[source]¶
Get 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)¶
Get an entry by its name.
- search(value)¶
Search an entry by its name.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
SalesArgument¶
- class tibiapy.SalesArgument(**kwargs)[source]¶
Represents a sales argument.
Sales arguments can be selected when creating an auction, and allow the user to highlight certain character features in the auction listing.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
SkillEntry¶
Kill Statistics¶
KillStatistics¶
- class tibiapy.KillStatistics(world, entries=None, total=None, available_worlds=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]¶
Get the Tibia.com URL of the kill statistics of a world.
- Parameters:
world (
str
) – The game world of the desired kill statistics.- Return type:
The URL to the Tibia.com kill statistics for this world.
- classmethod from_content(content)[source]¶
Create 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)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
RaceEntry¶
- class tibiapy.RaceEntry(last_day_killed=0, last_day_players_killed=0, last_week_killed=0, last_week_players_killed=0)[source]¶
Represents the statistics of a race.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
Library¶
CreaturesSection¶
- class tibiapy.CreaturesSection(boosted_creature, creatures)[source]¶
Represents the creature’s section in the Tibia.com library.
- boosted_creature¶
The current boosted creature.
- Type:
- creatures¶
The list of creatures in the library.
- Type:
list of
CreatureEntry
- classmethod get_url()[source]¶
Get the URL to the Tibia.com library section.
- Returns:
The URL to the Tibia.com library section.
- Return type:
- classmethod boosted_creature_from_header(content)[source]¶
Get 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]¶
Create 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 creatures section from Tibia.com.
- Return type:
- Raises:
InvalidContent – If content is not the HTML of a creature library’s page.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
Creature¶
- class tibiapy.Creature(name, identifier, **kwargs)[source]¶
Represents a creature’s details on the Tibia.com library.
- classmethod from_content(content)[source]¶
Create an instance of the class from the html content of the creature library’s page.
- classmethod get_url(identifier)¶
Get the URL to the creature’s detail page on Tibia.com.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
CreatureEntry¶
- class tibiapy.CreatureEntry(name, identifier=None)[source]¶
Represents a creature in the Library section.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
BoostableBosses¶
- class tibiapy.BoostableBosses(boosted_boss, bosses)[source]¶
Represents the boostable bosses section in the Tibia.com library
- classmethod get_url()[source]¶
Get the URL to the Tibia.com boostable bosses.
- Returns:
The URL to the Tibia.com library section.
- Return type:
- classmethod from_content(content)[source]¶
Create an instance of the class from the html content of the boostable bosses library’s page.
- Parameters:
content (
str
) – The HTML content of the page.- Returns:
The Boostable Bosses section.
- Return type:
- Raises:
InvalidContent – If content is not the HTML of a creature library’s page.
- classmethod boosted_boss_from_header(content)[source]¶
Get the boosted boss from any Tibia.com page.
- Parameters:
content (
str
) – The HTML content of a Tibia.com page.- Returns:
The boosted boss of the day.
- Return type:
- Raises:
InvalidContent – If content is not the HTML of a Tibia.com’s page.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
BoostedCreatures¶
- class tibiapy.BoostedCreatures(creature, boss)[source]¶
Contains both boosted creature and boosted boss.
- creature¶
The boosted creature of the day.
- Type:
- classmethod from_header(content: str)[source]¶
Parses both boosted creature and boss from the content of any section in Tibia.com
- Parameters:
content (
str
) – The HTML content of the page.- Returns:
The boosted creature an boss.
- Return type:
- Raises:
InvalidContent – If content is not the HTML of a Tibia.com page.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
BossEntry¶
SpellsSection¶
- class tibiapy.SpellsSection(**kwargs)[source]¶
The spells section in Tibia.com.
New in version 5.0.0.
The premium status to filter in.
True
to show only premium spells,False
to show free account spells andNone
will show any spells.- Type:
- sort_by¶
The sorting order of the displayed spells.
- Type:
- entries¶
The spells matching the selected filters.
- Type:
- classmethod from_content(content)[source]¶
Parse the content of the spells section.
- Parameters:
content (
str
) – The HTML content of the page.- Returns:
The spells contained and the filtering information.
- Return type:
- Raises:
InvalidContent – If content is not the HTML of the spells section.
- classmethod get_url(*, vocation=None, group=None, spell_type=None, premium=None, sort=None)[source]¶
Get the URL to the spells section with the desired filtering parameters.
- Parameters:
vocation (
VocationSpellFilter
, optional) – The vocation to filter in spells for.group (
SpellGroup
, optional) – The spell’s primary cooldown group.spell_type (
SpellType
, optional) – The type of spells to show.premium (
bool
, optional) – The type of premium requirement to filter.None
means any premium requirement.sort (
SpellSorting
, optional) – The field to sort spells by.
- Returns:
The URL to the spells section with the provided filtering parameters.
- Return type:
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
Spell¶
- class tibiapy.Spell(identifier, name, words, **kwargs)[source]¶
A spell listed on the spells section.
New in version 5.0.0.
- group¶
The cooldown group of the spell.
- Type:
Whether the spell requires a premium account to learn and use it.
- Type:
- soul_points¶
The number of soul points consumed by this spell. It will be
None
if not applicable.- Type:
int
, optional
- amount¶
The amount of objects created by this spell. It will be
None
if not applicable.- Type:
int
, optional
- magic_type¶
The type of magic of this spell. Influenced by specialized magic level attributes.
- Type:
str
, optional
- rune¶
Information of the rune created by this spell, if applicable.
- Type:
Rune
, optinal
- classmethod from_content(content)[source]¶
Parse the content of a spells page.
- Parameters:
content (
str
) – The HTML content of the page.- Returns:
The spell data. If the spell doesn’t exist, this will be
None
.- Return type:
- Raises:
InvalidContent – If content is not the HTML of the spells section.
- classmethod get_url(identifier)¶
Get the URL to a spell in the Tibia.com spells section.
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
SpellEntry¶
- class tibiapy.SpellEntry(identifier, name, words, **kwargs)[source]¶
A spell listed on the spells section.
New in version 5.0.0.
- identifier¶
The internal identifier of the spell. This is used as a key for links and images.
- Type:
- group¶
The cooldown group of the spell.
- Type:
Whether the spell requires a premium account to learn and use it.
- Type:
- to_json(*, indent=None, sort_keys=False)¶
Get the object’s JSON representation.
- Parameters:
- Returns:
JSON representation of the object.
- Return type:
Base Classes¶
The following classes are not meant to be used or instantiated, but are documented here for informational purposes.
They implement methods and properties that can be inherited by other classes to implement their functionality.
- class tibiapy.abc.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]¶
Get the Tibia.com URL to a board with a given id.
- classmethod get_world_boards_url()[source]¶
Get 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]¶
Get the URL to the Trade Boards section in Tibia.com.
- Returns:
The URL to the Trade Boards.
- Return type:
- 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:
- 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]¶
Get 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:
- 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, fetching_time=0)[source]¶
Exception thrown when there was a network error trying to fetch a resource from the web.
- class tibiapy.SiteMaintenanceError(message, original=None, fetching_time=0)[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, fetching_time=0)[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]¶
Convert 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, test=False, **kwargs)[source]¶
Build 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)
test (
bool
) – Whether to use the test website or not.
- 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_form_data(form: Tag, include_options=True)[source]¶
Parse the currently selected values in a form.
This should correspond to all the data the form would send if submitted.
- tibiapy.utils.parse_integer(number: str, default: Optional[int] = 0)[source]¶
Parse a string representing an integer, ignoring commas or periods.
- tibiapy.utils.parse_link_info(link_tag)[source]¶
Parse the information of a link tag.
It will parse the link’s content, target URL as well as the query parameters where applicable.
- Parameters:
link_tag (
bs4.Tag
) – The link tag object.- Returns:
A dictionary containing the link’s data.
- Return type:
Examples
>>> # <a href="https://www.tibia.com/community/?subtopic=houses&page=view&houseid=55302&world=Gladera">House</> >>> parse_link_info(link_tag) { "text": "House", "url": "https://www.tibia.com/community/?subtopic=houses&page=view&houseid=55302&world=Gladera" "query": { "subtopic": "houses", "page": "view", "houseid": "55302", "world": "Gladera" } }
When parsing links that have multiple query parameters, they are displayed as a list. Empty parameters are omitted.
>>> # <a href="https://example.com/?world=&beprotection=-1&worldtypes[]=0&worldtypes[]=3">Link</a> >>> parse_link_info(link_tag) { "text": "Link", "url": "https://example.com/?world=&beprotection=-1&worldtypes[]=0&worldtypes[]=3" "query": { "beprotection": "-1", "worldtypes": ["0", "3"] } }
- tibiapy.utils.parse_tibia_datetime(datetime_str) Optional[datetime] [source]¶
Parse 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[date] [source]¶
Parse 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]¶
Parse 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[date] [source]¶
Parse 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]¶
Parse the word representation of a number to a integer.
- tibiapy.utils.try_datetime(obj) Optional[datetime] [source]¶
Attempt 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[date] [source]¶
Attempt 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]¶
Parse HTML content from Tibia.com into a BeautifulSoup object.
- Parameters:
- Returns:
The parsed content.
- Return type:
bs4.BeautifulSoup
, optional
- tibiapy.utils.parse_tibiacom_tables(parsed_content) Dict[str, Tag] [source]¶
Parse tables from Tibia.com into a mapping by the tables title.
This is used for the table style used in Tibia.com, where a table is wrapped in a container with a title.
- Parameters:
parsed_content (
bs4.BeautifulSoup
) – The content to find the tables in.- Returns:
A dictionary mapping the container titles and the contained table.
- Return type:
- tibiapy.utils.try_enum(cls: Type[T], val, default: Optional[D] = None) Union[T, D] [source]¶
Attempt 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]¶
Parse a string that may contain ‘k’ as thousand suffix.
- tibiapy.utils.split_list(items, separator=',', last_separator=' and ')[source]¶
Split a string listing elements into an actual list.
- tibiapy.utils.parse_popup(popup_content) Tuple[str, BeautifulSoup] [source]¶
Parse the information popups used through Tibia.com.