Skip to main content

MagicCampus-flavoured SDK and CLI with a bundled OpenIM transport layer.

Project description

magiccampus-im-sdk

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

This project bundles the OpenIM transport implementation inside magiccampus_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 vendors only the OpenIM transport pieces that magiccampus_sdk actually uses.

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 the bundled transport modules inside magiccampus_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.1.tar.gz (57.3 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.1-py3-none-any.whl (63.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: magiccampus_im_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 57.3 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.1.tar.gz
Algorithm Hash digest
SHA256 989bb651cf53b8a112949224a3a54dd01cd9729d9b23dc4a3d0059281b575cba
MD5 d8b95cfa3c202caf5bc3b5a943405b49
BLAKE2b-256 78cb16e4fa593bd92600185e12acf49c4d7d418240a803d123851eca74b77bca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for magiccampus_im_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5f04587bd4d99d5991dd8b30cb7b1e0c2ed1ba4802c59132cac7efd3f5016f48
MD5 57c3bb460704f8e5626652cc776784cc
BLAKE2b-256 d62c4ea887f8401df648f57baa484231e23ef628ec2a1799e36e6e993ced5211

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