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

Metadata

Release files for pysage3 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pysage3 1.1.1
File Size Uploaded
pysage3-1.1.1.tar.gz 35.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pysage3 1.1.1
File Interpreter ABI Platform
pysage3-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 92.2 kB

Release files / pysage3-1.1.1.tar.gz

Download URL pysage3-1.1.1.tar.gz
Size 35.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f0797ef1433ebbf73dcb3f54a49ebc35ff688f412ec3471569cc396df00323f0
BLAKE2b-256 checksum
How to use checksums
95b6bcd4577ccbe1ea58a26e11ecffedc45759d4f1960e8a4b74b3080bca1e62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Release files / pysage3-1.1.1-py3-none-any.whl

Download URL pysage3-1.1.1-py3-none-any.whl
Size 57.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c1b20c5f924086109ed437575760395f7f4990a8d530d254820194b0ae808190
BLAKE2b-256 checksum
How to use checksums
ca62269e7d58ab2eec66d7e1a56e996b3a1fb66bb1c5b532c01d38743c0333dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.1.0

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page