Skip to main content

MagicCampus-flavoured SDK and CLI built on top of openim-sdk-core.

Project description

magiccampus-im-sdk

Python SDK and CLI for MagicCampus login, messaging, and websocket sync.

This project keeps the OpenIM transport implementation in openim_sdk, but removes direct user-facing dependency on OpenIM token and endpoint configuration. You only configure:

  • apiurl
  • apikey
  • platform

At runtime, the SDK calls:

GET /api/v1/accounts/imToken?platform=<PLATFORM>

and uses the response fields:

  • userId
  • imToken
  • wsApi
  • httpApi

Install locally

uv sync

This repository is configured to resolve openim-sdk-core from the sibling directory ../openim-python-sdk.

CLI quick start

magiccampus-cli --help
magiccampus-cli config init --apiurl https://api-test.pearlapi.com --apikey "$MAGICCAMPUS_APIKEY" --platform IOS --default true
magiccampus-cli auth status --format pretty
magiccampus-cli notify +send --to user:10134002 --text "hello"

magiccampus-cli config init also supports an interactive TTY flow when you omit auth flags.

CLI config is stored at:

~/.mushroom_agent/auth/magiccampus-im-sdk.json

Supported commands:

  • config init|list|use|remove
  • auth status
  • notify +send
  • notify +history

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",
    )
)

sdk.login()
sdk.start()
sdk.send_text("hello", recv_id="10134002")

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, default user:smoke-target
  • MAGICCAMPUS_PLATFORM: defaults to IOS

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

  • apiurl can point to any MagicCampus API base URL; the CLI and SDK append /api/v1/accounts/imToken
  • platform defaults to IOS
  • low-level message send / receive behavior comes from openim_sdk
  • the wrapper does not persist raw OpenIM credentials in CLI config

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

magiccampus_im_sdk-0.1.0.tar.gz (21.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

magiccampus_im_sdk-0.1.0-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file magiccampus_im_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: magiccampus_im_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 21.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for magiccampus_im_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 61a72d289281d1301eb334e2d1652921cf5d35d1eb6253ab70460c66f893e6b1
MD5 540998adbc15b8b486ba9eeb09baccfd
BLAKE2b-256 381b53555317c91aa3f5e410ec9e8c651f3ed52bcc2a61079e9608e1bc970ffb

See more details on using hashes here.

File details

Details for the file magiccampus_im_sdk-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for magiccampus_im_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 552cbec90b8ffc447ca4534561c63a643a37fdc820ef6bdd3655a70f41333e68
MD5 209b4cd46f6144f9895c8205d7bcdee3
BLAKE2b-256 0362a1d993e0eb6793cd7305531b1e70c48f2917013e0927b84b87f954becbea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page