magic-campus-sdk
Python SDK and CLI for MagicCampus platform integrations. IM remains a supported domain, and this repository keeps the bundled OpenIM transport inside magiccampus_sdk.
This project removes direct user-facing dependency on OpenIM token and endpoint configuration. You only configure:
apiurlapikeyplatform
At runtime, IM-backed flows call:
GET /api/v1/accounts/imToken?platform=<PLATFORM>
and uses the response fields:
userIdimTokenwsApihttpApi
Install locally
uv sync
This repository vendors only the OpenIM transport pieces that magiccampus_sdk actually uses, and layers platform-facing SDK / CLI commands on top.
IM-specific low-level internals, models, and protobufs now live under magiccampus_sdk.im.
CLI quick start
magic-campus --help
magic-campus config init --apiurl https://api-test.pearlapi.com --apikey "$MAGICCAMPUS_APIKEY" --platform IOS --default true
magic-campus auth status --format pretty
magic-campus im notify send --to user:10134002 --text "hello"
magic-campus im notify send --to user:10134002 --markdown "# title\n\nbody"
magic-campus space get --group group_123 --format pretty
magic-campus space group update-name --group group_123 --name "New group name"
magic-campus user get --id 10134002 --format pretty
magic-campus config init also supports an interactive TTY flow when you omit auth flags.
im notify send sends over MagicCampus HTTP POST /agent/v1/im/sendMessage. im notify history still relies on the websocket transport and local sync database.
Legacy compatibility commands remain available:
magic-campus notify +send --to user:10134002 --text "hello"
magic-campus notify +history --to user:10134002
CLI config is stored at:
~/.magic-campus/auth/magiccampus-im-sdk.json
Supported commands:
config init|list|use|removeauth statusim notify sendim notify historyspace getspace group update-nameuser getfeed listnotify +send(compat)notify +history(compat)
Python SDK quick start
from magiccampus_sdk import MagicCampusConfig, MagicCampusSDK
sdk = MagicCampusSDK(
MagicCampusConfig(
apiurl="https://api-test.pearlapi.com",
apikey="YOUR_API_KEY",
platform="IOS",
)
)
space = sdk.get_space_by_group_id("GROUP_ID")
print(space.id)
print(space.name)
print(space.introduction)
Python websocket quick start
from magiccampus_sdk import MagicCampusWSSDK, MagicCampusWSConfig
sdk = MagicCampusWSSDK(
MagicCampusWSConfig(
apiurl="https://api-test.pearlapi.com",
apikey="YOUR_API_KEY",
platform="IOS",
data_dir="./magiccampus_data",
)
)
space = sdk.get_space_by_group_id("GROUP_ID")
print(space.name)
sdk.login()
sdk.start()
sdk.send_text("hello", recv_id="10134002")
sdk.send_markdown("# title\n\nbody", recv_id="10134002")
group = sdk.get_group_info("GROUP_ID")
print(group["groupName"])
groups = sdk.get_groups_info(["GROUP_ID_1", "GROUP_ID_2"])
Runnable examples live in magiccampus_sdk/example.py and magiccampus_sdk/example_ws.py.
CLI smoke script
An executable smoke helper lives at scripts/smoke_cli.py.
Offline-safe mode only exercises config persistence and notify dry-run:
uv run python scripts/smoke_cli.py
This mode does not require a real API key. It uses a placeholder key by default and avoids any live auth call.
Real network mode
To run the live auth probe, provide a real API key and enable --live:
export MAGICCAMPUS_APIURL=https://api-test.pearlapi.com
export MAGICCAMPUS_APIKEY='your real api key'
export MAGICCAMPUS_PLATFORM=IOS
uv run python scripts/smoke_cli.py --live
Optional variables:
MAGICCAMPUS_SMOKE_TARGET: target used by dry-run and optional live send, defaultuser:smoke-targetMAGICCAMPUS_PLATFORM: defaults toIOS
If you also want to send a real text message, set a real target and pass --live-send:
export MAGICCAMPUS_SMOKE_TARGET='user:10134002'
uv run python scripts/smoke_cli.py --live --live-send --text 'hello from smoke script'
--live-send performs a real outbound send, so use it only with a valid target and credentials.
Notes
apiurlcan point to any MagicCampus API base URL; IM-backed flows append/api/v1/accounts/imTokenclient.user.get(...)callsGET /api/v1/accounts/getUserInfowithapiurlandapikeydirectlyplatformdefaults toIOS- low-level IM send / receive behavior comes from the bundled transport modules inside
magiccampus_sdk - the wrapper does not persist raw OpenIM credentials in CLI config
Metadata
Release files for magic-campus-sdk 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| magic_campus_sdk-0.2.3.tar.gz | 80.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| magic_campus_sdk-0.2.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 167.1 kB
Release files / magic_campus_sdk-0.2.3.tar.gz
| Download URL | magic_campus_sdk-0.2.3.tar.gz |
|---|---|
| Size | 80.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
424a1e8f41afd486d15ebf8619400cac02b3a4ce0828a415cead3ac46b701c6f
|
|
BLAKE2b-256 checksum How to use checksums |
49341dfa71c3fc802dad3da522e6f49363990d4416d151ee2b6fedd5a533258b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.12
|
Release files / magic_campus_sdk-0.2.3-py3-none-any.whl
| Download URL | magic_campus_sdk-0.2.3-py3-none-any.whl |
|---|---|
| Size | 86.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
04c4bec4f93d4553b6997efa9e6def5598c09b00bcce602a1a82396221689dbd
|
|
BLAKE2b-256 checksum How to use checksums |
f1e80cfde06558095de61672ea917150868eebc8d5b7d98bb6fd03beb2f5f7be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.12
|