Skip to main content

SAGE3 API

Project description

pysage3

Python SDK for SAGE3 — create and control apps on a SAGE3 board programmatically.

Installation

pip install pysage3

Or from source:

git clone https://github.com/SAGE-3/next.git
cd next/pysage3
pip install -e .

Configuration

pysage3 reads connection settings from environment variables:

Variable Description
ENVIRONMENT development, production, or backend
TOKEN JWT bearer token from your SAGE3 server
SAGE3_SERVER Hostname of the SAGE3 server (optional, defaults to localhost)
export ENVIRONMENT=development
export SAGE3_SERVER=localhost
export TOKEN=<your-jwt-token>

Usage

PySage3 — imperative client API

Connect, query, and control apps directly:

from pysage3 import PySage3
from pysage3.config import config as conf, prod_type

ps3 = PySage3(conf, prod_type)

# List rooms and boards
rooms = ps3.s3_comm.get_rooms()
boards = ps3.s3_comm.get_boards(room_id="<room-id>")

# Get apps on a board
apps = ps3.get_apps(room_id="<room-id>", board_id="<board-id>")

# Create a Stickie note
ps3.create_app(
    room_id="<room-id>",
    board_id="<board-id>",
    app_type="Stickie",
    state={"text": "Hello from pysage3!", "color": "yellow"},
)

# Move an app
smartbits = ps3.get_smartbits(room_id="<room-id>", board_id="<board-id>")
app = smartbits["<app-id>"]
ps3.update_position(app, x=100, y=200)

# Upload a file
with open("data.pdf", "rb") as f:
    ps3.upload_file(room_id="<room-id>", filename="data.pdf", filedata=f)

AsyncSageCommunication — async HTTP client

For use inside FastAPI, Jupyter, or any async context:

import asyncio
from pysage3 import AsyncSageCommunication
from pysage3.config import config as conf, prod_type

async def main():
    async with AsyncSageCommunication(conf, prod_type) as s3:
        rooms = await s3.get_rooms()
        apps = await s3.get_apps(room_id="<room-id>", board_id="<board-id>")
        await s3.create_app({"type": "Stickie", ...})

asyncio.run(main())

SAGEProxy — event-driven daemon

React to real-time changes on a board. Define methods on your SmartBit subclass and the proxy calls them when executeInfo.executeFunc is set from the frontend:

from pysage3 import SAGEProxy
from pysage3.config import config as conf, prod_type
import time

proxy = SAGEProxy(conf, prod_type)

# Keep alive — proxy processes WebSocket messages in background thread
while True:
    try:
        time.sleep(10)
    except KeyboardInterrupt:
        proxy.clean_up()
        break

SageCommunication — direct HTTP client

Low-level access to the SAGE3 REST API:

from pysage3 import SageCommunication
from pysage3.config import config as conf, prod_type

s3 = SageCommunication(conf, prod_type)

rooms = s3.get_rooms()
apps = s3.get_apps(room_id="<room-id>")
s3.send_app_update("<app-id>", {"state.text": "updated"})
s3.delete_app("<app-id>")

Supported App Types

SmartBit models exist for the following SAGE3 app types:

App Type SmartBit class
Chat ChatSmartBit
CodeEditor CodeEditorSmartBit
CSVViewer CSVViewerSmartBit
ImageViewer ImageViewerSmartBit
Map MapSmartBit
PDFViewer PDFViewerSmartBit
SageCell SageCellSmartBit
Stickie StickieSmartBit
VideoViewer VideoViewerSmartBit
Webview WebviewSmartBit

Unknown app types are handled by GenericSmartBit.

Project Structure

pysage3/
├── pyproject.toml          # build config, version, dependencies
├── README.md
├── scripts/                # helper scripts for running SAGEProxy as a daemon
└── src/
    └── pysage3/
        ├── __init__.py     # public API exports
        ├── client.py       # PySage3 imperative client
        ├── proxy.py        # SAGEProxy event-driven daemon
        ├── board.py        # Board model
        ├── room.py         # Room model
        ├── config/         # environment-based server config
        ├── smartbits/      # Pydantic models for each app type
        └── utils/          # HTTP client, WebSocket, layout utilities

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

pysage3-1.1.0.tar.gz (34.5 kB view details)

Uploaded Source

Built Distribution

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

pysage3-1.1.0-py3-none-any.whl (56.7 kB view details)

Uploaded Python 3

File details

Details for the file pysage3-1.1.0.tar.gz.

File metadata

  • Download URL: pysage3-1.1.0.tar.gz
  • Upload date:
  • Size: 34.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for pysage3-1.1.0.tar.gz
Algorithm Hash digest
SHA256 732c76ff319cc7da88f67a4ad196580977e4ca491a97100cc3d259edf530e719
MD5 95a82dcb863429436538b68485b5a3eb
BLAKE2b-256 6e0e1f0fa2f6f097f1e91fb8f83fec6f1da6e264f0441c2544f3d740c63bffbd

See more details on using hashes here.

File details

Details for the file pysage3-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: pysage3-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 56.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for pysage3-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cc8f8c870d37eb4e1c23c707ac5810239b17c86a71cb9f66bbaf04adc5830d09
MD5 2c3399b7fed0a460555eed9a1f38c9f9
BLAKE2b-256 11273dc1f0682f414bda4256412e36b43e9607ca7f0b15ae4d69ff21e5e9a77c

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