> ## Documentation Index
> Fetch the complete documentation index at: https://docs.degroshi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SDKs

> The official libraries for JavaScript and Python: install, the first request, amounts and safe retries.

The official SDKs work with the same public API this section describes. They have methods for accounts, transactions,
categories, budgets, recurring payments, analytics, custom sources, events and the change feed. They retry by
themselves after a network failure or a temporary error, and check webhook signatures for you. The code is open:
[degroshi-js](https://github.com/degroshi/degroshi-js) and
[degroshi-python](https://github.com/degroshi/degroshi-python).

## Install

```bash JavaScript theme={null}
npm i degroshi
```

```bash Python theme={null}
pip install --pre degroshi
```

The current versions are 1.0.0-beta.10 for JavaScript and 1.0.0b10 for Python (19 November 2026). What changed in each
version is in the repository’s CHANGELOG.

The JavaScript SDK has no dependencies and runs on Node 20+, Bun, Deno and edge runtimes. The Python SDK needs Python
3.11+. While 1.0 is in beta, pip installs it only with `--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 the
`DEGROSHI_API_KEY` environment variable. Keep the key on a server: in a browser, anyone can see it. Everything about
keys: [API keys](https://docs.degroshi.com/en/developers/authentication.md).

```javascript JavaScript theme={null}
import { Degroshi } from "degroshi"

const degroshi = new Degroshi({ apiKey: process.env.DEGROSHI_API_KEY })

const accounts = await degroshi.accounts.list()
for (const account of accounts) {
  console.log(account.name, account.current_balance, account.currency_code)
}
```

```python Python theme={null}
import os

from degroshi import Degroshi

with Degroshi(os.environ["DEGROSHI_API_KEY"]) as degroshi:
    for account in degroshi.accounts.list():
        print(account.name, account.current_balance, account.currency_code)
```

If the key works in several spaces, pass the space too: `new Degroshi({ apiKey, spaceId })` or
`Degroshi(api_key, space_id=...)`. See [Spaces](https://docs.degroshi.com/en/developers/authentication.md#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:

```javascript JavaScript theme={null}
const feed = degroshi.changes.iterate({ cursor: saved, types: ["transaction"] })
for await (const change of feed) {
  if (change.op === "delete") copy.delete(change.id)
  else copy.set(change.id, change.data)
}
save(feed.cursor)
```

```python Python theme={null}
feed = degroshi.changes.iterate(cursor=saved, types=["transaction"])
for change in feed:
    if change.op == "delete":
        copy.pop(change.id, None)
    else:
        copy[change.id] = change.data
save(feed.cursor)
```

`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](https://docs.degroshi.com/en/developers/changes.md).

## Good to know

* **Amounts.** The JavaScript SDK returns amounts as strings, as the API sends them (`"642.30"`), and the Python SDK as
  `Decimal`, 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](https://docs.degroshi.com/en/developers/writing.md#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 throws
  `NotFoundError`.
* **Types.** Every method returns its own response type, so your editor knows the fields. In Python that holds for
  `Degroshi` and `AsyncDegroshi` alike, and the request and response models are in `degroshi.models`. Python writes take
  a model or a plain `dict` in the API’s JSON shape.

Errors, paged lists, webhooks and versions are in each repository’s README. Report a bug in an SDK or ask for something
in the repository’s issues on GitHub.

## What’s next

> [card] [degroshi-js](https://github.com/degroshi/degroshi-js)
>
> The JavaScript and TypeScript SDK on GitHub.

> [card] [degroshi-python](https://github.com/degroshi/degroshi-python)
>
> The Python SDK on GitHub.

> [card] [API keys](https://docs.degroshi.com/en/developers/authentication.md)
>
> Create a key, pick its access and its space.

> [card] [Errors](https://docs.degroshi.com/en/developers/errors.md)
>
> Error codes and what to do about them.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.