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.8.tar.gz (2.6 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.8-py3-none-any.whl (2.6 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hsr_cards-1.0.8.tar.gz
  • Upload date:
  • Size: 2.6 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.8.tar.gz
Algorithm Hash digest
SHA256 8d64fbe81fe24c29ab17ca82b91952ecfd4c7fce87d6aec0903a7e6cefd7adf6
MD5 097699e0a8d039831fdd7c543a1ed63d
BLAKE2b-256 cae8bb2e4803d17468a4bb3dc77979eda9f4133fef0808c023a1d53adeeb6e8d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hsr_cards-1.0.8-py3-none-any.whl
  • Upload date:
  • Size: 2.6 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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 2a5a3a8c4d8ac85643151b8116f59b93789581ed42a69052ad94682e2bbae47c
MD5 1f75ee8abc96a8998d9bd909946714de
BLAKE2b-256 cf787c4a635fe301151470bddcee17fe8c27cdc675dd49432adf6e11627d6898

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