clypso-chat
Read live chat from Twitch, Kick and YouTube in Python, and find the moments chat goes wild.
The readers and parsers are written in Rust. They run outside Python's GIL, so watching dozens of channels costs almost no CPU.
import time
import clypso_chat as cc
with cc.Hub() as hub:
hub.join("jynxzi", "twitch", "jynxzi")
time.sleep(20)
for author, text, ts in hub.drain("jynxzi"):
print(author, ":", text)
viewer_one : !??????????!!
viewer_two : BOBCAT IS THE SAME THING
viewer_three : bro what was that
... 130 messages in 20 seconds
No login, API key or OAuth app is needed. Every reader is anonymous and read-only.
Features
- Three platforms, one API:
- Twitch: IRC over TLS.
- Kick: Pusher WebSocket.
- YouTube: the live chat feed of any live video.
- Many channels at once: every channel shares one small Rust runtime with one OS thread. The readers answer pings, reconnect, back off when blocked, and log what went wrong.
- Hype detection: a per-channel counter spots sudden chat spikes against the channel's own normal rate, and returns the moment in the stream that chat reacted to.
- Platform events:
- Twitch: subs, gift bombs, bits and raids.
- Kick: subs, gifted subs and hosts.
- YouTube: Super Chats, Super Stickers and memberships.
- Chat signals:
- For each second: messages, distinct chatters, reactions ("KEKW", "clip it", "W") and repeated lines.
compact()folds an emote wall into one line, so a burst fits in an AI prompt.
- Fast parsing: up to 7.6× faster than an equivalent pure-Python parser. Pure-Python details are under Speed.
- Typed: full type hints. Wheels for Linux, macOS and Windows on every CPython ≥ 3.10.
Install
pip install clypso-chat
Prebuilt wheels:
| Platform | Wheel |
|---|---|
| Linux x86-64 (glibc ≥ 2.17) | manylinux_2_17_x86_64 |
| Linux ARM64 (glibc ≥ 2.28) | manylinux_2_28_aarch64 |
| macOS Apple Silicon / Intel | macosx_11_0_arm64 / macosx_10_12_x86_64 |
| Windows x86-64 | win_amd64 |
Each wheel works on every CPython ≥ 3.10. It needs no OpenSSL: TLS is rustls with Mozilla's root certificates.
Anywhere else, for example Alpine/musl or Windows ARM, pip builds from source. That needs Rust (rustup, stable) and a C compiler.
Read live chat
import time
import clypso_chat as cc
with cc.Hub() as hub:
hub.join("tw", "twitch", "some_streamer") # Twitch channel name
hub.join("kk", "kick", "some_streamer", room=123456) # Kick: the chatroom id (see below)
hub.join("yt", "youtube", "dQw4w9WgXcQ") # YouTube: the live video's id
while True:
time.sleep(1)
for stream_id, lines in hub.drain_all():
for author, text, ts in lines:
print(f"[{stream_id}] {author}: {text}")
for line in hub.logs(): # "kk kick chat dropped: ...", reconnects, errors
print("log:", line)
join(id, platform, channel): starts a reader. Theidis your own name for the stream.drain(id)/drain_all(): return the messages received since the last call, as(author, text, epoch_seconds)tuples.status(id): returns{connected, received, reconnects, last_error, last_message_at, events, ...}.leave(id): stops one reader. Leaving thewithblock stops them all.
Detect hype moments
Counter keeps messages per second and fires when chat jumps well above the channel's recent normal rate. Use it with your own messages, or call hub.tick(id), which counts the hub's messages for you.
import clypso_chat as cc
counter = cc.Counter("twitch")
t = 1_000_000.0
for s in range(300): # 290 calm seconds at 2 msg/s, then 40 msg/s
for _ in range(2 if s < 290 else 40):
counter.add(t + s)
moment = counter.tick(t + s + 1) # call once a second
if moment:
print("chat exploded; the moment was at", moment - t, "s")
chat exploded; the moment was at 284.0 s
The moment comes a few seconds before the burst, because chat reacts after what happened on stream. That makes it the place to start a clip.
You can tune the detector with a dict (the defaults are shown):
cfg = {
"warmup_s": 120, # seconds of chat before it may fire
"baseline_s": 600, # how far back "normal" is measured
"z_on": 3.0, # how many standard deviations above normal counts as a spike
"min_rate": 1.5, # and at least this many messages per second
"chat_lag_s": 4.0, # how far chat trails the stream
"cooldown_s": 45.0, # no second spike within this time
}
counter = cc.Counter("twitch", cfg)
hub = cc.Hub(cfg)
Subs, gifts, raids and Super Chats
for e in hub.events("tw"):
print(e)
{'kind': 'raid', 'user': 'BigStreamer', 'amount': 1200.0, 'detail': '', 'text': '', 'ts': None}
{'kind': 'gift', 'user': 'Gifter', 'amount': 50.0, 'detail': '', 'text': '', 'ts': None}
| kind | Twitch | Kick | YouTube | amount |
|---|---|---|---|---|
sub |
sub, resub (detail: plan) |
subscription | — | months |
gift |
gift bomb, one gifted sub | gifted subs | gifted memberships | subs |
bits |
cheer | — | — | bits |
raid |
raid | host | — | viewers |
superchat |
— | — | Super Chat, Super Sticker (detail: "$5.00") |
the amount |
member |
— | — | new or returning member | months |
A gift bomb is counted once, not once per gifted sub. The same parsers also work on raw messages: twitch_event(line), kick_event(name, data) and youtube_event(item).
What chat is saying
chat = [(f"viewer{i}", "KEKW", 100 + i / 10) for i in range(40)]
chat += [("mod", "he fell off the bridge", 101.5), ("a", "CLIP IT", 102.0),
("b", "clip it!!", 102.2), ("c", "LMAOOO", 102.4)]
chat.sort(key=lambda x: x[2])
cc.signals(chat) # per second: (second, messages, chatters, reactions, repeats)
[(100, 10, 10, 10, 9), (101, 11, 11, 10, 10), (102, 13, 13, 13, 11), (103, 10, 10, 10, 10)]
cc.compact(chat, max=10) # one line per reaction: (author, text, ts, times said, people)
[('viewer0', 'KEKW', 100.0, 40, 40),
('mod', 'he fell off the bridge', 101.5, 1, 1),
('a', 'CLIP IT', 102.0, 2, 2),
('c', 'LMAOOO', 102.4, 1, 1)]
- Matching: lines are compared by
cc.norm(text), which ignores case and punctuation and squashes held letters. "LMAOOO" becomes "lmao" and "KEKW KEKW KEKW" becomes "kekw". - Reactions: the default list is
cc.KEYWORDS. Pass your own withsignals(chat, keywords=[...]). - Over
max:compactkeeps the most repeated reactions and an even spread of the rest, in order.
Parse single messages
To use your own connection, call the parsers directly:
cc.twitch_line("@display-name=Ninja :ninja!ninja@ninja.tmi.twitch.tv PRIVMSG #chan :that was insane")
# ('Ninja', 'that was insane')
cc.kick_item({"content": "W stream", "created_at": "2026-12-01T18:00:00Z", "sender": {"username": "kickfan"}})
# ('kickfan', 'W stream', 1796148000.0)
cc.youtube_item(action) # one item from YouTube's live chat feed → (author, text, ts)
Platform notes
- Twitch: pass the channel name. Anonymous read-only login.
- YouTube: pass the id of a live video (the part after
watch?v=). Chat is polled at the pace YouTube asks for. - Kick:
- Pass
room=<chatroom id>when you know it. kick.com's channel API often blocks non-browser clients with Cloudflare; without a room the hub tries anyway and retries. - The chat WebSocket itself works fine. If Kick changes its public Pusher key, the log says so, and you can pass
Hub(kick_pusher_key="...").
- Pass
- Failures: a Kick or YouTube reader that keeps failing waits longer each time: 10 s, 20 s, 40 s, up to 5 minutes.
Speed
Measured against a pure-Python implementation of the same readers (4-CPU laptop, python bench/bench.py):
| Python | clypso-chat | Faster | |
|---|---|---|---|
| Twitch parsing, 200k lines | 0.79 s | 0.10 s | 7.6× |
| Kick parsing, 100k events | 0.61 s | 0.15 s | 4.0× |
| Spike detector, per call | 178 µs | 30 µs | 6.0× |
| 1,000,000 messages over 40 streams, read + counted | 14.9 s CPU | 1.03 s CPU | 14.5× |
On 7 real channels at about 8 messages a second, the whole hub uses about 0.1% of one core.
API at a glance
Hub(cfg=None, *, threads=1, max_lines=20000, kick_pusher_key=None) |
join, leave, drain, drain_all, events, tick, rates, quiet, status, streams, logs, close |
Counter(platform="twitch", cfg=None) |
add(ts), tick(now), rates, series, quiet() |
spike(rates, cfg), chat_quiet(rates, cfg), loud_spike(db, cfg) |
the detectors on a plain list of numbers |
twitch_line, kick_item, youtube_item |
one message → (author, text[, ts]) |
twitch_event, kick_event, youtube_event |
one message → an event dict or None |
signals, compact, norm, KEYWORDS |
chat signals |
Full signatures are in clypso_chat/_native.pyi, so your editor shows them.
Development
pip install maturin
maturin develop --release && pytest # 95 tests
cargo test # the Rust unit tests
The tests run each reader against local fakes of Twitch IRC, Kick's Pusher socket and YouTube's chat feed: handshakes, pings, reconnects, events and errors. bench/smoke.py reads a few seconds of real chat.
How it plugs into the Clypso clipping engine it was built for is described in docs/CLYPSO.md.
License
MIT
Metadata
Release files for clypso-chat 0.1.1
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 |
|---|---|---|---|---|
| clypso_chat-0.1.1.tar.gz | 81.7 kB | With provenance | Details for clypso_chat-0.1.1.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| clypso_chat-0.1.1-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details for clypso_chat-0.1.1-cp310-abi3-win_amd64.whl |
| clypso_chat-0.1.1-cp310-abi3-manylinux_2_28_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.28+ ARM64 | Details for clypso_chat-0.1.1-cp310-abi3-manylinux_2_28_aarch64.whl |
| clypso_chat-0.1.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details for clypso_chat-0.1.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
| clypso_chat-0.1.1-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details for clypso_chat-0.1.1-cp310-abi3-macosx_11_0_arm64.whl |
| clypso_chat-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl | CPython 3.10 | abi3 | macOS 10.12+ x86-64 | Details for clypso_chat-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl |
Total release size: 12.4 MB
Release files / clypso_chat-0.1.1.tar.gz
| Download URL | clypso_chat-0.1.1.tar.gz |
|---|---|
| Size | 81.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
698b483c538b3ce12905bec4bc573c859d2c4651152fcf62f421e92c169d779f
|
|
BLAKE2b-256 checksum How to use checksums |
9d8cf9e94fbc143215746de62878bd09ee9045da3ccfe5939eb1cc29ad9f50a1
|
| 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 Dec 1, 2026.
Transparency logRelease files / clypso_chat-0.1.1-cp310-abi3-win_amd64.whl
| Download URL | clypso_chat-0.1.1-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 2.5 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
22d35c835c7f15509843f514d466ed57d54a2cad212dbdc7f21f87895522dd10
|
|
BLAKE2b-256 checksum How to use checksums |
650bb085168bbf88ef8687570de9ac3bddd698b57abd4cda3055f025d984ca72
|
| 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 Dec 1, 2026.
Transparency logRelease files / clypso_chat-0.1.1-cp310-abi3-manylinux_2_28_aarch64.whl
| Download URL | clypso_chat-0.1.1-cp310-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 2.5 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
37274aee929de2779ec7d13283b16eb43e8d2c4544c246e4605d0c26490a3b3e
|
|
BLAKE2b-256 checksum How to use checksums |
bc213081166fc4c9e8db5bd796544a41d01f9d98e150229ba8c5e0c2706c0748
|
| 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 Dec 1, 2026.
Transparency logRelease files / clypso_chat-0.1.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | clypso_chat-0.1.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 2.6 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
1d5bf3b68bc684b535b1efda77e0ec96d97266cc38b83465d82d67d1fb999d24
|
|
BLAKE2b-256 checksum How to use checksums |
5d5e2dc3839690945f9c389555c32c56007b5cafb58994061e0146bafc68c064
|
| 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 Dec 1, 2026.
Transparency logRelease files / clypso_chat-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | clypso_chat-0.1.1-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.3 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
c69ca416c846f71b13699906e31e5e5d22ecb8862d27d66e748e31c9bdb60d92
|
|
BLAKE2b-256 checksum How to use checksums |
2f7ff5df154a82c282d5ae5285cb567c2940f3a3b526d00a584c9f5f96ef7a88
|
| 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 Dec 1, 2026.
Transparency logRelease files / clypso_chat-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | clypso_chat-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
27932b97481bf0dfe82246dd37381a92a065a0c54b211959d675a8beaffbc688
|
|
BLAKE2b-256 checksum How to use checksums |
e7d3c57a654e2d116bf929a5d561e28e2ca4319a2093b15ae711304d1d5c3527
|
| 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 Dec 1, 2026.
Transparency logSecurity for clypso-chat 0.1.1
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
All 6 files in this release have been uploaded with provenance metadata.
Attestation for clypso_chat-0.1.1.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 Dec 1, 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.