Skip to content

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.

For each event you receive, store:

  • the event id, to skip duplicates delivered from history;
  • the id of the donation or the platform event (in the event it is data.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 marked PENDING, and the most recent Twitch and YouTube event’s recordedAt.

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.

The library reconnects automatically and provides the server’s response in the subscription event: fields by library.

  • wasRecovering: true and recovered: 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: true and recovered: 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.

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:

Terminal
curl -s "https://api.donatty.com/v1/donations?limit=100&since=2026-11-09T10:00:00Z" -H "Authorization: Bearer $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:

Terminal
curl -s "https://api.donatty.com/v1/platform-events?order=asc&since=2026-11-09T10:00:00Z" -H "Authorization: Bearer $DONATTY_TOKEN"

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.

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.

  • 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.