Twitch lurk tracking for Nightbot — powered by Cloudflare
LurkAPI lets your Twitch chat track who is lurking using
Nightbot custom commands.
When a viewer runs !lurk, the bot records the time. When they run
!unlurk, the bot reports how long they were away. No setup is needed
beyond adding the commands — Nightbot automatically passes the viewer’s identity in its request headers.
Data is stored per-channel. Lurkers who have been gone for more than 24 hours are automatically pruned.
All endpoints are GET requests under /api/.
They require the standard Nightbot request headers (Nightbot-User and Nightbot-Channel),
which Nightbot sends automatically.
| Method | Path | Description | Response example |
|---|---|---|---|
| GET | /api/lurk | Start lurking (visible confirmation) | StreamerName started lurking |
| GET | /api/lurksilent | Start lurking (no chat message) | silent — returns a single space |
| GET | /api/unlurk | Stop lurking with full message | StreamerName stopped lurking after 1:23:45 |
| GET | /api/unlurktime | Stop lurking, return duration only | 1:23:45 |
| GET | /api/lurkers | List all current lurkers in the channel | Current Lurkers: Alice, Bob, Charlie |
Add these as custom commands in your
Nightbot dashboard.
Replace lurk.helpful.stream with
staging.lurk.helpful.stream to test on staging first.
$(urlfetch https://lurk.helpful.stream/api/lurk)
$(urlfetch https://lurk.helpful.stream/api/lurksilent)
$(urlfetch https://lurk.helpful.stream/api/unlurk)
$(user) was lurking for $(urlfetch https://lurk.helpful.stream/api/unlurktime)
$(urlfetch https://lurk.helpful.stream/api/lurkers)
When Nightbot calls a $(urlfetch ...) URL, it attaches
Nightbot-User and Nightbot-Channel headers containing the
viewer’s Twitch ID, display name, and the channel they’re in.
LurkAPI reads these headers, looks up or updates the viewer’s lurk record in a
Cloudflare D1 database, and returns a plain-text response that Nightbot posts to chat.
Lurk times are stored as Unix timestamps. The duration is calculated at unlurk time.
Entries older than 24 hours are automatically removed when the /api/lurkers
endpoint is called.