Skip to content

Connect Twitch

Receive events from your Twitch channel in a macOS, Linux or Windows terminal: follows, subscriptions, bits, raids, channel point rewards and hype train levels.

1. Issue a key with the Twitch events scope

Section titled “1. Issue a key with the Twitch events scope”

Before you start, check the Source conditions. In the «Секретные ключи» (Secret keys) section, click «Выпустить секретный ключ» (Issue secret key). Enter a name, tick «События Twitch» (Twitch events, twitch:read), choose an expiration period and click «Выпустить ключ» (Issue key).

To find out which keys support this scope, see Secret key scopes.

Open Developers in your dashboard

Save the key in the DONATTY_TOKEN variable: how to do it.

Terminal
curl -s "https://api.donatty.com/v1/event-sources" -H "Authorization: Bearer $DONATTY_TOKEN"

Find the item with "platform": "TWITCH" in items. Before the first connection its status is IDLE: there are no stream connections yet. This is expected. No such item means the key has no twitch:read scope or no Twitch account is linked to your dashboard.

Terminal
curl -N -X POST "https://api.donatty.com/v1/realtime/uni_http_stream" \
-H "Authorization: Bearer $DONATTY_TOKEN" -H "Content-Type: application/json" -d '{"data": {"channels": ["twitch"]}}'

In PowerShell, pipe the request body through | to preserve the JSON quotes when calling curl.exe.

The command reads the stream until you press Ctrl+C. In the first line, subs contains the twitch:str_… channel. For when collection starts and how long events take to arrive, see Source conditions.

Event data is in pub.data, for example twitch.follow when someone follows the channel. All types and their fields are in Twitch event formats.

Repeat the request from step 2 in another terminal window and wait for the READY status. A status change also arrives in the stream as a source.status_changed event. For the meaning of each status, see Source status.

After a long disconnection, use the Platform events method to catch up. For commands and steps, see the Stream and catch-up example. For recovery requirements, see History and catch-up. REST cannot return events that Donatty did not receive from Twitch. See Source conditions.