Stream and catch-up
Use these steps to resume receiving events from the Centrifugo stream after a disconnection. For recovery guarantees and limits, see History and catch-up. The key is in the DONATTY_TOKEN variable: how to save it.
1. Remember what you processed
Section titled “1. Remember what you processed”For each event you receive, store:
- the event
id, to skip duplicates delivered from history; - the
idof the donation or the platform event (in the event it isdata.id), to match it with the catch-up records; - the data needed to choose where to start catch-up: the newest donation’s
createdAt, donations still markedPENDING, and the most recent Twitch and YouTube event’srecordedAt.
To resume after a restart, persist this data outside process memory. To recover channel history, also save the channel epoch and the processed publication’s offset if your client exposes them. Do not advance the saved position before processing succeeds.
2. After reconnecting, look at recovered
Section titled “2. After reconnecting, look at recovered”The library reconnects automatically and provides the server’s response in the subscription event: fields by library.
wasRecovering: trueandrecovered: true— the server recovered the gap from the supplied position. No REST catch-up is needed for that gap; process the recovered events and discard duplicates.wasRecovering: trueandrecovered: false: history did not cover the gap. Catch up using the steps below.- Both
false— the client did not request recovery. After a restart without a position, catch up over REST from your saved processing checkpoint; if it is missing, choose an initial load period. These flags do not prove that there is no gap.
The HTTP stream does not reconnect by itself: open it again with epoch and offset (how) and look at recovered in the first line of the response.
3. Wait and read each channel
Section titled “3. Wait and read each channel”Wait a random time from 1 to 10 seconds, then catch up on each channel your program uses. Choose a starting timestamp from the How to read the gap table and replace the date in the commands with it.
Donations, without the moderation filter:
curl -s "https://api.donatty.com/v1/donations?limit=100&since=2026-11-09T10:00:00Z" -H "Authorization: Bearer $DONATTY_TOKEN"curl.exe -s "https://api.donatty.com/v1/donations?limit=100&since=2026-11-09T10:00:00Z" -H "Authorization: Bearer $env:DONATTY_TOKEN"For goals, use Fundraising goals to read their current state. No starting timestamp is needed.
Twitch and YouTube events, oldest first, order=asc:
curl -s "https://api.donatty.com/v1/platform-events?order=asc&since=2026-11-09T10:00:00Z" -H "Authorization: Bearer $DONATTY_TOKEN"curl.exe -s "https://api.donatty.com/v1/platform-events?order=asc&since=2026-11-09T10:00:00Z" -H "Authorization: Bearer $env:DONATTY_TOKEN"4. Follow the pages and drop repeats
Section titled “4. Follow the pages and drop repeats”While nextCursor is not null, request the next page with cursor=<nextCursor> and the same parameters. For platform events, keep order=asc: a cursor from a different order will not work. An order=asc pass includes events recorded up to the first page request. Later events arrive through the stream or in the next pass.
Skip records whose id you have already processed: donations by the donation id, Twitch and YouTube events by the platform event id (pevt_…). Show donations by the Moderation and display rule. Update the starting timestamps for the next catch-up only after reading all pages successfully.
5. Read the gaps of the sources
Section titled “5. Read the gaps of the sources”REST cannot return events that Donatty did not receive from the platform. These gaps appear in the source status. Once the source is READY again, read its events the same way, with since a few minutes before gapSince.
Limitations
Section titled “Limitations”- State kept only in memory is lost on restart. Without saved processed
ids, a catch-up checkpoint and the channel position, automatic reconnection cannot restore the program’s progress: events may be shown again or missed. - The catch-up returns only what Donatty received: source conditions.
For programs that implement these steps for donations, see Streaming donations: Python, Streaming donations: Go and the OBS donation overlay.