Introduction

Prerequisites

Tibia.py requires Python 3.6 or higher. Dependencies are installed automatically when installing the package.

However, since it uses lxml for parsing, on Linux you may require to install libxml on your system.

sudo apt-get install libxml2-dev libxslt-dev python-dev

Windows users are usually safe from this. For more information check out lxml installation page.

Installation

Tibia.py can be installed from PyPi using:

python -m pip install tibia.py

Usage

This library is composed of two parts, parsers and an asynchronous request client.

The asynchronous client (tibiapy.Client) contains methods to obtain information from Tibia.com.

The parsing methods allow you to get Python objects given the HTML content of a page.

The tibiapy.urls package contains many methods to get URLs for Tibia.com.

With the URL, the HTML content can be fetched and then passed to the respective class from the available Parsers.

This allows you to use any networking library (e.g. aiohttp, requests, httpx) to obtain the data, and use the library to parse it.

import requests
import tibiapy
from tibiapy.parsers import CharacterParser

# Fetching a character using requests instead of aiohttp
def get_character(name):
    url = tibiapy.urls.get_character_url(name)

    r = requests.get(url)
    content = r.text
    return CharacterParser.from_content(content)

On the other hand, using the built-in asynchronous client you can do the fetching and parsing in one step:

import asyncio
import tibiapy

async def main():
    client = tibiapy.Client()
    character = await client.fetch_character("Galarzaa Fidera")
    await client.session.close()

if __name__ == "__main__":
    asyncio.get_event_loop().run_until_complete(main())

Supported Sections

Section

Parsing

Fetching

Boostable Bosses (List)

tibiapy.parsers.BoostableBossesParser.from_content()

Client.fetch_boostable_bosses()

Characters

tibiapy.parsers.CharacterParser.from_content()

Client.fetch_character()

Character Bazaar (Current)

tibiapy.parsers.CharacterBazaarParser.from_content()

Client.fetch_current_auctions()

Character Bazaar (History)

tibiapy.parsers.CharacterBazaarParser.from_content()

Client.fetch_auction_history()

Character Bazaar (Detail)

tibiapy.parsers.AuctionParser.from_content()

Client.fetch_auction()

CM Post Archive

tibiapy.parsers.CMPostArchiveParser.from_content()

Client.fetch_cm_post_archive()

Creature Library (List)

tibiapy.parsers.CreaturesSectionParser.from_content()

Client.fetch_creatures()

Creature Library (Individual)

tibiapy.parsers.CreatureParser.from_content()

Client.fetch_creature()

Event Schedule

tibiapy.parsers.EventScheduleParser.from_content()

Client.fetch_event_schedule()

Guilds (Individual)

tibiapy.parsers.GuildParser.from_content()

Client.fetch_guild()

Guilds (List)

tibiapy.parsers.GuildsSectionParser.from_content()

Client.fetch_world_guilds()

Guilds (Wars)

tibiapy.parsers.GuildWarsParser.from_content()

Client.fetch_guild_wars()

Fansites

tibiapy.parsers.FansitesSectionParser.from_content()

Client.fetch_fansites_section()

Forums (Section)

tibiapy.parsers.ForumSectionParser.from_content()

Client.fetch_forum_world_boards() Client.fetch_forum_trade_boards() Client.fetch_forum_community_boards() Client.fetch_forum_support_boards()

Forums (Board)

tibiapy.parsers.ForumBoardParser.from_content()

Client.fetch_forum_board()

Forums (Announcement)

tibiapy.parsers.ForumAnnouncementParser.from_content()

Client.fetch_forum_announcement()

Forums (Thread)

tibiapy.parsers.ForumThreadParser.from_content()

Client.fetch_forum_thread()

Highscores

tibiapy.parsers.HighscoresParser.from_content()

Client.fetch_highscores_page()

Houses (Individual)

tibiapy.parsers.HouseParser.from_content()

Client.fetch_house()

Houses (List)

tibiapy.parsers.HousesSectionParser.from_content()

Client.fetch_houses_section()

Kill Statistics (List)

tibiapy.parsers.KillStatisticsParser.from_content()

Client.fetch_kill_statistics()

Leaderboards

tibiapy.parsers.LeaderboardParser.from_content()

Client.fetch_leaderboard()

News (Individual)

tibiapy.parsers.NewsParser.from_content()

Client.fetch_news()

News (List)

tibiapy.parsers.NewsArchiveParser.from_content()

Client.fetch_news_archive() Client.fetch_news_archive_by_days()

Spell Library (List)

tibiapy.parsers.SpellsSectionParser.from_content()

Client.fetch_spells()

Spell Library (Individual)

tibiapy.parsers.SpellParser.from_content()

Client.fetch_spell()

Worlds (Individual)

tibiapy.parsers.WorldParser.from_content()

Client.fetch_world()

Worlds (List)

tibiapy.parsers.WorldOverviewParser.from_content()

Client.fetch_world_overview()

Docker

A ready to use HTTP server is also available as a Docker image, allowing you to integrate tibia.py in projects using other languages other than Python.

The image can be pulled from Docker Hub:

docker pull galarzaa90/tibia.py

Alternatively, the image can be built from the root of the project’s source.

To run the image:

docker run \
    -p 8000:8000 \
    --rm -ti \
    galarzaa90/tibia.py

API documentation will be available at: http://localhost:8000/docs.