Skip to main content

Cordia

The official Python analytics SDK for Discord bots.

Async-first design built on aiohttp. Tracks commands, users, server count, and uptime with automatic batching and background heartbeat.

PyPI License: MIT

Install

pip install cordia

Requires Python 3.8+.

Quick Start

import cordia
import os

# pass your discord.py bot/client instance
client = cordia.CordiaClient(
    api_key=os.getenv("CORDIA_API_KEY"),
    bot=bot,  # bot_id auto-detected from bot.user.id
)

Discord.py Example

import discord
from discord.ext import commands
import cordia
import os

intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)

cordia_client = cordia.CordiaClient(
    api_key=os.getenv("CORDIA_API_KEY"),
    bot=bot,  # bot_id + shard metadata auto-detected
)

@bot.event
async def on_ready():
    print(f"Logged in as {bot.user}")
    await cordia_client.post_guild_count(len(bot.guilds))
    cordia_client.start(bot.loop)

@bot.command()
async def ping(ctx):
    await ctx.send("Pong!")
    await cordia_client.track_command(
        command="ping",
        user_id=str(ctx.author.id),
        guild_id=str(ctx.guild.id) if ctx.guild else None,
    )

bot.run(os.getenv("DISCORD_TOKEN"))

Configuration

Parameter Type Default Description
api_key str required API key from the Cordia dashboard
bot discord.Client recommended Discord.py bot/client for bot_id + shard auto-detection
bot_id str optional Manual bot ID override (rarely needed)
heartbeat_interval int 30000 Heartbeat interval (ms)
auto_heartbeat bool True Start heartbeat on start()
batch_size int 10 Events before auto-flush
flush_interval int 5000 Auto-flush interval (ms)
debug bool False Enable debug logging

API

Method Description
start(loop) Start background tasks (flush + heartbeat)
track_command(...) Queue a command event
track_user(...) Queue a user activity event
post_guild_count(count) Report server count (immediate)
start_heartbeat(loop) Start heartbeat manually
stop_heartbeat() Stop heartbeat
get_uptime() Returns uptime in ms
flush() Force-flush queued events
close() Stop tasks, flush, and close session

Documentation

Full guides and API reference at docs.cordialane.com.

License

MIT

Metadata

Release files for cordia 1.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cordia 1.2.3
File Size Uploaded Provenance Actions
cordia-1.2.3.tar.gz 8.9 kB Without provenance Details for cordia-1.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cordia 1.2.3
File Interpreter ABI Platform Actions
cordia-1.2.3-py3-none-any.whl Python 3 none any Details for cordia-1.2.3-py3-none-any.whl

Total release size: 17.0 kB

Release files / cordia-1.2.3.tar.gz

Download URL cordia-1.2.3.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2138fed632f2046576fece635a76a2f2c4adf19d6fecbd16ef726041900a676c
BLAKE2b-256 checksum
How to use checksums
81fc96fac29b7ee0146b5db3d438b489c567b491cb5474672a86edfc98ef898f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / cordia-1.2.3-py3-none-any.whl

Download URL cordia-1.2.3-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46f281423a7e8a65fed7af0a5557acc0862f9286131200fc61ddabbf04cf730e
BLAKE2b-256 checksum
How to use checksums
4ea06c8e80ccdc918272999b55da871d8087c0b3efd0cc654ce50ea1036c8ed5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for cordia 1.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.2.3 This release

2 release files No provenance

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