I’ve been setting up a Sigma-like replica of Stripe. However, unlike the Gmail API, the Stripe email isn’t built for data sync, but for…well, billing flows.
Getting a snapshot of current state is relatively easy. Most endpoint offer pagination, so getting all current charges or customers is easy. However, polling against this endpoint with the
starting_after cursor will only give you newly created objects, not the updates or deletions.
To get updates, you have to hit the Events endpoint. However, events are only guaranteed to go back 30 days, so you can’t use it to sync state. Therefore, get a in-sync version, you need to use both.
- Get most recent event_id to be used as a cursor.
- Poll all endpoints to get all data
- Poll against the list event endpoint with
If you’d like to have more real-time data, you can use webhooks. Webhooks for Stripe (as well as many other B2B services) are user-configured, so it’s always possible for them to be turned off without your server knowing or worse, if your server goes down and fails the respond to webhooks, many API services automatically turn them off.
It’s also worth nothing that the the List all events endpoint returns events in chronological order, so always used the last event in the array as the next
Hence Gmail’s guide to synch recommending that you continue to periodically poll, using webhooks soley for more real-time information.