Skip to main content

Habiticalib

Modern asynchronous Python client library for the Habitica API

build codecov PyPI version PyPI - Downloads 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!

Release files for Habiticalib 0.4.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Habiticalib 0.4.7
File Size Uploaded
habiticalib-0.4.7.tar.gz 125.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Habiticalib 0.4.7
File Interpreter ABI Platform
habiticalib-0.4.7-py3-none-any.whl Python 3 none any Details

Total release size: 168.9 kB

Release files / habiticalib-0.4.7.tar.gz

Download URL habiticalib-0.4.7.tar.gz
Size 125.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9fd2eae8f0775ade78dbcad6a1c23426d35ba4dd45b25ed8d218743837dede49
BLAKE2b-256 checksum
How to use checksums
874fc3786534724b88248f3bc4b1eb8a15b6405c71cef0de6963bc901f2789ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via Hatch/1.16.5 cpython/3.12.3 HTTPX/0.28.1

Release files / habiticalib-0.4.7-py3-none-any.whl

Download URL habiticalib-0.4.7-py3-none-any.whl
Size 43.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b9fb280235986758db82195aaf2785d0d7ddba5abfb7012d1ea0f7e2566a7e40
BLAKE2b-256 checksum
How to use checksums
e2ba516096bf0b029df9fc3e51a4aba355a82b84b75fd450efd141264ca0ed8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via Hatch/1.16.5 cpython/3.12.3 HTTPX/0.28.1
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page