Skip to content

Client

FireflyClient owns an async HTTP client. Pass the Firefly III instance root and a personal access token, then close it in a finally block. Read methods return simplified domain models. Updates affect real data and may trigger Firefly III rules and webhooks.

For an executable flow, start with Getting started. For skipped multipart groups and matching behavior, see Transactions and matching.

FireflyClient

Async client for the supported Firefly III endpoints.

Pass the instance root URL without /api/v1 and a personal access token. Always call :meth:close when finished, typically in a finally block. Listing methods return handwritten domain models; the generated OpenAPI transport models remain internal.

Parameters:

Name Type Description Default
base_url str

Firefly III instance root, for example https://firefly.example. A trailing slash is accepted.

required
token str

Personal access token sent as a bearer token.

required

close() -> None async

Release the underlying HTTP connections.

Call this once after the final request. The client does not implement an async context manager.

get_about() -> SystemInfo async

Read version and environment information from /api/v1/about.

Returns:

Type Description
SystemInfo

System information. Individual fields may be None when Firefly

SystemInfo

III omits them.

Raises:

Type Description
FireflyAPIError

The request fails or the response is invalid.

fetch_transactions(*, tx_type: str = 'withdrawal', page_size: int = 1000, max_pages: int | None = None, start_date: date | None = None, end_date: date | None = None) -> list[SimplifiedTx] async

Fetch single-split transactions across Firefly III pages.

Multipart groups and responses that cannot be mapped are logged and skipped. The result is therefore not guaranteed to contain every transaction group reported by Firefly III. Use fetch_transactions_with_stats to count those skipped groups.

Parameters:

Name Type Description Default
tx_type str

Firefly III transaction type filter. Defaults to "withdrawal". Use "deposit" or "transfer" for a single type, or "all" to request all types from the API. Only single-split withdrawals, deposits, and transfers can be returned as SimplifiedTx objects.

'withdrawal'
page_size int

Requested number of groups per API page.

1000
max_pages int | None

Maximum pages to request, or None to follow pagination to the end.

None
start_date date | None

Inclusive start date sent to the API, if supplied.

None
end_date date | None

Inclusive end date sent to the API, if supplied.

None

Returns:

Type Description
list[SimplifiedTx]

Successfully mapped transactions in API order.

Raises:

Type Description
FireflyAPIError

A request fails or a page has an invalid schema.

fetch_categories(limit: int = 1000, simplified: bool = False) -> list[SimplifiedCategory] async

Fetch all categories across Firefly III pages.

Parameters:

Name Type Description Default
limit int

Requested number of categories per API page.

1000
simplified bool

Retained for compatibility; currently ignored. The method always returns SimplifiedCategory objects.

False

Returns:

Type Description
list[SimplifiedCategory]

Mapped categories in API order.

Raises:

Type Description
FireflyAPIError

A request fails or the response is invalid.

fetch_accounts(*, account_type: str | None = None, active: bool | None = None, limit: int = 50) -> list[SimplifiedAccount] async

Fetch all accounts matching the supplied filters across API pages.

Parameters:

Name Type Description Default
account_type str | None

Optional Firefly III type filter, such as expense.

None
active bool | None

Filter by active status. With None, return both.

None
limit int

Requested number of accounts per page.

50

Returns:

Type Description
list[SimplifiedAccount]

Accounts in API order.

Raises:

Type Description
FireflyAPIError

A request fails or the response is invalid.

get_account_balance(account_id: int, *, on_date: date) -> AccountBalance async

Fetch the end-of-day balance of one account.

Parameters:

Name Type Description Default
account_id int

Firefly III account ID.

required
on_date date

Calendar date for the balance.

required

Returns:

Type Description
AccountBalance

Signed balance in the currency and calendar date reported by Firefly III.

Raises:

Type Description
FireflyAPIError

The request fails, balance data is invalid or missing, or the response is for a different account or day.

create_account(*, name: str, account_type: Literal['expense', 'revenue'], iban: str | None = None, account_number: str | None = None) -> SimplifiedAccount async

Create an expense or revenue account.

Parameters:

Name Type Description Default
name str

Account name.

required
account_type Literal['expense', 'revenue']

Use expense for payees or revenue for payers.

required
iban str | None

Optional international bank account number.

None
account_number str | None

Optional separate account number.

None

Returns:

Type Description
SimplifiedAccount

The created account, including its Firefly III ID.

Raises:

Type Description
FireflyAPIError

The request fails or the response is invalid.

ValueError

The account type is unsupported.

get_transaction(transaction_id: int) -> SimplifiedTx async

Fetch one single-split transaction by Firefly III group ID.

Parameters:

Name Type Description Default
transaction_id int

Firefly III transaction group ID.

required

Returns:

Type Description
SimplifiedTx

The mapped transaction.

Raises:

Type Description
FireflyAPIError

The request or validation fails, or the group has multiple splits or cannot be mapped.

update_transaction(transaction_id: int, update: TransactionUpdate, *, apply_rules: bool = True, fire_webhooks: bool = True) -> SimplifiedTx async

Update selected fields of a single-split transaction.

Reads and validates the current single-split group before writing and targets its journal ID. This is not an atomic compare-and-set; concurrent changes and server-side rules may still affect the result.

Firefly III rules and webhooks are enabled by default. Supplying tags replaces the full tag list; use build_add_tag_payload to preserve existing tags while adding one. The returned response must still be mappable as a single-split transaction.

Parameters:

Name Type Description Default
transaction_id int

Firefly III transaction group ID.

required
update TransactionUpdate

Fields to change on the split, including its type and account IDs. Firefly III validates account types against the requested transaction type.

required
apply_rules bool

Run Firefly III rules after the update.

True
fire_webhooks bool

Trigger Firefly III webhooks after the update.

True

Returns:

Type Description
SimplifiedTx

The mapped transaction returned by Firefly III after the update.

Raises:

Type Description
ValueError

No update field was supplied, or the type changes without both account IDs.

FireflyAPIError

The request or validation fails, or the returned transaction cannot be mapped.

TransactionUpdate dataclass

Fields accepted by FireflyClient.update_transaction().

Supply at least one field. None means leave a field unchanged; an empty tag list removes all tags. A supplied tag list replaces the entire existing list rather than adding to it.

Attributes:

Name Type Description
description str | None

Replacement description.

notes str | None

Replacement notes; an empty string clears existing notes.

tags list[str] | None

Complete replacement list of tag names.

category_id int | None

Firefly III category ID to assign.

reconciled bool | None

True to reconcile, False to undo, None to leave unchanged.

source_id int | None

Firefly III account ID for the source of the transaction.

destination_id int | None

Firefly III account ID for the destination.

type TxType | None

Replacement transaction type. Changing the type requires both account IDs in the same update. For a transfer, use asset accounts.

FireflyAPIError

Bases: RuntimeError

Error raised for HTTP, network, JSON, or response mapping failures.

Attributes:

Name Type Description
status_code

HTTP status for an HTTP or JSON response error, or None when no usable HTTP response was received.