Async Python client for the Kirka Public API
Project description
kirkaio
Async Python client for the Kirka Public API.
Made by gayboi.club for the kirka.io community :3
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kirkaio-1.1.5.tar.gz.
File metadata
- Download URL: kirkaio-1.1.5.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc3b746444fd6788ea64cc05edd98094be7e35c9c2be9c7dee326ceaa9894212
|
|
| MD5 |
e269bbf08f5a927d10ef65ca87143d98
|
|
| BLAKE2b-256 |
bc5493405da1e7961345a9bc4e5d9c2be788fcb16a3cccb0eafe9f0d75077907
|
Provenance
The following attestation bundles were made for kirkaio-1.1.5.tar.gz:
Publisher:
publish.yml on gayboi-club/kirkaio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kirkaio-1.1.5.tar.gz -
Subject digest:
bc3b746444fd6788ea64cc05edd98094be7e35c9c2be9c7dee326ceaa9894212 - Sigstore transparency entry: 1234723592
- Sigstore integration time:
-
Permalink:
gayboi-club/kirkaio@ccc57bb40f8cc40a07b963d2ea17452162c16588 -
Branch / Tag:
refs/tags/v1.1.5 - Owner: https://github.com/gayboi-club
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ccc57bb40f8cc40a07b963d2ea17452162c16588 -
Trigger Event:
release
-
Statement type:
File details
Details for the file kirkaio-1.1.5-py3-none-any.whl.
File metadata
- Download URL: kirkaio-1.1.5-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
519afbc8842964eddbc0a5e48b92df5f1f09a428357a112899516a706c214524
|
|
| MD5 |
2458fb3d795d9bda626a97ac555931e6
|
|
| BLAKE2b-256 |
ed2c9b7692e6c8bd7ac0fea26d998ce177e478a6e2f638357aeb0cda25069a76
|
Provenance
The following attestation bundles were made for kirkaio-1.1.5-py3-none-any.whl:
Publisher:
publish.yml on gayboi-club/kirkaio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kirkaio-1.1.5-py3-none-any.whl -
Subject digest:
519afbc8842964eddbc0a5e48b92df5f1f09a428357a112899516a706c214524 - Sigstore transparency entry: 1234723646
- Sigstore integration time:
-
Permalink:
gayboi-club/kirkaio@ccc57bb40f8cc40a07b963d2ea17452162c16588 -
Branch / Tag:
refs/tags/v1.1.5 - Owner: https://github.com/gayboi-club
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ccc57bb40f8cc40a07b963d2ea17452162c16588 -
Trigger Event:
release
-
Statement type: