Skip to main content

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

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.1.tar.gz (35.0 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.1-py3-none-any.whl (57.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pysage3-1.1.1.tar.gz
  • Upload date:
  • Size: 35.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.15

File hashes

Hashes for pysage3-1.1.1.tar.gz
Algorithm Hash digest
SHA256 f0797ef1433ebbf73dcb3f54a49ebc35ff688f412ec3471569cc396df00323f0
MD5 0eb029ce9ce5605151d7ca635448923b
BLAKE2b-256 95b6bcd4577ccbe1ea58a26e11ecffedc45759d4f1960e8a4b74b3080bca1e62

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysage3-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 57.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.15

File hashes

Hashes for pysage3-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c1b20c5f924086109ed437575760395f7f4990a8d530d254820194b0ae808190
MD5 2aa35ae59a7c2f0eff0dbb53971fa541
BLAKE2b-256 ca62269e7d58ab2eec66d7e1a56e996b3a1fb66bb1c5b532c01d38743c0333dc

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 files

1.1.0

2 files

1.0.8

2 files

1.0.7

2 files

1.0.6

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

Supported by

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