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.1.6.tar.gz (21.7 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.1.6-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for kirkaio-1.1.6.tar.gz
Algorithm Hash digest
SHA256 9b81bb6515c7285113ca4415fcc32d154f714c1e676c3eb830308d3a06e5277c
MD5 e374308caafc83d122f2658d6733f0a1
BLAKE2b-256 6a53e5ed10a1411d1b389ac6d39f27c417dfb9569da777b021900b535ce4de91

See more details on using hashes here.

Provenance

The following attestation bundles were made for kirkaio-1.1.6.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.1.6-py3-none-any.whl.

File metadata

  • Download URL: kirkaio-1.1.6-py3-none-any.whl
  • Upload date:
  • Size: 16.1 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.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ead61d9b1639e6b6d1b97efe91065c03e3fdde779b605aafeadc715ad0b84cd1
MD5 446f5281b1d8eb9110671bd99447e60b
BLAKE2b-256 f5c572cfed6a198a58ec0a7fb7e87a00632e94b35b7edb71112d9b829f7097c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for kirkaio-1.1.6-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