This release is a pre-release and may not be stable for production use.
MarkanM Python SDK
Python SDK for the MarkanM bot API: bot identity, room messages, command/event dispatch, polling, signed webhooks, and an OpenAI-compatible AI helper. The server currently exposes GET /me, POST /rooms/{roomId}/messages, and POST /polling under /api/bot/v1; methods for other platform features are not advertised until the backend supports them.
Requirements and install
- Python 3.9 or newer (the SDK uses
asyncio.to_thread). httpxis installed with the package; it provides async HTTP and TLS handling.
python -m pip install markanm
On Kali Linux and other Debian based distributions, system Python may be externally managed (PEP 668). Do not use sudo pip or force --break-system-packages. Create a virtual environment:
sudo apt update
sudo apt install python3-venv python3-pip
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install markanm
If venv reports that ensurepip is unavailable, install the matching python3-venv package for your Kali Python version, then recreate the environment. Activate .venv in each new shell before running the bot. Use the system package manager for OS packages; avoid sudo pip.
Quick start: polling bot
Create a bot and copy its token from the MarkanM developer portal. Keep the token in an environment variable:
export MARKANM_BOT_TOKEN="mkbot_..."
import os
from markanm import Bot
bot = Bot(os.environ["MARKANM_BOT_TOKEN"])
@bot.command("hello")
async def hello(ctx):
await ctx.reply(f"Hello, {ctx.user.display_name or 'there'}!")
@bot.on("command.received")
async def log_command(event):
print(event.id, event.type)
bot.run_polling(interval=2.0)
Run python bot.py. Polling is intended for local development and simple deployments. Since the server marks fetched events as delivered before your handlers finish, keep handlers fast and make side effects safe to repeat. For hosted production bots, configure a webhook.
API methods
profile = await bot.get_me()
result = await bot.send_message(room_id="123", text="Hi")
await bot.poll_once() # fetch one batch and dispatch it
bot.stop() # request run_polling() to stop
send_message accepts an optional card dictionary. The current backend stores card content as a formatted text message; it does not yet expose interactive button callbacks. CommandContext provides command, text, args, user, room, room_id, message, and await ctx.reply(text).
@bot.on("event.type") registers event listeners. Handlers may be synchronous or async def. Handler errors are logged and do not stop polling. Event exposes id, type, timestamp, payload, and raw_data.
Webhooks
The webhook signature is X-MarkanM-Signature: t=UNIX_SECONDS,v1=HEX_HMAC_SHA256, computed over timestamp + "." + exact_raw_body with the bot webhook secret. Preserve the raw request bytes before JSON parsing and pass the exact body to the SDK:
event = await bot.handle_webhook(raw_body, request.headers["X-MarkanM-Signature"])
The default accepted timestamp drift is five minutes. Webhook event formats follow the same Event model as polling.
AI helper
The AI helper supports OpenAI, Groq, Mistral, DeepSeek, Together, Perplexity, Sarvam, Anthropic, Gemini, Cohere, Hugging Face, Ollama, OpenRouter, and custom OpenAI-compatible endpoints:
from markanm import AI
ai = AI(provider="openai", api_key=os.environ["OPENAI_API_KEY"], model="gpt-4o-mini")
answer = await ai.chat("Suggest a greeting") # keeps in-memory conversation history
ai.reset()
AI calls use your provider credentials directly and are billed by that provider. Do not put provider keys in client side code.
Errors and network troubleshooting
All SDK exceptions derive from MarkanMError. API errors include status_code, error_code, and optional request_id; rate limit errors also expose retry_after. TLS certificate verification remains enabled. On Kali, install/update the OS CA bundle (sudo apt install ca-certificates && sudo update-ca-certificates) instead of disabling certificate checks. Check system time, DNS, outbound HTTPS access, token validity, API base URL, and that the bot is active. For a self-hosted endpoint, pass base_url="https://host.example/api/bot/v1".
from markanm import MarkanMAPIError, MarkanMRateLimitError
try:
await bot.send_message("123", "Hello")
except MarkanMRateLimitError as exc:
print("Retry after", exc.retry_after)
except MarkanMAPIError as exc:
print(exc.status_code, exc.error_code, exc.request_id)
Publishing
From this directory, build with python -m build, inspect the wheel and sdist in dist/, then upload with python -m twine upload dist/*. Use a PyPI token or trusted publishing in CI; do not commit credentials. Version numbers must be unique on PyPI.
License
MIT. See LICENSE.
Metadata
Release files for markanm 0.1.0a3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| markanm-0.1.0a3.tar.gz | 19.1 kB | With provenance | Details for markanm-0.1.0a3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| markanm-0.1.0a3-py3-none-any.whl | Python 3 | none | any | Details for markanm-0.1.0a3-py3-none-any.whl |
Total release size: 36.9 kB
Release files / markanm-0.1.0a3.tar.gz
| Download URL | markanm-0.1.0a3.tar.gz |
|---|---|
| Size | 19.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8c3462cd40b084c35784db01c5b18a0684a2da080771406b0dafbd6384efc0fb
|
|
BLAKE2b-256 checksum How to use checksums |
cb38b2e5dea59804e521a93f516f90bdba3a72fa5554c381a90415fc82344ddb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logRelease files / markanm-0.1.0a3-py3-none-any.whl
| Download URL | markanm-0.1.0a3-py3-none-any.whl |
|---|---|
| Size | 17.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc82ee30b3eec9128d21ad0b3dfe4525fca0cd8dbce67cbaae306c8457f7fa94
|
|
BLAKE2b-256 checksum How to use checksums |
8b328e3413b2f8b4e9a5dbc52b86930a81e8311c1b3b76500386166a58c1e6bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logSecurity for markanm 0.1.0a3
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for markanm-0.1.0a3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logA 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.