Skip to main content

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.

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for hsr_cards-1.0.9.tar.gz
Algorithm Hash digest
SHA256 c322fee817cf4f6c3b90986d950e164f819a16a7ecdd4a7d1930dd6326d112b1
MD5 f73f18984f45a84232bc4b85e755145f
BLAKE2b-256 3482406d0d7378db46e7ec0bc8f339818753ced59faeca4aad953cae7bc971ac

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hsr_cards-1.0.9-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.14

File hashes

Hashes for hsr_cards-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 d48466f4940b7bc8976d13dc5d36e617f2b094b861e836c0e974aabd9c6531d2
MD5 4e83f3b6500ab6f76d906d3332b91f93
BLAKE2b-256 11c4947194ba62178c13db0e10b197f249acb6ceff7139432f3d28ac5fefa65b

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.9 This release

2 files

1.0.8

2 files

1.0.7

2 files

1.0.6

2 files

1.0.1

2 files

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