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.

notify +send sends over MagicCampus HTTP POST /agent/v1/im/sendMessage. notify +history still relies on the websocket transport and local sync database.

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.2.tar.gz (61.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.2-py3-none-any.whl (66.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: magiccampus_im_sdk-0.1.2.tar.gz
  • Upload date:
  • Size: 61.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.12

File hashes

Hashes for magiccampus_im_sdk-0.1.2.tar.gz
Algorithm Hash digest
SHA256 31da680bd198b6b0d25d1296fe1d136ea3013f9160078bba457ec01cd73193c2
MD5 4bd3774ca6ac4c456f004346dcd0b470
BLAKE2b-256 02b99e3068b62301579aa5059451e83c90f56b6bf8e7adc8e4c28a7a12261f36

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for magiccampus_im_sdk-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 eca56ae59cce37b2f8900b4881ac6af8932018f1ac95b4da6f8f7f812b2ccb17
MD5 37420ef3faea6ecabda009756ae86ce4
BLAKE2b-256 538d57c9cec085c2fc7a22b13a9fe29242fe91e0065cd91bacdb285c7c43752e

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