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 (strorbytes). Automatically buffered, rate-limited, and chunked.resize(cols, rows)— Updates terminal dimensions.end()— Flushes buffer, sends end frame, closes session.
Static Methods
ShoutSession.delete_session(api_key, session_id, *, api_url='https://api.shout.run')— Delete an ended session (permanent). RaisesRuntimeErroron failure.
ShoutSession.delete_session(api_key='shout_sk_...', session_id='abc123')
ShoutSession.search_sessions(api_key, query, *, tags=None, status=None, limit=20, cursor=None, api_url='https://api.shout.run')— Search sessions by query, tags, and status.
results = ShoutSession.search_sessions(
api_key='shout_sk_...',
query='typescript',
tags=['tutorial'],
status='ended',
limit=10,
)
for session in results:
print(f"{session['title']} by {session['username']}")
ShoutSession.get_session_content(api_key, session_id, *, api_url='https://api.shout.run')— Get session metadata and plain-text transcript.
content = ShoutSession.get_session_content(api_key='shout_sk_...', session_id='abc123')
print(f"Title: {content['session']['title']}")
print(f"Transcript: {content['transcript'][:200]}...")
Properties
state— Current state:SessionState.IDLE,.CONNECTING,.LIVE,.ENDING,.ENDEDviewers— Current viewer countsession_id— Session ID (Nonebefore 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
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.3.0.tar.gz
(9.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shout_run_sdk-0.3.0.tar.gz.
File metadata
- Download URL: shout_run_sdk-0.3.0.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c37b72da54b448916467cc99b55f4fe881c56e25efd6f5fb1fa041b877e06af
|
|
| MD5 |
94b49ac6495f67ff1a2c74aa9b8d7ba8
|
|
| BLAKE2b-256 |
92789b978bd0fb42d5d94fd9241769c872032e65e0c12e763a0dd58a025de62d
|
File details
Details for the file shout_run_sdk-0.3.0-py3-none-any.whl.
File metadata
- Download URL: shout_run_sdk-0.3.0-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20c8aff345cb8d8c69507643ea3e9a72961c8f0102dcf9f7732cdc8de7a7b932
|
|
| MD5 |
2c4abff15bb0ddc0417233dc147956d8
|
|
| BLAKE2b-256 |
f4ce9fe8d2f9ca16b5418dea3a6f5e83396fef40a3ed70a726ee6f5682a06b8d
|