Skip to main content
This is the loop an integration like Publisher Champ’s runs for each connected author. It uses two endpoints:
  • GET /events for anything that just happened (went viral, passed a milestone), to notify the author.
  • GET /stats for day-by-day views, to draw or annotate a chart.

1. Notify on new events

Store one cursor per author. Each run, ask for events after it, handle them, and save the new cursor. You only ever see each event once.
The first call without after returns the author’s whole history since 15 June 2026. If you only want to notify about new things, page through that first batch without notifying, save the cursor, and notify from the next run on. occurred_at tells you when each event happened.

2. Annotate the chart

Ask for the days you draw. The range is up to 90 days, and videos with no new views in the range are left out.
With group_by=book, each book gets its views per day plus videos_went_viral listing the videos that went viral that day, which lines up with sales charts drawn per book:
Sonder doesn’t store ASINs. Match books to your catalogue by title; GET /books lists every title along with its subtitle and author name.

3. Schedule it

  • Run every 1 to 4 hours per author. Views refresh hourly, so more often gains nothing.
  • Each key allows 60 requests a minute, far more than this loop needs.
  • On 401 api_key_revoked, mark the connection as disconnected and ask the author to reconnect.
  • On 403 plan_inactive, keep the connection and try again on the next run.
  • On 429 or 5xx, wait (use Retry-After when present) and try again.