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

Uploaded Python 3

File details

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

File metadata

  • Download URL: hsr_cards-1.0.6.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.6.tar.gz
Algorithm Hash digest
SHA256 c2c59c3fba1520a3ad06469ee6e480cb00f1fd908b7cd9e1059d3cd7e44e79be
MD5 e0a10c408acd85ad8fb3290a81174bf7
BLAKE2b-256 f754d6e5cee8fb114e1175ac177c33ded9632d0a3f1aa8192589bb67d964047b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hsr_cards-1.0.6-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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9bd6ff98ad569f76da12c54ea764e4886ac5ada679eec9cc358f98e8c96b813c
MD5 a94683ceb79dde96790fd3acb9f12a7d
BLAKE2b-256 f6cdf7bd81b1d0c7f68864a76bb12662295c3974a1ef2a70cf4ab0cd9ec17e8c

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