Python SDK & CLI — Built for Python Developers

OSHI ships an official Python SDK and command-line interface for its Bot API, the same way Telegram and Slack ship SDKs for their bot platforms. It is one file, oshi_bot.py, that only depends on the requests library already in most Python environments. You can use it as a library inside a script, or run it directly from the shell as a CLI — no separate install, no package manager, no account beyond the bot token you get from the OSHI app.

Installation

pip install requests
curl -O https://oshi-messenger.com/sdk/oshi_bot.py

That is the entire install. oshi_bot.py is plain, readable Python — read it before you trust it, or vendor it directly into your project.

Quick start: the SDK

from oshi_bot import OshiBot

bot = OshiBot(token="YOUR_BOT_TOKEN")
result = bot.send("GROUP_ID", "Hello from Python!")
print(f"Delivered to {result['delivered']} members")

Get a bot token from the OSHI app (Portal › Bots › Create), assign the bot to a group, and it is ready to send. The OshiBot class also covers images, documents and arbitrary files:

bot.send_image("GROUP_ID", "chart.png", caption="BTC +2.5% today")
bot.send_document("GROUP_ID", "report.pdf")
bot.send_file("GROUP_ID", "/path/to/any/file", caption="Logs attached")

Quick start: the CLI

The same file runs as a command-line tool with no extra flags library — useful for cron jobs, CI pipelines, or a one-line notification from a shell script.

python oshi_bot.py send    TOKEN GROUP_ID "Hello from the command line!"
python oshi_bot.py send-file TOKEN GROUP_ID "/path/to/file" "optional caption"
python oshi_bot.py info    TOKEN
python oshi_bot.py groups  TOKEN
python oshi_bot.py stats   TOKEN
python oshi_bot.py help
CommandWhat it does
sendSend a text message to a group by its ID
send-fileSend an image, document or any file, with an optional caption
infoPrint the bot's own profile: name, token prefix, assigned groups
groupsList every group the bot is assigned to, with member counts
statsMessages sent and last activity for this bot
helpPrint usage and examples

Known issue: list / list_bots()

The CLI's list command and the SDK's list_bots() method predate a server-side security fix that narrowed GET /api/bot/list from an open, unauthenticated listing of every bot on the platform to a token-gated lookup of the caller's own bot only. Neither was updated afterwards: the CLI calls it with a hardcoded placeholder token, and the SDK method sends no token at all — so both currently fail with “Invalid bot token” rather than listing anything. Everything else on this page (send, info, groups, stats, media sends) was individually verified against the current server code. We flag this rather than quietly leave it out, and will fix the SDK file itself to call get_groups()/get_stats() against your own token instead.

Full SDK surface

Beyond send, the OshiBot class exposes the rest of the Bot API as plain Python methods: info(), register() and unregister() to manage a bot programmatically, update_groups() to change which groups it posts to, send_to_all_groups() for a broadcast across every assigned group in one call, and get_groups() / get_stats() for introspection — all confirmed against the live API. Every method raises a typed exception on failure — OshiAuthError for a bad token, OshiGroupError when the bot is not assigned to the target group, OshiRateLimitError on throttling, each a subclass of OshiBotError — so a script can catch exactly what it needs to.

MoltBot bridge

The SDK also includes OshiMoltBotBridge, a thin adapter that lets an existing MoltBot-framework bot send through OSHI as a transport layer without rewriting its logic:

from oshi_bot import OshiMoltBotBridge

bridge = OshiMoltBotBridge(oshi_token="TOKEN", default_group="GROUP_ID")
bridge.send("Hello from MoltBot!")
bridge.broadcast("Posted to every assigned group")

Why a Python-first SDK

OSHI is a decentralized, peer-to-peer messaging app built for off-grid communication — mesh over Bluetooth and Wi-Fi first, an encrypted relay only when no peer is in range. The bot layer sits on top of that and talks plain HTTPS, so it works the same whether the bot lives on a Raspberry Pi, a CI runner, or a laptop. Python was the first SDK because it is the default choice for quick automation scripts, data pipelines and CI integrations — the audience most likely to want a message sent from a script rather than typed into an app.

The SDK is deliberately send-only and read-light: it cannot read a group's message history or anyone's content, only post to groups the bot has been explicitly assigned to and read its own delivery stats. A leaked bot token lets someone send spam to those groups, not read anyone's conversation.

For the full HTTP API reference — every endpoint, error code and the JavaScript and curl equivalents — see the complete Bot API documentation.

Build Your First Bot

Download OSHI, create a bot in Portal › Bots, and send your first message from Python in minutes. Free forever.

Download OSHI FreeGoogle Play