# Pdf Bank Statement To Csv Transactions (`first_watch/pdf-bank-statement-to-csv-transactions`) Actor

Bookkeepers, small lenders and automation builders receive months of bank or credit-card statement PDFs. They need one clean, de-duplicated, balance-checked transaction ledger they can import into Xero, QuickBooks or any OFX-capable tool. Existing converters handle one statement at a time, only...

- **URL**: https://apify.com/first\_watch/pdf-bank-statement-to-csv-transactions.md
- **Developed by:** [Jordan Nabbe](https://apify.com/first_watch) (community)
- **Categories:** Automation, Business, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $6.40 / 1,000 result returneds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## PDF Bank Statement to Ledger (CSV, OFX, Xero, QuickBooks)

Turn a pack of bank or credit-card statement PDFs into one clean, balance-checked, de-duplicated transaction ledger. The Actor is built for bookkeepers and accountants onboarding a client's back statements, for small lenders and brokers reviewing 3 to 12 months of statements, and for n8n, Make and Zapier users who forward monthly statement PDFs into accounting. It parses the real PDF files, checks that every statement reconciles (opening balance plus transactions equals closing balance), removes rows repeated by overlapping statements, gives every row a stable transaction ID and writes import-ready files per account. You stop re-keying statements, and you catch missing months and double imports before they reach the books.

### What it does

- Reads **text-based statement PDFs** supplied as base64 strings (the main mode, which works fully offline) or as `https` URLs such as signed Drive, S3 or Dropbox links. Text is extracted from the actual PDF bytes with a real PDF parser. Password-protected PDFs work when you pass the password.
- Finds the statement header (last 4 digits of the account number, currency, statement period, opening and closing balance) and parses transaction lines: date, description (wrapped continuation lines are joined), amount and running balance.
- Understands ISO dates (`2026-01-05`), numeric dates (`05/01/2026`; you can set the day/month order or let the Actor detect it from the whole document) and textual dates (`5 Feb 2026`, `Feb 5, 2026`, and `05 Feb` with the year taken from the statement period).
- Works out money in and money out from the change in the running balance. When there is no balance column, it uses minus signs, brackets, `CR` and `DR` markers instead.
- **Verifies each statement.** A statement that does not reconcile is marked `failed_balance_check` with the difference in the message. Reconciling totals alone do not prove that every row was read (two missed rows can cancel out), so the Actor also checks every printed running balance (previous balance + amount must equal the printed balance) and counts lines with amounts that it could not read. If either shows a problem the statement is `incomplete_extraction`. A row is `verified: true` only when its own running balance proves it; rows of statements without a running-balance column are marked `verification: statement_totals_only`. Rows of statements that fail are never delivered or charged. Set `includeUnverifiedRows` to receive them in the `OUTPUT` record.
- **Checks continuity per account.** Overlapping periods, missing periods and balance breaks (where the previous closing balance differs from the next opening balance) are listed in `OUTPUT.accountSummaries`.
- **De-duplicates** rows that appear in overlapping statements using deterministic transaction IDs, so re-running a month never double-imports.
- Writes files per account to the run's key-value store: a ledger CSV every time, plus an OFX file, a Xero bank-statement CSV, a QuickBooks CSV and a JSON coverage report if you request them.
- Reports problems per document in `OUTPUT.statements` (`invalid_pdf`, `encrypted`, `download_failed`, `no_text_layer`, `unsupported_layout`, `failed_balance_check`, `incomplete_extraction`, `duplicate_only`). One bad file never stops the others. When no statement reconciles, the run ends as failed after saving `OUTPUT`.

Account numbers are only ever output as their last 4 digits. Statement text is never written to the log.

### How to use it

1. Open the Actor and click **Start**. The prefilled input contains a tiny sample statement PDF, so the first run works with one click and needs no network access.
2. Replace the sample with your statements. Add each PDF to `documents` as base64, or list https links in `documentUrls`.
3. Pick any extra export files and run. Then download the dataset (CSV, Excel or JSON) and the import files from the key-value store.

Example input:

```json
{
  "documents": [
    { "filename": "jan-2026.pdf", "contentBase64": "JVBERi0xLjQK..." },
    { "filename": "feb-2026.pdf", "contentBase64": "JVBERi0xLjQK...", "password": "only-if-encrypted" }
  ],
  "currency": "GBP",
  "dateOrder": "auto",
  "exports": ["ofx", "xero", "coverageReport"],
  "includeUnverifiedRows": false
}
```

To encode a PDF, use `base64 -w0 statement.pdf` (Linux), `base64 -i statement.pdf` (macOS) or `[Convert]::ToBase64String([IO.File]::ReadAllBytes("statement.pdf"))` (PowerShell). A `data:application/pdf;base64,` prefix and line breaks are accepted.

### Output

The dataset holds three record types, identified by `recordType`: `statement_report` (one per document), `transaction` (one per kept row) and `account_summary` (one per account). The same rows are also stored in the `OUTPUT` record, together with run totals.

| recordType | sourceFile | sourcePage | date | description | amount | balance | transactionId | verified |
|---|---|---|---|---|---|---|---|---|
| transaction | jan-2026.pdf | 1 | 2026-01-05 | SALARY ACME | 500 | 2500 | tx\_4821\_20260105\_50000\_0302\_0 | true |
| transaction | jan-2026.pdf | 1 | 2026-01-14 | TESCO STORES | -42.17 | 2457.83 | tx\_4821\_20260114\_-4217\_037e\_0 | true |

Here is the statement report from the same run:

```json
{
  "recordType": "statement_report",
  "sourceFile": "jan-2026.pdf",
  "status": "ok",
  "message": "Balance check passed",
  "accountLast4": "4821",
  "currency": "GBP",
  "periodStart": "2026-01-01",
  "periodEnd": "2026-01-31",
  "openingBalance": 2000,
  "closingBalance": 2457.83,
  "rowCount": 2,
  "scannedPagesSkipped": 0,
  "duplicatesRemoved": 0
}
```

Amounts are signed numbers (negative means money out), with separate `debit` and `credit` columns. Dates use ISO format (`YYYY-MM-DD`). Every transaction carries `sourceFile` and `sourcePage`. Each transaction ID combines the account's last 4 digits, the date, the amount in cents, a checksum of the normalised description and an occurrence counter, so the same input always gives the same IDs.

Files written to the key-value store for each account (`XXXX` is the last 4 digits):

| Key | Content |
|---|---|
| `ledger-XXXX.csv` | Always written: date, description, amount, debit, credit, balance, currency, account, transaction ID, source file and page |
| `ofx-XXXX.ofx` | OFX 1.02 bank statement; transaction IDs are used as FITID |
| `xero-XXXX.csv` | Xero bank statement import columns: `*Date` (DD/MM/YYYY), `*Amount`, Payee, Description, Reference, Check Number |
| `quickbooks-XXXX.csv` | QuickBooks 4-column format: Date (MM/DD/YYYY), Description, Credit, Debit |
| `coverage-XXXX.json` | Statements, periods, balances, gaps and overlaps for human review |

In CSV files, descriptions that start with `=`, `+`, `@` or `-` get an apostrophe in front to prevent spreadsheet formula injection.

### Pricing

Pay per event. The main charge is per transaction from a reconciled statement; everything else listed below is free.

| Event | Price (USD) | Charged when |
|---|---|---|
| Run start (`apify-actor-start`) | $0.005 | once per run; the default 512 MB memory is one event |
| Transaction (`apify-default-dataset-item`) | $0.0064 | per transaction delivered to the dataset |

Not charged:

- statements that fail the balance checks, and their rows
- duplicates removed from overlapping statements
- OFX, Xero, QuickBooks, ledger CSV and coverage export files
- per-statement reports and account summaries

Examples (default 512 MB memory, one start event):

- One month, 60 transactions: $0.005 start + 60 × $0.0064 = **$0.389**
- Twelve months for a new bookkeeping client, 900 transactions: $0.005 start + 900 × $0.0064 = **$5.765**
- A scanned statement: $0.005 start + 0 × $0.0064 = **$0.005**

Spending limit: when you set a maximum cost per run, the Actor stops before it would exceed it, keeps every transaction from a reconciled statement it already delivered and reports `limitReached` in the `OUTPUT` record. It never delivers results beyond the limit.

The Store's Pricing tab shows the prices in force. If this section and the Pricing tab ever differ, the Pricing tab applies.

### Use cases

- **Onboarding a bookkeeping client:** upload 12 months of statements and get one ledger per account plus a Xero or QuickBooks import file.
- **Monthly automation:** send the newest statement from email or Drive each month. Stable transaction IDs let your accounting import skip rows it already has.
- **Lender and broker file review:** check that 3 to 12 months of statements are complete and continuous, with gaps, overlaps and balance breaks listed for human review. The Actor makes no credit or lending decision.
- **Credit-card packs to OFX** for tools that only accept bank feeds.

### Limits

- Text-based PDFs only. **Scanned or image-only pages are not OCR'd.** They are counted in `scannedPagesSkipped`, and a fully scanned file is reported as `no_text_layer`.
- Layout parsing is generic and expects one transaction per line, starting with a date. Unusual layouts can end as `unsupported_layout` or `failed_balance_check`. The balance checks make most parsing errors show up as failures instead of wrong data, but a statement without running balances can only be checked on its totals.
- A statement can only be verified when its opening and closing balances are printed on it.
- Up to 60 documents per run (inline documents and URLs combined), 200 pages per document, 25 MB per file, 5000 rows per statement and 60 MB of total input.
- URL mode: https on port 443 only, and public hosts only. Private and local addresses are blocked, every redirect is re-checked (at most 3), and each download has a 30 second timeout and one retry.
- Currency is read from the statement (common ISO codes, or the £, € and $ symbols). If the statement has none, the `currency` input is used.
- The OFX file uses a placeholder bank ID and account type CHECKING. Check them in your accounting tool before relying on the file.
- De-duplication only merges rows with the same date, amount and description. If two statements print the same transaction differently, both rows are kept, but the overlap is still flagged in the account summary.

### FAQ

**Do you need my bank login?** No. Only the PDF files you supply are processed.

**Is my data stored?** Processing happens in memory, and results are written only to your own run storage. Set a short retention period for that storage, and make sure you have authority or consent to process statements that belong to clients.

**What if a statement fails the balance check?** It is reported with the difference in `OUTPUT.statements`, its rows are not delivered and you are not charged for them.

**Can I mix several accounts in one run?** Yes. Statements are grouped by the last 4 digits of the account number and the currency. Statements without a recognisable account number are never merged with each other; each gets its own ledger.

**Does it work for credit-card statements?** Yes, when the PDF has a text layer and prints opening and closing balances in a supported layout. Amounts follow the statement's own balance direction. On a card statement where the balance is the amount owed, purchases come out as positive amounts, so check the sign convention before importing.

**What does `maskAccountNumbers` do?** Account numbers are always reduced to their last 4 digits. The flag is kept for compatibility.

**Is this financial advice?** No. It is data extraction only, and the coverage report needs human review.

# Actor input Schema

## `documents` (type: `array`):

Inline statement PDFs. Each item: { filename, contentBase64, password? }. contentBase64 may carry a data:application/pdf;base64, prefix. Up to 60 documents per run (inline documents and URLs combined), 25 MB each.

## `documentUrls` (type: `array`):

Optional https URLs of statement PDFs (for example signed Drive, S3 or Dropbox links). Up to 60 documents per run (inline documents and URLs combined), 25 MB each, 30 s timeout. Private and local addresses are blocked and every redirect is re-checked.

## `currency` (type: `string`):

ISO 4217 code used when the statement does not state a currency, e.g. GBP.

## `dateOrder` (type: `string`):

Order of numeric dates. Auto detects it from the whole document (defaults to DMY when ambiguous). ISO dates (2026-01-05) are always recognised.

## `exports` (type: `array`):

JSON list with any of: ofx, xero, quickbooks, coverageReport. One file per account is stored in the key-value store (each is a billable export event). The ledger CSV is always produced.

## `includeUnverifiedRows` (type: `boolean`):

Also output rows from statements that failed the balance check, marked verified=false and never charged.

## `maskAccountNumbers` (type: `boolean`):

Account numbers are always reduced to their last 4 digits in every output. This flag is accepted for compatibility and defaults to true.

## Actor input object example

```json
{
  "documents": [
    {
      "filename": "jan-2026.pdf",
      "contentBase64": "JVBERi0xLjQKMSAwIG9iajw8L1R5cGUvQ2F0YWxvZy9QYWdlcyAyIDAgUj4+ZW5kb2JqCjIgMCBvYmo8PC9UeXBlL1BhZ2VzL0tpZHNbMyAwIFJdL0NvdW50IDE+PmVuZG9iagozIDAgb2JqPDwvVHlwZS9QYWdlL1BhcmVudCAyIDAgUi9Db250ZW50cyA0IDAgUi9SZXNvdXJjZXM8PC9Gb250PDwvRjEgNSAwIFI+Pj4+Pj5lbmRvYmoKNCAwIG9iajw8L0xlbmd0aCAyMTM+PnN0cmVhbQpCVC9GMSA5IFRmIDE0IFRMIDIwIDcwMCBUZChBY2NvdW50IDEyMzQ0ODIxKVRqKFBlcmlvZCAwMS8wMS8yMDI2IC0gMzEvMDEvMjAyNiknKE9wZW5pbmcgYmFsYW5jZSAyMDAwLjAwKScoMDUvMDEvMjAyNiBTQUxBUlkgQUNNRSA1MDAuMDAgMjUwMC4wMCknKDE0LzAxLzIwMjYgVEVTQ08gU1RPUkVTIDQyLjE3IDI0NTcuODMpJyhDbG9zaW5nIGJhbGFuY2UgMjQ1Ny44MyknRVQKZW5kc3RyZWFtIGVuZG9iago1IDAgb2JqPDwvVHlwZS9Gb250L1N1YnR5cGUvVHlwZTEvQmFzZUZvbnQvSGVsdmV0aWNhPj5lbmRvYmoKdHJhaWxlcjw8L1Jvb3QgMSAwIFIvU2l6ZSA2Pj4KJSVFT0YK"
    }
  ],
  "documentUrls": [],
  "currency": "GBP",
  "dateOrder": "auto",
  "exports": [
    "ofx",
    "xero"
  ],
  "includeUnverifiedRows": false,
  "maskAccountNumbers": true
}
```

# Actor output Schema

## `results` (type: `string`):

Every result row stored in the default dataset.

## `summary` (type: `string`):

Summary written to the OUTPUT record.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "documents": [
        {
            "filename": "jan-2026.pdf",
            "contentBase64": "JVBERi0xLjQKMSAwIG9iajw8L1R5cGUvQ2F0YWxvZy9QYWdlcyAyIDAgUj4+ZW5kb2JqCjIgMCBvYmo8PC9UeXBlL1BhZ2VzL0tpZHNbMyAwIFJdL0NvdW50IDE+PmVuZG9iagozIDAgb2JqPDwvVHlwZS9QYWdlL1BhcmVudCAyIDAgUi9Db250ZW50cyA0IDAgUi9SZXNvdXJjZXM8PC9Gb250PDwvRjEgNSAwIFI+Pj4+Pj5lbmRvYmoKNCAwIG9iajw8L0xlbmd0aCAyMTM+PnN0cmVhbQpCVC9GMSA5IFRmIDE0IFRMIDIwIDcwMCBUZChBY2NvdW50IDEyMzQ0ODIxKVRqKFBlcmlvZCAwMS8wMS8yMDI2IC0gMzEvMDEvMjAyNiknKE9wZW5pbmcgYmFsYW5jZSAyMDAwLjAwKScoMDUvMDEvMjAyNiBTQUxBUlkgQUNNRSA1MDAuMDAgMjUwMC4wMCknKDE0LzAxLzIwMjYgVEVTQ08gU1RPUkVTIDQyLjE3IDI0NTcuODMpJyhDbG9zaW5nIGJhbGFuY2UgMjQ1Ny44MyknRVQKZW5kc3RyZWFtIGVuZG9iago1IDAgb2JqPDwvVHlwZS9Gb250L1N1YnR5cGUvVHlwZTEvQmFzZUZvbnQvSGVsdmV0aWNhPj5lbmRvYmoKdHJhaWxlcjw8L1Jvb3QgMSAwIFIvU2l6ZSA2Pj4KJSVFT0YK"
        }
    ],
    "currency": "GBP",
    "dateOrder": "auto",
    "exports": [
        "ofx",
        "xero"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("first_watch/pdf-bank-statement-to-csv-transactions").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "documents": [{
            "filename": "jan-2026.pdf",
            "contentBase64": "JVBERi0xLjQKMSAwIG9iajw8L1R5cGUvQ2F0YWxvZy9QYWdlcyAyIDAgUj4+ZW5kb2JqCjIgMCBvYmo8PC9UeXBlL1BhZ2VzL0tpZHNbMyAwIFJdL0NvdW50IDE+PmVuZG9iagozIDAgb2JqPDwvVHlwZS9QYWdlL1BhcmVudCAyIDAgUi9Db250ZW50cyA0IDAgUi9SZXNvdXJjZXM8PC9Gb250PDwvRjEgNSAwIFI+Pj4+Pj5lbmRvYmoKNCAwIG9iajw8L0xlbmd0aCAyMTM+PnN0cmVhbQpCVC9GMSA5IFRmIDE0IFRMIDIwIDcwMCBUZChBY2NvdW50IDEyMzQ0ODIxKVRqKFBlcmlvZCAwMS8wMS8yMDI2IC0gMzEvMDEvMjAyNiknKE9wZW5pbmcgYmFsYW5jZSAyMDAwLjAwKScoMDUvMDEvMjAyNiBTQUxBUlkgQUNNRSA1MDAuMDAgMjUwMC4wMCknKDE0LzAxLzIwMjYgVEVTQ08gU1RPUkVTIDQyLjE3IDI0NTcuODMpJyhDbG9zaW5nIGJhbGFuY2UgMjQ1Ny44MyknRVQKZW5kc3RyZWFtIGVuZG9iago1IDAgb2JqPDwvVHlwZS9Gb250L1N1YnR5cGUvVHlwZTEvQmFzZUZvbnQvSGVsdmV0aWNhPj5lbmRvYmoKdHJhaWxlcjw8L1Jvb3QgMSAwIFIvU2l6ZSA2Pj4KJSVFT0YK",
        }],
    "currency": "GBP",
    "dateOrder": "auto",
    "exports": [
        "ofx",
        "xero",
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("first_watch/pdf-bank-statement-to-csv-transactions").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "documents": [
    {
      "filename": "jan-2026.pdf",
      "contentBase64": "JVBERi0xLjQKMSAwIG9iajw8L1R5cGUvQ2F0YWxvZy9QYWdlcyAyIDAgUj4+ZW5kb2JqCjIgMCBvYmo8PC9UeXBlL1BhZ2VzL0tpZHNbMyAwIFJdL0NvdW50IDE+PmVuZG9iagozIDAgb2JqPDwvVHlwZS9QYWdlL1BhcmVudCAyIDAgUi9Db250ZW50cyA0IDAgUi9SZXNvdXJjZXM8PC9Gb250PDwvRjEgNSAwIFI+Pj4+Pj5lbmRvYmoKNCAwIG9iajw8L0xlbmd0aCAyMTM+PnN0cmVhbQpCVC9GMSA5IFRmIDE0IFRMIDIwIDcwMCBUZChBY2NvdW50IDEyMzQ0ODIxKVRqKFBlcmlvZCAwMS8wMS8yMDI2IC0gMzEvMDEvMjAyNiknKE9wZW5pbmcgYmFsYW5jZSAyMDAwLjAwKScoMDUvMDEvMjAyNiBTQUxBUlkgQUNNRSA1MDAuMDAgMjUwMC4wMCknKDE0LzAxLzIwMjYgVEVTQ08gU1RPUkVTIDQyLjE3IDI0NTcuODMpJyhDbG9zaW5nIGJhbGFuY2UgMjQ1Ny44MyknRVQKZW5kc3RyZWFtIGVuZG9iago1IDAgb2JqPDwvVHlwZS9Gb250L1N1YnR5cGUvVHlwZTEvQmFzZUZvbnQvSGVsdmV0aWNhPj5lbmRvYmoKdHJhaWxlcjw8L1Jvb3QgMSAwIFIvU2l6ZSA2Pj4KJSVFT0YK"
    }
  ],
  "currency": "GBP",
  "dateOrder": "auto",
  "exports": [
    "ofx",
    "xero"
  ]
}' |
apify call first_watch/pdf-bank-statement-to-csv-transactions --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,first_watch/pdf-bank-statement-to-csv-transactions"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/7CGb3VmgN0tpK8xXJ/builds/DwecpoWuxdqWkmw9u/openapi.json
