Connecting: REST and streaming
There are two ways to get your channel’s donations, goals, top donors, donation totals, and Twitch and YouTube events:
- REST: your program requests data from the API. Use it for websites, reports or bots that can poll every few seconds.
- Centrifugo stream: the API sends events over an open WebSocket or HTTP connection. Use it for overlays, stream alerts or bots that need events without polling.
| REST | Centrifugo stream | |
|---|---|---|
| When you need it | a website, a report, a simple bot | an overlay, an alert on stream, a bot |
| How new data arrives | in the response to the next request | as an event in the open connection |
| What happens on a drop | repeat the request; read what you missed page by page | the channel history or a REST catch-up covers the gap: conditions |
| Key | secret; public for the profile, goals and stats | secret only |
| Key scopes | the scope required by the method | the scope required by the channel |
Platform delays apply to both REST and the stream. Twitch subscriptions arrive later than other events; YouTube events arrive after polling. See Twitch conditions and YouTube conditions.
How recovery after a drop works
Section titled “How recovery after a drop works”For what channel history can recover, when to catch up over REST and which timestamp to start from, see History and catch-up. For the steps and requests, see the Stream and catch-up example.
What you need besides the key
Section titled “What you need besides the key”For the scope required by each source, see Keys and scopes. For dashboard setup and when Donation Alerts, Twitch and YouTube events become available, see Source conditions.
Where to start
Section titled “Where to start”- REST: donations over REST, data for a website
- Stream: first streamed donation, connect Twitch, connect YouTube
- Catch-up after a stream drop: the Stream and catch-up example
- What comes in responses and events: response and event structures