# Export a month of transactions

> Page through entries and write a spreadsheet your accountant can open.

Source: https://app.getoatmilk.com/docs/tutorials/export-transactions

This script reads every entry in a month, page by page, and writes a CSV with the merchant, date, amount, tax and status. It's a starting point for a month-end report, a data warehouse load or a spreadsheet for your accountant.

## 1. Read every page

`entries.list` returns up to 500 entries per page. Ask for the month with `from` and `to`, and stop when a page comes back short.

```bash
curl -G https://app.getoatmilk.com/api/v1/accounting/entries.list \
  -H "Authorization: Bearer $OATMILK_API_KEY" \
  --data-urlencode 'from=2026-09-01' \
  --data-urlencode 'to=2026-09-30' \
  --data-urlencode 'limit=500' \
  --data-urlencode 'offset=0'
```

```js title="export.js"
import { writeFile } from "node:fs/promises";

const entries = [];
for (let offset = 0; ; offset += 500) {
  const page = await callOatmilk("entries.list", { from: "2026-09-01", to: "2026-09-30", limit: 500, offset });
  entries.push(...page);
  if (page.length < 500) break;
}
```

## 2. Write the CSV

Amounts are cents written as strings, so divide by 100 only when you format them, and keep each currency in its own column.

```js title="export.js"
const cell = value => `"${String(value ?? "").replaceAll('"', '""')}"`;
const money = minor => (Number(minor) / 100).toFixed(2);
const rows = entries.map(entry => [entry.date, entry.merchant, entry.type, entry.currency, money(entry.amount_minor), money(entry.tax_minor), entry.status]);
const csv = [["Date", "Merchant", "Type", "Currency", "Amount", "Tax", "Status"], ...rows].map(row => row.map(cell).join(",")).join("\n");
await writeFile("2026-09.csv", csv);
```

## Or let Oatmilk build it

For an export with every original receipt attached, or one ready for tax, ask Oatmilk to build it with `reports.export`. It runs in the background and tells you where to download it when it's done.

```bash
curl https://app.getoatmilk.com/api/v1/accounting/reports.export \
  -H "Authorization: Bearer $OATMILK_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
  "format": "csv",
  "from": "2026-09-01",
  "to": "2026-09-30"
}'
```
