Skip to content

Galarzaa90/tibia.py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

609aa01 · Oct 31, 2024
Oct 2, 2024
Mar 26, 2024
May 25, 2024
Oct 31, 2024
Oct 31, 2024
Aug 24, 2023
Dec 16, 2023
Aug 21, 2023
May 14, 2024
Apr 6, 2024
May 14, 2024
Aug 7, 2018
Jan 8, 2019
Oct 31, 2024
Oct 31, 2024
May 14, 2024
Mar 26, 2024
May 14, 2024
Dec 14, 2023
Apr 17, 2024
Oct 2, 2024
Mar 26, 2024

Repository files navigation

Tibia.py

An API to parse Tibia.com content into object oriented data.

No fetching is done by this module, you must provide the html content.

PyPI GitHub commits since latest release (branch) PyPI - Python Version PyPI - License PyPI - Downloads

Code Smells Coverage Lines of Code Reliability Rating Technical Debt Maintainability Rating

Features:

  • Converts data into well-structured Python objects.
  • Type consistent attributes.
  • All objects can be converted to JSON strings.
  • Can be used with any networking library.
  • Support for characters, guilds, houses and worlds, tournaments, forums, etc.

Installing

Install and update using pip

pip install tibia.py

Installing the latest version form GitHub

pip install git+https://github.com/Galarzaa90/tibia.py.git -U

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.

import tibiapy

# Asynchronously
import aiohttp

async def get_character(name):
    url = tibiapy.urls.get_character_url(name)

    async with aiohttp.ClientSession() as session:
        async with session.get(url) as resp:
            content = await resp.text()
    character = tibiapy.Character.from_content(content)
    return character

# Synchronously
import requests

def get_character_sync(name):
    url = tibiapy.urls.get_character_url(name)
    
    r = requests.get(url)
    content = r.text
    character = tibiapy.Character.from_content(content)
    return character

Running from 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.

docker build . -t tibia.py:local

To run the image:

docker run -p 8000:8000 --rm -ti tibia.py:local

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

Documentation

https://tibiapy.readthedocs.io/