Skip to main content

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

Anomaly card

Pure Fiction (PF)

PF card 1 PF card 2

Memory of Chaos (MOC)

MOC card 1 MOC card 2

Apocalyptic Shadow (AS)

AS card 1 AS card 2

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 card
  • PF(schedule_type) → Image: Generate Pure Fiction card
  • MOC(schedule_type) → Image: Generate Memory of Chaos card
  • shadow(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


Download files

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

Source Distribution

hsr_cards-1.0.7.tar.gz (2.4 MB view details)

Uploaded Source

Built Distribution

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

hsr_cards-1.0.7-py3-none-any.whl (2.4 MB view details)

Uploaded Python 3

File details

Details for the file hsr_cards-1.0.7.tar.gz.

File metadata

  • Download URL: hsr_cards-1.0.7.tar.gz
  • Upload date:
  • Size: 2.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hsr_cards-1.0.7.tar.gz
Algorithm Hash digest
SHA256 72b15f626db24b82e28389b73158e92d76d8973ac56bfec45db43454405e394e
MD5 f2503d0b16f359dbc48c4fc3da0f1aad
BLAKE2b-256 a1ade3ebbc3442a1dd5472ba6b128c0f626d2d885d55a2108a6743516487a7ea

See more details on using hashes here.

File details

Details for the file hsr_cards-1.0.7-py3-none-any.whl.

File metadata

  • Download URL: hsr_cards-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hsr_cards-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 02397b5099d78cd1d26d5786fc139107ed65189982b83ceb011266885da4d6ea
MD5 a5d819a0c5700796b0ba8941fd38f1c9
BLAKE2b-256 a91c4ffd7bac037dfcf445471c9f0a39b64b3464a202ef8bda8c71c724fc6348

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