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 main models have a get_url method that can be used to get their Tibia.com page. With the url, the html/json content can be fetched and then passed to their from_content methods.

This allows you to use any networking module to obtain the data, and use the library to parse it.

import requests
import tibiapy

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

    r = requests.get(url)
    content = r.text
    character = tibiapy.Character.from_content(content)
    return character

Supported Sections

Section

Parsing

Fetching

Characters

Character.from_content()

Client.fetch_character()

Character Bazaar (Current)

CharacterBazaar.from_content()

Client.fetch_current_auctions()

Character Bazaar (History)

CharacterBazaar.from_content()

Client.fetch_auction_history()

Character Bazaar (Detail)

AuctionDetails.from_content()

Client.fetch_auction()

Characters

Character.from_content()

Client.fetch_character()

CM Post Archive

CMPostArchive.from_content()

Client.fetch_cm_post_archive()

Creature Library (List)

CreaturesSection.from_content()

Client.fetch_library_creatures()

Creature Library (Individual)

CreatureDetail.from_content()

Client.fetch_creature()

Event Schedule

EventSchedule.from_content()

Client.fetch_event_schedule()

Guilds (Individual)

Guild.from_content()

Client.fetch_guild()

Guilds (List)

ListedGuild.list_from_content()

Client.fetch_world_guilds()

Guilds (Wars)

GuildWars.from_content()

Client.fetch_guild_wars()

Forums (Section)

ListedBoard.list_from_content()

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

Forums (Board)

ForumBoard.from_content()

Client.fetch_forum_board()

Forums (Announcement)

ForumAnnouncement.from_content()

Client.fetch_forum_announcement()

Forums (Thread)

ForumThread.from_content()

Client.fetch_forum_thread()

Highscores

Highscores.from_content()

Client.fetch_highscores_page()

Highscores

Highscores.from_content()

Client.fetch_highscores_page()

Houses (Individual)

House.from_content()

Client.fetch_house()

Houses (List)

ListedHouse.list_from_content()

Client.fetch_world_houses()

Kill Statistics (List)

KillStatistics.from_content()

Client.fetch_kill_statistics()

News (Individual)

News.from_content()

Client.fetch_news()

News (List)

ListedNews.list_from_content()

Client.fetch_news_archive() Client.fetch_recent_news()

Tournaments

Tournament.from_content()

Client.fetch_tournament()

Tournament Leaderboards

TournamentLeaderboard.from_content()

Client.fetch_tournament_leaderboard()

Worlds (Individual)

World.from_content()

Client.fetch_world()

Worlds (List)

WorldOverview.from_content()

Client.fetch_world_list()

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

The root location shows a list of the available routes.

Note

Documentation for endpoints and JSON schemas is not yet available.