Skip to content

History and pagination

List Holds Filters Permission
history.orders Filled and cancelled orders, with their fills ticker history:orders
history.dividends Dividends paid out ticker history:dividends
history.transactions Deposits, withdrawals, fees, transfers and interest time, from then history:transactions

Each allows 20 requests a minute, and each has the same two methods: list() for one page and all() for every item.

dividends-total.mts
import { Trading212 } from "@kkkermit/trading212.js";
const t212 = Trading212.fromEnv();
// The UK tax year that started on 6 April 2026.
const { total, count, currency, byTicker } = await t212.history.dividends.total({
since: "2026-04-06",
until: "2027-04-06",
});
console.log(`${count} dividends, ${total.toFixed(2)} ${currency ?? ""}`);
for (const [ticker, amount] of Object.entries(byTicker))
console.log(ticker.padEnd(14), amount.toFixed(2));

history.dividends.total() adds up the dividends paid from since up to, but not including, until, both optional, for every ticker or one ticker. It returns { total, count, currency, byTicker }, with each ticker’s total largest first. It reads every page of the dividend history, 50 payments per request, because Trading 212 does not say the history is sorted, so stopping early could leave a payment out.

for await (const dividend of t212.history.dividends.all({ ticker: "AAPL_US_EQ" })) {
console.log(dividend.paidOn, dividend.amount);
}

all() fetches pages as the loop asks for them, newest first. It takes:

Option Does
pageSize Items per request, 1 to 50. Default 50, the fewest requests
maxPages Stop after this many pages
maxItems Stop after this many items
cursor Start from a saved cursor
filters ticker, or time for transactions
signal, timeoutMs Cancel it, or limit each request

It stops without fetching another page once a limit is reached. To collect everything into an array, use await Array.fromAsync(t212.history.dividends.all()).

history-pages.mts
import { isTrading212Error, Trading212 } from "@kkkermit/trading212.js";
const t212 = Trading212.fromEnv();
// One page at a time: up to 50 items, newest first.
const first = await t212.history.orders.list({ ticker: "AAPL_US_EQ", limit: 50 });
for (const { order, fill } of first.items)
console.log(order?.id, order?.status, fill?.price);
// The cursor is a plain string, so it can be saved and used later.
if (first.nextCursor) {
const second = await t212.history.orders.list({ cursor: first.nextCursor });
console.log(`The second page has ${second.items.length} orders`);
}
// When a long walk fails part-way, resumeCursor says where to carry on.
try {
for await (const transaction of t212.history.transactions.all({ maxItems: 1000 })) {
console.log(transaction.dateTime, transaction.type, transaction.amount);
}
} catch (error) {
if (isTrading212Error(error) && error.resumeCursor) {
console.log(`Stopped early. Carry on with { cursor: "${error.resumeCursor}" }`);
} else {
throw error;
}
}

list() returns one page: items, nextCursor (a string, or null on the last page), hasMore, and next(), which fetches the following page or resolves to null. limit is 1 to 50; Trading 212’s default is 20. A cursor is a plain string, so you can store it and carry on later with { cursor }.

If a request fails part-way through all(), the error carries resumeCursor: pass it as cursor to pick up where it stopped.

A long history takes a while at 20 requests a minute; the client paces itself rather than hitting the limit, so a loop over thousands of items simply runs for a few minutes. nextPagePath from Trading 212 is followed only if it points back at the same endpoint on the same host, because the next request carries your credentials.