Install
--pre.
The JavaScript package is an ES module, but from 1.0.0-beta.1 on Node 20.19+ and 22.12+ you can also load it with
const { Degroshi } = require("degroshi").
The first request
Create a key under “Settings” › “For developers” and pass it to the client. Without one, the client reads theDEGROSHI_API_KEY environment variable. Keep the key on a server: in a browser, anyone can see it. Everything about
keys: API keys.
new Degroshi({ apiKey, spaceId }) or
Degroshi(api_key, space_id=...). See Spaces.
Keeping a copy
changes.iterate() reads the change feed, GET /v1/changes: everything that changed since your cursor, deletions
included, in the order the changes were saved. Without a cursor it starts with every object. The SDK reads every page
itself; after the loop, save feed.cursor and pass it next time:
changes.iterate() returns a ChangeFeed, and on AsyncDegroshi an AsyncChangeFeed for async for. A cursor that
can’t continue (the space’s access changed, or 180 days passed) throws a DegroshiError with status 410 and code
CHANGES_RESYNC_REQUIRED: read everything again without a cursor and replace the copy. How the feed works, and a Google
Sheets recipe: Keeping a copy.
Good to know
- Amounts. The JavaScript SDK returns amounts as strings, as the API sends them (
"642.30"), and the Python SDK asDecimal, so no cent is lost to rounding. - Safe retries. Requests that create transactions or write to custom sources send an
Idempotency-Key, so a retry after a dropped connection doesn’t record the transaction twice. See Safe retries. - A retried delete. When the answer to a delete is lost (a dropped connection, a timeout, a 5xx), the SDK retries
it. If the retry no longer finds the row (404), the delete counts as done, because the first try made it: the SDK
returns a 204 with
X-Degroshi-Retried-Delete: true(RETRIED_DELETE_HEADER). A 404 on the first try still throwsNotFoundError. - Types. Every method returns its own response type, so your editor knows the fields. In Python that holds for
DegroshiandAsyncDegroshialike, and the request and response models are indegroshi.models. Python writes take a model or a plaindictin the API’s JSON shape.
What’s next
degroshi-js
The JavaScript and TypeScript SDK on GitHub.
degroshi-python
The Python SDK on GitHub.
API keys
Create a key, pick its access and its space.
Errors
Error codes and what to do about them.