A dependency-free Python client for the JuggleIM Server REST API.
English · 简体中文
imserver-sdk-python lets a trusted Python backend call JuggleIM server APIs without
reimplementing request signing, serialization, and response mapping. It uses only the Python
standard library and is intended for server-side applications.
Important
Your app secret grants privileged server API access. Never embed it in a mobile, desktop, browser, or other client application.
- Users: registration, profiles, online status, bans, blocks, devices, and settings
- Messages: private, group, chatroom, broadcast, recall, and history
- Groups, conversations, chatrooms, friends, moments, and public channels
- Push tags, sensitive words, bots, device binding, and global mute controls
For other server languages, see the Go and Java SDKs.
- Python 3.10 or newer
- A running JuggleIM server
- An app key and app secret created in the JuggleIM admin console
The package is not currently published on PyPI. Install the tagged source directly:
python -m pip install "git+https://github.com/juggleim/imserver-sdk-python.git@v1.0.0"For local development:
git clone https://github.com/juggleim/imserver-sdk-python.git
cd imserver-sdk-python
python -m pip install -e .Set server credentials outside your source code:
export JUGGLEIM_APP_KEY="your-app-key"
export JUGGLEIM_APP_SECRET="your-app-secret"
export JUGGLEIM_API_URL="http://127.0.0.1:9001"Register a user:
import os
from juggleimsdk import User, new_juggle_im_sdk
sdk = new_juggle_im_sdk(
os.environ["JUGGLEIM_APP_KEY"],
os.environ["JUGGLEIM_APP_SECRET"],
os.environ.get("JUGGLEIM_API_URL", "http://127.0.0.1:9001"),
)
user, code, trace_id, error = sdk.register(
User(user_id="alice", nickname="Alice")
)
if error:
raise RuntimeError(f"register failed: code={code}, trace_id={trace_id}: {error}")
print(user.user_id, user.token)SDK methods return (data, code, trace_id, error) when the endpoint returns data, or
(code, trace_id, error) for operations without a response body. Always log the trace ID when
reporting a failed request.
See examples/main.py and the
Server API reference for more operations.
The test suite does not call a live JuggleIM server:
python -m unittest discover -s tests -v
python -m build