Skip to content

CSV reports

Method Does Limit
reports.export(request) Requests a report, waits for it and downloads the CSV combined
reports.request(request) Asks Trading 212 to build a report; returns its ID 1 / 30 s
reports.list() Every report you have asked for, with its status 1 / min
reports.waitFor(id) Checks a report until it is finished 1 / min
reports.download(report) Downloads a finished report’s CSV text none

The spec names no permission for these endpoints.

export-csv.mts
import { Trading212 } from "@kkkermit/trading212.js";
import { csvNumber, parseCsv } from "@kkkermit/trading212.js/csv";
const t212 = Trading212.fromEnv();
// Requests the report, waits for it (at least a minute) and downloads it.
const { report, csv } = await t212.reports.export(
{ from: "2026-01-01", to: "2026-12-31", include: { interest: false } },
{ onStatus: (current) => console.log(`Report ${current.reportId}: ${current.status}`) },
);
console.log(`Report ${report.reportId} has ${csv.length} characters`);
let deposits = 0;
for (const row of parseCsv(csv)) {
if (row.Action === "Deposit") deposits += csvNumber(row.Total) ?? 0;
}
console.log(`Deposited ${deposits.toFixed(2)} this year`);

export() takes at least a minute, because listing reports is limited to once a minute. Its timeoutMs (default 10 minutes) bounds the wait; the request and the download keep their own timeouts.

A request takes from and to (a Date or a date string) and include, with dividends, interest, orders and transactions all included unless you say otherwise.

const id = await t212.reports.request({ from: "2026-01-01", to: "2026-06-30" });
const ready = await t212.reports.waitFor(id, { onStatus: (report) => console.log(report.status) });
const text = await t212.reports.download(ready);

waitFor() takes timeoutMs, intervalMs (default 60 s) and onStatus, called on each check. It throws if the report failed or was cancelled. The download goes to a signed link without your credentials, and links expire, so fetch a fresh one with reports.list() if a download is refused.

The parser lives in its own entry point, @kkkermit/trading212.js/csv, so the client stays small:

Function Returns
parseCsv(text) One object per line, keyed by column name; every value a string
parseCsvRows(text) Every line as an array of strings, the header included
csvNumber(value) A number from 1234.56, 1,234.56 or -0.5, or undefined for anything else

Both parsers handle quoted fields, doubled quotes, commas and line breaks inside quotes, either line ending, and a leading byte-order mark. csvNumber() refuses a decimal comma such as 1,5, because Trading 212 writes decimals with a full stop.