Skip to main content

Async Python client for the Kirka Public API

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

kirkaio

Async Python client for the Kirka Public API.

Made by gayboi.club for the kirka.io community :3

License Python Version

Installation

pip install kirkaio

Requires Python 3.11+.

Quickstart :3

import asyncio
from kirkaio import KirkaClient

async def main():
    async with KirkaClient("YOUR_API_KEY") as client:
        # Look up a player
        user = await client.get_user("BOTTOM")
        print(f"{user.name} - Level {user.level}")
        print(f"K/D: {user.stats.kd_ratio}  Win Rate: {user.stats.win_rate}%")

        # Clan info
        clan = await client.get_clan("Meowers")
        print(f"{clan.name} - War Position #{clan.current_war_position}")

        # Leaderboard
        lb = await client.get_solo_leaderboard()
        for i, entry in enumerate(lb.results[:5], 1):
            print(f"#{i} {entry.name} - {entry.scores} pts")

        # Quests
        quests = await client.get_quests()
        if quests:
            print(f"Active quests: {len(quests)}")
            print(f"First quest: {quests[0].name} ({quests[0].rarity})")

if __name__ == "__main__":
    asyncio.run(main())

API Key

Get your API key by joining the Kirka Discord :3 Set it as an environment variable for the CLI:

export KIRKA_API_KEY="your_key_here"

Features

  • Fully async - built on aiohttp.
  • Typed models - all responses deserialize into Python dataclasses.
  • TTL caching - avoid redundant requests (configurable, default 60s).
  • Rate limit handling - auto-retry with Retry-After back-off.
  • CLI tool - quick lookups straight from your terminal :3
  • Global Chat Bot - experimental websocket listener for the global chat.

Client Options

KirkaClient(
    api_key="...",
    cache_ttl=60.0,           # seconds; set 0 to disable
    retry_on_rate_limit=True,  # auto-retry on 429
)

CLI Usage

# Player profile
kirkaio user BOTTOM

# Clan details
kirkaio clan Meowers

# Leaderboards: solo | clan | sad | 1v1 | 2v2
kirkaio leaderboard solo

# Active quests
kirkaio quests
kirkaio quests --type event

Available Methods :3

Method Description
get_user(id, is_short_id=True) Player profile by shortId or UUID
get_quests(type=None) Active quests
get_user_inventory(id, is_short_id=True) User's inventory
get_all_items() All public game items
get_solo_leaderboard() Solo scores leaderboard
get_clan_leaderboard() Clan championship leaderboard
get_ranked_sad_leaderboard() Ranked SAD leaderboard
get_ranked_1v1_leaderboard() Ranked 1v1 leaderboard
get_ranked_2v2_leaderboard() Ranked 2v2 leaderboard
get_clan(name) Clan details + members

Global Chat Bot (Experimental)

[!WARNING] Using an automated bot in the Kirka global chat is against Kirka's Terms of Service and could result in an account ban. We do not condone the use of this feature, use it at your own risk.

import asyncio
from kirkaio import KirkaChatBot

async def main():
    def ping_handler(packet):
        return "Pong!"
        
    bot = KirkaChatBot("your_token", "your_refresh_token")
    bot.add_command("ping", ping_handler)
    
    await bot.listen()

if __name__ == "__main__":
    asyncio.run(main())

Raw Message Handler

You can also hook into every raw websocket message for logging, analytics, or custom packet handling:

import asyncio
from kirkaio import KirkaChatBot

async def on_raw_message(data, ws):
    print(f"Received packet type: {data.get('type')}")

async def main():
    bot = KirkaChatBot("your_token", "your_refresh_token")
    bot.set_raw_handler(on_raw_message)
    await bot.listen()

if __name__ == "__main__":
    asyncio.run(main())

On Connect Handler

You can also run logic immediately after the bot successfully connects to the WebSocket server using set_on_connect:

import asyncio
from kirkaio import KirkaChatBot

async def on_connect(ws):
    print("Successfully connected to the Kirka chat server!")
    # Send an initial message
    await ws.send_str("Hello World!")

async def main():
    bot = KirkaChatBot("your_token", "your_refresh_token")
    bot.set_on_connect(on_connect)
    await bot.listen()

if __name__ == "__main__":
    asyncio.run(main())

Credentials Recovery

By default, KirkaChatBot saves its tokens to creds.json whenever it refreshes them. Upon starting, the bot will automatically read creds.json (if it exists) to securely load the newest valid tokens, preventing authentication mismatches and disconnects on startup. You can change the credentials file name by passing creds_file="my_creds.json" during initialization.

Error Handling

from kirkaio import KirkaClient, NotFoundError, RateLimitError, AuthenticationError

async with KirkaClient("...") as client:
    try:
        user = await client.get_user("SOMEONE")
    except NotFoundError:
        print("Player not found")
    except RateLimitError:
        print("Slow down!")
    except AuthenticationError:
        print("Bad API key")

License

This project is licensed under the MIT License :3 See the LICENSE file for details :P

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

kirkaio-1.2.0.tar.gz (21.9 kB view details)

Uploaded Source

Built Distribution

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

kirkaio-1.2.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file kirkaio-1.2.0.tar.gz.

File metadata

  • Download URL: kirkaio-1.2.0.tar.gz
  • Upload date:
  • Size: 21.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kirkaio-1.2.0.tar.gz
Algorithm Hash digest
SHA256 6f9cfe72ae250c3ea633edcdb29e797c0aa3852220a6e9f2cb7e6c633a4b855e
MD5 2af3f8363b8f5463d7a4f6e47ac8eb94
BLAKE2b-256 03f0c602b2113d1107cc8a7dad64c5d8500f5056ce1330971e8cc766aac7a59d

See more details on using hashes here.

Provenance

The following attestation bundles were made for kirkaio-1.2.0.tar.gz:

Publisher: publish.yml on gayboi-club/kirkaio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kirkaio-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: kirkaio-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kirkaio-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 903c34b680c061e4c10fb092d3e5d8b5af5cf5536dd87044180914d117dff877
MD5 9311f7ecd11fe58148a146a7fe7dd6c8
BLAKE2b-256 36324f277ddd73ca191b933ccde3762ab0ba8735ca1735df396f36e556dcebfd

See more details on using hashes here.

Provenance

The following attestation bundles were made for kirkaio-1.2.0-py3-none-any.whl:

Publisher: publish.yml on gayboi-club/kirkaio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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