Asynchronous Python client library for the Habitica API
Project description
Habiticalib
Modern asynchronous Python client library for the Habitica API
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 withmashumaro
andorjson
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)
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())
Documentation
For full documentation and detailed usage examples, please visit the Habiticalib documentation.
License
This project is licensed under the terms of the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file habiticalib-0.1.0a2.tar.gz
.
File metadata
- Download URL: habiticalib-0.1.0a2.tar.gz
- Upload date:
- Size: 66.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: python-httpx/0.27.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f612a19f9a62f1bfa36da4e7d81242399843c459868a754f65a8de0f7aa827de |
|
MD5 | e87232177b568932a872d226d5988c28 |
|
BLAKE2b-256 | 1a8e3802baf4a780e023b530abf991f561b1025a2d7054c4c1055d2c4e746c61 |
File details
Details for the file habiticalib-0.1.0a2-py3-none-any.whl
.
File metadata
- Download URL: habiticalib-0.1.0a2-py3-none-any.whl
- Upload date:
- Size: 23.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: python-httpx/0.27.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93795c18c8e7a5ae587b0d30b29d39c5d98b32bd58356e63320d58dcf0cf22bd |
|
MD5 | b09645f2c8dd3e7c45884e817c3a78ec |
|
BLAKE2b-256 | bf3af4668b9f094900cb297a23ba61ab3557000dedbbead0d96db4c3eef4f51f |