kymoscope
Stream live, end-to-end encrypted telemetry to Kymoscope from Python.
Requires Python 3.9 or later.
pip install kymoscope
Example
import math, time
from kymoscope import LiveStream
API_KEY = "kymoscope_..." # Account -> API & real-time streaming, or a project's API key
# mode/hz/channels declare what it sends; state_path keeps this sender's identity, so a restart needs no new approval
with LiveStream(API_KEY, "Rig A", mode="live", hz=60, channels=1, state_path="kymoscope-state.json") as stream:
print("stream id:", stream.stream_id)
while True:
t = time.time() # absolute (Unix seconds)
stream.send([{"t": t, "signals": [
{"name": "speed", "unit": "m/s", "value": 50 + 10 * math.sin(t)},
]}])
time.sleep(1 / 60)
Declare what the stream sends
Since 1.0 every stream says what it sends, and Kymoscope admits it against your plan when it starts:
mode:"live"(watched as it comes) or"record"(also kept, in files: see "Record to files").hzandchannels: samples per second and how many channels, orsources=[{"hz": 10, "channels": 2}, {"hz": 1, "channels": 40}]for channels at different rates (give one or the other).- Optional, for an exact bandwidth:
namesandunits(your channels) andrate_hz(how many times a second you callsend_columns; a source insourcestakes the same keys). The sender works out the bytes a second it really sends from them (without them it assumes long names and one call per sample, which can only overstate it), and the relay holds the stream to that. Names and units never leave your machine. - Over 1,000 channels that change one at a time: send them with
stream.send_events(names, index, t, values)(eventkis channelnames[index[k]]att[k];namesthe whole channel list, the same list each call) and addevents_per_sec(values a second) to the source:sources=[{"hz": 10, "channels": 50_000, "events_per_sec": 5_000}]. Up to 100,000 channels a stream.
At start the sender prints what it was given and what is left, for example:
Kymoscope: 'Rig A' admitted (live, 60 Hz × 1 ch = 7 kbit/s). Left: ...
A stream the plan can't take is refused at start (RegistrationError, with the reason). While it runs, the
heartbeat may say something once (for example, a recording that stopped because storage is full); it goes to
on_status (stderr by default). The password is a keyword argument: LiveStream(API_KEY, "Rig A", mode=..., password="..."). Senders before 1.0 are refused with "This sender is too old": update with pip install -U kymoscope.
In an end-to-end encrypted project, the first run waits until a project member's browser
approves the sender; after that it publishes on its own.
LiveStream.project_key gives a sender the current project key, which a camera follows to seal its own keys;
never log or persist it.
Record to files
with LiveStream(API_KEY, "Rig A", mode="record", hz=1000, channels=8, state_path="kymoscope-state.json",
split_every="1h", buffer_path="kymoscope-buffer", buffer_max_mb=2048) as stream:
...
Since 1.1 a record stream is recorded by this sender, the same way by every Kymoscope sender:
| Setting | Meaning | Default |
|---|---|---|
mode |
"live" or "record" |
required |
split_every |
how often the recording is cut into a new file: "1m", "5m", "15m", "30m", "1h", "2h", "4h", "8h", "12h" or "24h" (or seconds) |
from the declared rate |
buffer_max_mb |
local space for files not stored yet | 2048 (2 GB) |
storage |
how to reach the project's own storage, when it has one | none |
retention_days |
own storage only: how many days Kymoscope lists each file (it never deletes files there) | listed until deleted |
Files are cut at the clock (a 1 h period cuts at 00:00, 01:00, ... of this machine's time), never by size. Without
split_every, the sender takes the longest period whose file stays under about 150 MB at the declared rate (1.5 KB/s:
24 h; 40 KB/s: 1 h). Each file is sealed exactly like live data (end-to-end encrypted), written to disk under
buffer_path/rec (default ~/.kymoscope/buffer) in chunks of up to a minute, uploaded and deleted locally once
Kymoscope confirms it. Through an outage the chunks wait on disk and go out oldest first when the connection is back,
also after a restart. When the buffer reaches buffer_max_mb, the oldest chunks are dropped and the sender says so.
At the first file the sender says where the files go, for example:
Recording files: every 1h → Kymoscope (buffer 2 GB)
The project decides where its recordings go. When an admin set it to its own storage, give the sender the way in (the key never leaves your machine):
storage={"s3": {"endpoint": "https://minio.customer.local:9000", "region": "us-east-1", "bucket": "recordings",
"prefix": "kymoscope", "access_key_id": "...", "secret_access_key": "..."}}
storage={"folder": r"\\server\recordings"} # a shared folder: <folder>/<stream>/<recording>/<n>.krc
Without it, the sender says "This project records to : set storage in the sender's config" and keeps the
files until it has it. When the plan refuses recording (storage full, not in the plan) the sender says why once and
keeps live going. stream.pause_recording() ends the current file and records nothing until
stream.resume_recording() (for example while a machine is stopped). Live data still goes out only while someone
watches.
Keep live data when the connection drops
With buffer_path (a folder), a live stream keeps what it couldn't send through an outage that starts while
someone watches: it keeps the encrypted messages on disk, then sends them in order when the relay is back, with the
bandwidth live data leaves spare, while someone watches (until then it waits on disk); with nobody watching when the
relay becomes unreachable it keeps nothing. A crash can send a few messages twice.
buffer_max_mb caps the disk used; when it is full, new samples are dropped and counted in stream.buffer_dropped.
buffer_min_free_mb (default 0, off) also stops buffering when the disk has less free space than that.
Since 0.3.0 the stream sends the compact format by default (4–8× less data); block_format=False sends the
classic format for viewers on SDK versions before 0.2.0 or self-hosted relays before 0.2.0 (buffer_path and
record always use the compact one). With buffer_path, send absolute times (time.time()), so data sent after a
restart lands in the right place.
Alert rules on this machine
pip install "kymoscope[rules]"
def heard(alert): # every raise and clear, here, with the rule's values
print(alert["kind"], alert["rule"], alert["values"])
with LiveStream(API_KEY, "Press 2", mode="live", hz=100, channels=4, state_path="kymoscope-state.json",
rules=True, on_alert=heard) as stream:
...
rules=True runs the project's alert rules that are set to run on The sending machine on every block you send,
whether or not anyone watches the stream. The values never leave this machine: Kymoscope gets only which rule, which
stream and when each alert started and ended, and notifies as it does for an alert seen in a browser. The posts wait
on disk (under buffer_path/alerts, else next to state_path, else ~/.kymoscope/alerts) through an outage or a
restart. Every 60 s the sender tells the project it is watching; if it goes silent for 5 minutes the project hears
"Nobody is watching Press 2". Rules are fetched again every minute, so an edit in the app reaches the sender within
a minute. Blocks sent with historical=True count as past data. In an end-to-end encrypted project the sender runs
only rules sealed with the project key, once a project member approved it. on_alert hears every transition, whether
or not Kymoscope takes the post. Rules never stop or slow the data: a rule that
fails is logged and the stream goes on.
Replay a sample or a CSV as a live stream
pip install "kymoscope[rules]"
python -m kymoscope.replay batch-reactor --api-key kymoscope_... --speed 3600
Sends a Kymoscope sample (or a sample's file name, a URL or a local CSV) into the API key's project, at --speed
data seconds per real second, once (--loop to repeat). Rows keep their data seconds from the file's start, so the
project's alerts on The sending machine hold for their forS in data time and fire where they would on the real
line; Kymoscope dates each alert by the clock. CSV only. Guide: https://kymoscope.com/docs/replay
Samples come from kymoscope.com; with KYMOSCOPE_BASE set to a Kymoscope Site they come from <site>/samples/
(or from KYMOSCOPE_SAMPLES).
Use a Kymoscope Site (your own install)
Set KYMOSCOPE_BASE=https://kymoscope.customer.local (https; http only for localhost) before running, or pass
"base" in kymoscope-stream.json or KymoscopeConfig.from_api_key(key, base=...). API keys and data then go to that
address and nowhere else (a warning names it once per process). For an internal CA, set REQUESTS_CA_BUNDLE and SSL_CERT_FILE to its PEM file.
Cameras
A camera is a channel of a stream: whoever opens the stream sees its cameras. It needs ffmpeg on PATH.
hd = dict(mode="live", quality="720p", fps=30)
with LiveStream(API_KEY, "Rig A", mode="live", hz=60, channels=1, state_path="kymoscope-state.json") as stream:
stream.add_camera("Front", "video=Integrated Camera", input_format="dshow", **hd) # a webcam on Windows
stream.add_camera("Bay", "/dev/video0", input_format="v4l2", **hd) # a webcam on Linux
stream.add_camera("Door", "rtsp://user:pass@10.0.0.7/stream1", copy=True, **hd) # an H.264 IP camera, as is
stream.add_camera("Test", "testsrc=size=1280x720:rate=30", input_format="lavfi", **hd) # a test pattern
while True:
stream.send(...) # keep sending (or call stream.tick()): the cameras heartbeat with the stream
Each camera declares mode ("live" or "record"), quality ("360p", "480p", "720p" or "1080p": the
height, the aspect kept) and fps (1 to 60). ffmpeg re-encodes to H.264 at that height and frame rate, at the
bitrate Kymoscope chooses for them (a keyframe every 2 s), unless copy=True, which forwards the camera's own stream
(quality and fps then only declare it: set the camera's own resolution, frame rate and bitrate to match them, as the
relay holds the camera to what it declared). size and kbps are gone since 1.0. When the month's video hours run out,
the camera stops and says why; the stream goes on.
Video goes out only while someone watches the camera; a new viewer starts at the next keyframe. A record camera
of a record stream is recorded in files cut together with its stream's (each starts at a keyframe); of a live
stream, by the period its bitrate gives.
Use the same API key for the cameras as for their stream; in an encrypted project they need no extra approval.
low=True also publishes a 360p copy (640x360 for 16:9, 15 fps, 400 kbit/s, a keyframe every 2 s) as the camera's
low layer. Viewers play it in small panels and camera walls, and switch to full quality when a camera is enlarged;
it also suits viewers on slow links. It goes out only while someone watches it, isn't recorded, and doesn't count
as a camera of your plan.
stream.add_camera("Bay", "/dev/video0", input_format="v4l2", low=True, **hd)
stream.add_camera("Door", "rtsp://user:pass@10.0.0.7/stream1", copy=True, low=True, **hd)
One ffmpeg writes both layers. With copy=True the full layer is still forwarded as is; only the low layer is decoded
and encoded, which costs the CPU of one 360p libx264 encode (plus decoding the camera's stream). On Windows a
second ffmpeg encodes the low layer and opens the input again: fine for an IP camera or a file, but a webcam
(dshow) can't be opened twice, so low=True with input_format="dshow" raises an error; run that sender on
Linux or macOS, or use an IP camera.
Credentials in a camera URL (rtsp://user:pass@host/...) are passed to ffmpeg on its command line, so other users
of the same machine can read them in the process list. Kymoscope hides them (rtsp://***@host) in everything it
prints, ffmpeg's own error lines included. Give the sender a camera account that can only view the stream, and run
it on a machine (or under an account) nobody else uses.
The headless viewer (kymoscope.viewer) needs msgpack: pip install 'kymoscope[viewer]'.
Full documentation: https://kymoscope.com/docs/live
Metadata
Release files for kymoscope 1.12.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kymoscope-1.12.0.tar.gz | 296.0 kB | With provenance | Details for kymoscope-1.12.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kymoscope-1.12.0-py3-none-any.whl | Python 3 | none | any | Details for kymoscope-1.12.0-py3-none-any.whl |
Total release size: 481.3 kB
Release files / kymoscope-1.12.0.tar.gz
| Download URL | kymoscope-1.12.0.tar.gz |
|---|---|
| Size | 296.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9961f9c9b4a8881f82447dee6f4c250780da35a2592a8c5d095677eef6c0586a
|
|
BLAKE2b-256 checksum How to use checksums |
cccc998c4822ca39001d46962a5cc1049d13381d75f3a1d1f68e394d486787af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logRelease files / kymoscope-1.12.0-py3-none-any.whl
| Download URL | kymoscope-1.12.0-py3-none-any.whl |
|---|---|
| Size | 185.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2dd3e4ad1edf04ec253a82c84db443a0c845de9ee9cbf451d145fab6af893cd5
|
|
BLAKE2b-256 checksum How to use checksums |
8eb1c5b41ba9d9d2d1bbb5a1ba89d61fc848a66a43efc2517b7b44d05c7cdde4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logSecurity for kymoscope 1.12.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for kymoscope-1.12.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.