GET /v1/changes. It returns everything that changed after your cursor, deletions included, in the order the changes
were saved. So the copy never misses a row and never keeps a deleted one.
How to read it
1
First read without a cursor
GET /v1/changes without cursor returns every object of the space as an upsert, in pages of up to limit
(100, at most 500). That is your first copy: you don’t need to read the lists separately.2
Keep next_cursor
Every page has a
next_cursor. Keep it, even when items is empty.3
Read to the end
While
has_more is true, ask for the next page right away with cursor=<next_cursor>.4
Next time
Ask with the last
next_cursor: only what changed since then arrives. Read as often as you like, within the
limits.changes.iterate() does this: it reads every page itself and
keeps the cursor.
What arrives
Each item ofitems is one object:
type: what kind of object it is (table below).id: itsid.op:upsertwhen the object is new or changed, ordeletewhen it was deleted or you can no longer see it.data: for anupsert, the object as it is now, in the same shape as in its list. Adeletehas nodata.
types picks what to read: types=transaction,account or several types=. Without it you get everything the token
may read. A type the token has no permission for simply doesn’t arrive, and a token with none of these permissions
gets 403.
An object that changed several times arrives once per page, in its latest state. It may arrive again on a later page,
so replace the copy’s row by id rather than adding a new one.
The feed carries no rates or totals. Analytics, net worth and the days of recurring payments
(/v1/recurring-transactions/occurrences) are computed by the server each time, so read them again. Read sources
(/v1/sources) from their list, and webhook events from the event log.
When a cursor can’t continue
Sometimes a cursor can’t be continued. The API then answers 410 with the codeCHANGES_RESYNC_REQUIRED, and
details.reason says why:
Then read the feed again without a cursor and replace the whole copy.
Recipe: Google Sheets every hour
The spreadsheet pulls the changes itself every hour. This is a pull, not a webhook: an Apps Script web app answers with a 302 redirect, so webhook deliveries would count as failed.1
The sheet
Create a sheet named “Операції” with a header row:
id, date, description, amount, account, category. (Or
rename the sheet in the code.)2
The key
Create an API key with the
transactions:read permission for one space. In the
spreadsheet open “Extensions” › “Apps Script”, add the script property DEGROSHI_KEY in the project settings and
paste the key there. Keep the key out of the code.3
The code
Paste the code below and run
syncTransactions once to grant access. The first run copies every transaction.4
Every hour
In the triggers section, add a time-driven trigger for
syncTransactions that runs every hour.Apps Script
An amount in the API is a string with an exact decimal number (“-642.3”).
Number() turns it into a number for the
sheet’s formulas. For bookkeeping where every cent matters, keep the string.