A library to generate Honkai Star Rail player stats cards with async support
Project description
Honkai Star Rail Cards
A Python library to generate beautiful battle cards for Honkai Star Rail .
Features
- Render player anomaly cards
- Generate Pure Fiction (PF) stats cards
- Create Memory of Chaos (MOC) cards
- Generate Apocalyptic Shadow (AS) cards
- Clean, type-hinted interface
Installation
From PyPI (coming soon)
pip install hsr-cards
From source
git clone https://github.com/MR-LORD-REX/hsr-cards.git
cd hsr-cards
pip install -e .
Quick Start
from hsr_cards import HonkaiStarrail
import asyncio
import os
from dotenv import load_dotenv
load_dotenv()
async def test():
try:
os.makedirs("Cards", exist_ok=True)
async with HonkaiStarrail("800556377") as client:
img=await client.anomaly()
img.save(f"Cards/Anomaly.png")
print(f"saved Cards/Anomaly.png")
for i in range(1,3):
img=await client.PF(schedule_type=str(i))
img.save(f"Cards/PF_{i}.png")
print(f"saved Cards/PF_{i}.png")
img=await client.MOC(schedule_type=str(i))
img.save(f"Cards/MOC_{i}.png")
print(f"saved Cards/MOC_{i}.png")
img=await client.shadow(schedule_type=str(i))
img.save(f"Cards/AS_{i}.png")
print(f"saved Cards/AS_{i}.png")
except Exception as e:
print(f"Error during test: {e}")
pass
asyncio.run(test())
Preview
Below are some example cards generated by this library.
Anomaly
Pure Fiction (PF)
Memory of Chaos (MOC)
Apocalyptic Shadow (AS)
Requirements
- Python 3.10+
- aiohttp
- Pillow (PIL)
- python-dotenv
- asyncio
API Reference
HonkaiStarrail(uid)
Main client class for generating cards.
Parameters:
uid(int | str): Your Honkai Star Rail UID
Methods:
anomaly()→ Image: Generate anomaly cardPF(schedule_type)→ Image: Generate Pure Fiction cardMOC(schedule_type)→ Image: Generate Memory of Chaos cardshadow(schedule_type)→ Image: Generate Apocalyptic Shadow card
All methods are async and return PIL Image objects.
Environment Variables
Create a .env file in your project root (see .env_example):
ltoken_v2=v2_CAISdKm9p8FxQ3sZ4gT0RJlkfFn3NbX7tCmmE9ff0ZqjKaB2xPkHYqThZsFQPP5is4NCd2Rjc19vdmVyc2Vh.GxGYbRBBBBBD.MVRCIDFy85cHYgYnvbC4tLpI8wZx0NKq0nq5SKz6o9cE1h_hCjBq2igWd0n4ZBU1rSI52elPNjsgFHz2IRrKLbuI8O7lB
ltuid_v2=242012003
License
MIT License - see LICENSE file for details
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Disclaimer
This library is not affiliated with or endorsed by HoYoverse. Use at your own risk and in compliance with the game's Terms of Service.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hsr_cards-1.0.2.tar.gz.
File metadata
- Download URL: hsr_cards-1.0.2.tar.gz
- Upload date:
- Size: 1.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
772357e4ce2acdcad1348ff826f0e535a1af9a25bd2f61f4e072c0b39ef846f2
|
|
| MD5 |
1dcc3cb4341c7a8fb7b0aced7dee717b
|
|
| BLAKE2b-256 |
2862f7ce8fa911ff5fc4c7bf9d5c2be1f10881932e293f3d18e018905f68308e
|
File details
Details for the file hsr_cards-1.0.2-py3-none-any.whl.
File metadata
- Download URL: hsr_cards-1.0.2-py3-none-any.whl
- Upload date:
- Size: 2.0 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7cdcd530fcee60b2b3563123f425170533589e985fa35efe22d3d3bc190377d
|
|
| MD5 |
380de72831ef50d7db1ac7b81ad1d7c8
|
|
| BLAKE2b-256 |
3ee9f9f95008a1d5ea0478cca154e2dae201466b9cb80e8658173ef7134f9399
|