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

Uploaded Python 3

File details

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

File metadata

  • Download URL: shout_run_sdk-0.1.2.tar.gz
  • Upload date:
  • Size: 7.4 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.2.tar.gz
Algorithm Hash digest
SHA256 f64c3c86af284376768aaabaee351f014252b27c1b880da0ff14d220c24c9777
MD5 2081f337c9df356a42de1ff8d5ef3490
BLAKE2b-256 21b5039ed51ec0ee5bd558a0d553153e6814db4c9066ea231711f3634dbe8736

See more details on using hashes here.

File details

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

File metadata

  • Download URL: shout_run_sdk-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.1 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 137727a2e5b768ebd39a9f0583ac0b73758235e6a3bf3da81ee6e4a2494488d2
MD5 c8638562fedbff4a97541ca9db7fa2ce
BLAKE2b-256 8422abee879411cc973ebdf166f2845679ab5695bc662e0d17e4a01afdd34516

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