Reads what the Qonto API answers for one bank account — the account and its transactions — into a bank statement, in TypeScript, with no dependencies.
A company reaches its own Qonto accounts with its own key: the organisation's
login and secret key, read only. This reader makes no request: the caller
fetches (GET /v2/organization for the bank accounts, the pages of
GET /v2/transactions for one of them) and hands the answer over. What comes
back is a statement as the file readers return one — an account, two balances
and lines — so it enters a ledger the way a camt.053 does.
import { readQontoTransactions } from '@ekwo-ai/qonto-transactions';
const { statements, violations } = readQontoTransactions(
{ account, transactions }, // one of organization.bank_accounts, and every page's transactions
{ openingBalance: '1700.00', balanceDate: '2026-11-30' },
);
const statement = statements[0];
statement.closingBalance; // { type: 'CLBD', amount: '2149.90', currency: 'EUR', date: '2026-11-30' }
statement.balanced; // true: 1700.00 plus the settled lines is the balance
for (const line of statement.lines) {
line.amount; // '-800.00' — signed by its `side`, a decimal string, never a float
line.booked; // true for a settled transaction; a pending or declined one is returned, not booked
}
It knows no database and no ledger. The shape it returns is declared in
src/types.ts, imported from nowhere, and is field for
field the shape @ekwo-ai/camt053 declares for itself; what
only Qonto says comes after (emittedOn on a line, openingImplied on the
statement). Nothing here assumes a currency, a number of decimals, a country or
a language.
The balances
An API gives a balance now, not a statement with two ends. So:
- The closing balance is the account's
balance, dated onbalanceDate— the day the caller read it — or, without one, on the newest settled line. - The opening balance is the caller's to declare: the closing balance of
the statement before, which it kept. The settled lines are then checked
against it, and a transaction the answer lacks shows as
balance_mismatch, with the difference. It is never corrected. openingBalance: 'implied'is for a first statement, with nothing before it: the opening is the balance less the settled lines,openingImpliedsays so, andbalancedstaysnull.
A line's booking day is the day of settled_at, as written. Settled lines
are ordered by the instant they settled, and the same instant by id. The
statement's id is the day of the balance and the id of the newest settled
transaction: the same transactions, in any order, always make the same one.
The statement's period runs from the earliest to the latest of the settled
days and the balance day, so it never ends before it starts. A line settled
after balanceDate widens it to that line's day; the closing balance keeps
its own day.
Options
| Option | What it says |
|---|---|
openingBalance |
A decimal string (1250.00, -40.10), or implied. Left out, the statement has no opening balance. |
balanceDate |
YYYY-MM-DD: the day the balance was read. |
maxTransactions |
Refuse more transactions than this, unread. Default 100 000. |
What is thrown, and what comes back as a violation
Thrown (StatementFileError, with a code): not_a_response (no account,
no IBAN, no currency, a balance that is not an amount, transactions that are
not a list), too_large, invalid_option.
Returned in violations, with the line and the transaction id:
| code | when |
|---|---|
balance_mismatch |
the declared opening plus the settled lines is not the balance |
invalid_amount, invalid_date |
the line comes back with null there |
unknown_side |
a side that is neither credit nor debit: the amount has no sign, and comes back null |
other_currency |
a transaction in another currency than its account: kept, and an importer refuses it |
duplicate_transaction |
the same id twice — two pages that overlap: the second is returned with status INFO, not booked and not counted in the balance, so it is imported once |
What it does not do
- It makes no request and holds no key.
- It reads no attachment. The receipts attached to a transaction are another answer of the API, and another brick's job.
- It converts nothing: the amount of an operation in another currency is
kept beside the line (
instructedAmount), never used for the balance. - It moves no date to another time zone:
settled_atis read as written. Qonto writes it in UTC, so the booking day is the UTC day — open point for the caller: a transaction settled on 31 December at 23:30 UTC is booked on 31 December, though it is already 1 January in Paris.
Not verified
The answers in the tests are invented, shaped on Qonto's documentation.
Read in Qonto's sandbox (30/11/2026, one account, three settled incoming
transfers, fetched over two pages): the reader returns three booked lines and
no violation; an opening balance of 0.00 plus the lines is the account's
balance, and a wrong opening comes back as balance_mismatch; every settled
transaction carries settled_at; GET /v2/transactions answers the same
transactions by iban and by bank_account_id; an incoming transfer carries
its counterparty under income.
Still not verified: that balance leaves out a transaction that is not
settled yet — the sandbox account had none, so the sum is the same either way
(the account also carries an authorized_balance, which the reader does not
use); the counterparty fields of an outgoing transfer (transfer), of a card
payment and of a direct debit; and an account with months of history.
Licence
MIT. See LICENSE.