Skip to main content

Asynchronous Python client library for the Habitica API

Project description

Habiticalib

Modern asynchronous Python client library for the Habitica API

build codecov PyPI version PyPI - Downloads "Buy Me A Coffee" GitHub Sponsor


Habiticalib is a Python library for interacting with the Habitica API. It provides an organized, typed interface to work with Habitica’s features, including tasks, user data, and avatars. The goal of this library is to simplify integration with Habitica.

Key features

  • Asynchronous: The library is fully asynchronous, allowing non-blocking API calls.
  • Fully typed with Dataclasses: The library is fully typed using Python dataclasses. It handles serialization with mashumaro and orjson for efficient conversion between Habitica API JSON data and Python objects.
  • Dynamic avatar image generation: Habiticalib can fetch all necessary assets (like equipped items, pets, and mounts) and combine them into a single avatar image. This image can be saved to disk or returned as a byte buffer for further processing.
  • Fetch user data: Retrieve and manage user data such as stats, preferences, and items. User data is structured with dataclasses to make it easy to work with.
  • Task management: Support for creating, updating, and retrieving Habitica tasks (to-dos, dailies, habits, rewards) is provided.
  • Task status updates: The library allows updates for task statuses, habit scoring, and daily completion.
  • Tags: Habiticalib supports the creation, updating and deletion of tags.
  • Stat allocation, class cystem and sleep: The library offers methods for stat point allocation and switching between Habitica classes. It also provides the ability to disable the class system and pausing damage(resting in the inn)

📖 Documentation


📦 Installation

pip install habiticalib

🚀 Getting started

Here’s an example to demonstrate basic usage:

import asyncio

from aiohttp import ClientSession

from habiticalib import Habitica, TaskType


async def main():
    async with ClientSession() as session:
       habitica = Habitica(session)

       # Login to Habitica
       habitica.login(username="your_username", password="your_password")

       # Fetch user data
       user_data = await habitica.user()
       print(f"Your current health: {user_data.stats.hp}")

        # Fetch all tasks (to-dos, dailies, habits, and rewards)
        tasks = await habitica.get_tasks()
        print("All tasks:")
        for task in tasks:
            print(f"- {task.text} (type: {task.type})")

        # Fetch only to-dos
        todos = await habitica.get_tasks(task_type=TaskType.TODO)
        print("\nTo-Do tasks:")
        for todo in todos:
            print(f"- {todo.text} (due: {todo.date})")

        # Fetch only dailies
        dailies = await habitica.tasks(task_type=TaskType.DAILY)
        print("\nDailies:")
        for daily in dailies:
            print(f"- {daily.text}")

asyncio.run(main())

🛠️ Contributing

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a new branch.
  3. Make your changes and commit them.
  4. Submit a pull request.

Make sure to follow the contributing guidelines.


📜 License

This project is licensed under the MIT License - see the LICENSE file for details.


❤️ Support

If you find this project useful, consider buying me a coffee ☕ or sponsoring me on GitHub!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

habiticalib-0.4.4.tar.gz (125.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

habiticalib-0.4.4-py3-none-any.whl (43.1 kB view details)

Uploaded Python 3

File details

Details for the file habiticalib-0.4.4.tar.gz.

File metadata

  • Download URL: habiticalib-0.4.4.tar.gz
  • Upload date:
  • Size: 125.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for habiticalib-0.4.4.tar.gz
Algorithm Hash digest
SHA256 629506a2be9cfb92609c4385550e1990b755de010b6a107ff222d6186d27f69e
MD5 e34b46839fde4354389414d8cff8b600
BLAKE2b-256 c193b53c610d1585570b7bbf1dbaeacceb2b043fc78144eaa7347aaa8aca6155

See more details on using hashes here.

File details

Details for the file habiticalib-0.4.4-py3-none-any.whl.

File metadata

  • Download URL: habiticalib-0.4.4-py3-none-any.whl
  • Upload date:
  • Size: 43.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for habiticalib-0.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3297392682334d6af849a4ec8f4c348a89dade1f41495a669d21e3442ab1124a
MD5 d7414973604000863160e330901439fa
BLAKE2b-256 8be34745ea154920fafeee41f481f318381f045bf15abfe5df9ef2377eeb8676

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page