Skip to main content

Python SDK for shout.run - broadcast your terminal from code

Project description

shout.run

shout-run-sdk

Python SDK for shout.run. Broadcast your terminal from code.

Write a script, pipe some output, and anyone with the link watches it live.

Install

pip install shout-run-sdk

Quick Start

from shout_sdk import ShoutSession

session = ShoutSession(api_key='shout_sk_...')
info = session.start(title='My Agent Session')
print(f"Live at: {info['url']}")

session.write('Hello, world!\r\n')
# ... do work ...

session.end()

Context Manager

from shout_sdk import ShoutSession

with ShoutSession(api_key='shout_sk_...') as session:
    info = session.start(title='My Agent')
    session.write('Working...\r\n')
    # session.end() called automatically

Getting an API Key

npm install -g shout-run
shout login
shout api-key create "My Agent"

The key is printed once. Save it somewhere safe. Keys start with shout_sk_.

You can list your keys with shout api-key list and revoke one with shout api-key revoke <id>.

API Reference

ShoutSession(api_key, **kwargs)

Parameter Type Default Description
api_key str required API key (starts with shout_sk_)
title str 'SDK Session' Session title shown to viewers
visibility str 'public' 'public', 'followers', or 'private'
cols int 80 Terminal columns
rows int 24 Terminal rows
api_url str 'https://api.shout.run' API base URL

Methods

  • start() — Creates the session and connects WebSocket. Returns {'session_id', 'url', 'ws_url'}.
  • write(data) — Sends terminal output (str or bytes). Automatically buffered, rate-limited, and chunked.
  • resize(cols, rows) — Updates terminal dimensions.
  • end() — Flushes buffer, sends end frame, closes session.

Properties

  • state — Current state: SessionState.IDLE, .CONNECTING, .LIVE, .ENDING, .ENDED
  • viewers — Current viewer count
  • session_id — Session ID (None before start)

Events

session.on('connected', lambda: print('Connected!'))
session.on('disconnected', lambda code, reason: print(f'Disconnected: {code}'))
session.on('reconnecting', lambda attempt: print(f'Reconnecting #{attempt}'))
session.on('viewers', lambda count: print(f'Viewers: {count}'))
session.on('error', lambda err: print(f'Error: {err}'))
session.on('state_change', lambda state: print(f'State: {state}'))

Piping Subprocess Output

import subprocess
from shout_sdk import ShoutSession

session = ShoutSession(api_key='shout_sk_...')
info = session.start(title='Running tests')

proc = subprocess.Popen(
    ['pytest', '-v'],
    stdout=subprocess.PIPE,
    stderr=subprocess.STDOUT,
)

for line in proc.stdout:
    session.write(line)

proc.wait()
session.end()

License

MIT

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

shout_run_sdk-0.1.3.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

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

shout_run_sdk-0.1.3-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file shout_run_sdk-0.1.3.tar.gz.

File metadata

  • Download URL: shout_run_sdk-0.1.3.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for shout_run_sdk-0.1.3.tar.gz
Algorithm Hash digest
SHA256 f196ee5ee090545605ff90ac804f2d08d01726e451945a713fb5dbc71abc54a4
MD5 ac939ea5f7a68bbdd8979af1b72df7ad
BLAKE2b-256 d4e3a280a57a9d9960b51d15e9cfd309c2728afd1098e6bc7ba2c29e2d482b9b

See more details on using hashes here.

File details

Details for the file shout_run_sdk-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: shout_run_sdk-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for shout_run_sdk-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 56d6ac5e9959fdc6b86aae63a746f105d04927ef9af7acb8bff8466487b5db5a
MD5 3d63790aa294cedc5329f691bcb420b9
BLAKE2b-256 28e21f04ab625bd276b153ca83f0d1fac42a2acb1f8e136297e5caedeca81651

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