bankstatementparser-loader-sepa
ISO 20022 SEPA loader that parses PAIN.002 payment status reports and PAIN.008 Direct Debit collections into bankstatementparser Transaction objects.
Contents
Getting started
- Install: PyPI, source
- Requirements: toolchain floor, platforms
- Quick Start: parse a message in three lines
The bankstatementparser-loader-sepa ecosystem
- The bankstatementparser-loader-sepa ecosystem: the core library, the other loaders and writers
Library reference
- Capabilities at a glance: the current surface by theme
- Ecosystem comparison: short matrix; full table at
docs/COMPARISON.md - Benchmarks: headline numbers; full table at
docs/BENCHMARKS.md - Features: public API, element mapping, amounts and signs
- Configuration: core options
- Examples: runnable example index
Operational
- When not to use bankstatementparser-loader-sepa: limitations
- Development: make targets, fuzzing, CI
- Security: guarantees and compliance
- Documentation: all reference docs
- Stability guarantees: SemVer axis, output stability, minimum toolchain discipline
- License
Install
As a Python library
pip install bankstatementparser-loader-sepa
That installs the loader, defusedxml, and bankstatementparser >= 0.0.35, which brings pandas and pydantic.
| Channel | Command | Notes |
|---|---|---|
| PyPI | pip install bankstatementparser-loader-sepa |
Pulls in bankstatementparser >= 0.0.35 |
| Source | git clone https://github.com/sebastienrousseau/bankstatementparser-loader-sepa && cd bankstatementparser-loader-sepa && poetry install |
For development |
Verify the installation:
python -c "import bankstatementparser_loader_sepa as s; print(s.__version__)"
# -> 0.0.36
An isolated virtual environment keeps the loader's dependencies apart:
python -m venv venv
source venv/bin/activate # macOS/Linux
venv\Scripts\activate # Windows
python -m pip install -U bankstatementparser-loader-sepa
Requirements
- Python 3.10 or later. CI tests CPython 3.10, 3.11, 3.12, 3.13 and 3.14 on Linux, macOS and Windows;
docs/POLICIES.mdsays when the floor moves. bankstatementparser0.0.35 or later, whoseTransactionmodel andBankStatementParserbase class the loader produces and extends, anddefusedxml0.7, which parses the XML.- No network access, native extensions or system packages of its own.
Quick Start
from bankstatementparser_loader_sepa import load_sepa_file
for txn in load_sepa_file("pain002.xml"):
print(txn.amount, txn.currency, txn.reference, txn.description)
Or parse an in-memory payload:
from bankstatementparser_loader_sepa import load_sepa
report = """<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.002.001.03">
<CstmrPmtStsRpt>
<GrpHdr><MsgId>STS-2026-0121</MsgId></GrpHdr>
<OrgnlPmtInfAndSts>
<TxInfAndSts>
<OrgnlEndToEndId>E2E-INV-1001</OrgnlEndToEndId>
<TxSts>ACSC</TxSts>
<OrgnlTxRef><Amt><InstdAmt Ccy="EUR">64.90</InstdAmt></Amt></OrgnlTxRef>
</TxInfAndSts>
<TxInfAndSts>
<OrgnlEndToEndId>E2E-INV-1002</OrgnlEndToEndId>
<TxSts>RJCT</TxSts>
<StsRsnInf><Rsn><Cd>AM04</Cd></Rsn></StsRsnInf>
<OrgnlTxRef><Amt><InstdAmt Ccy="EUR">25.00</InstdAmt></Amt></OrgnlTxRef>
</TxInfAndSts>
</OrgnlPmtInfAndSts>
</CstmrPmtStsRpt>
</Document>"""
for txn in load_sepa(report):
print(txn.amount, txn.category, txn.reference, txn.description)
# 64.90 pain002:ACSC E2E-INV-1001 SEPA Status: ACSC
# -25.00 pain002:RJCT E2E-INV-1002 SEPA Status: RJCT (AM04)
Both return a flat list of bankstatementparser.transaction_models.Transaction objects with source="sepa", ready for the rest of a bankstatementparser pipeline.
The bankstatementparser-loader-sepa ecosystem
bankstatementparser-loader-sepa is one of the input loaders of the bankstatementparser suite, whose packages ship one version together. The full table is in The suite.
| Component | Purpose | Use case |
|---|---|---|
bankstatementparser |
The parser core: CAMT, pain.001, CSV, OFX, QFX, MT940, MT942, BAI2 and PDF statements, and the Transaction model |
Parsing statements from Python or the CLI |
bankstatementparser-loader-sepa |
This loader: PAIN.002 and PAIN.008 XML to Transaction objects, with rejections signed negative and the status kept |
Reconciling SEPA Direct Debit collections and their status reports |
| Other loaders | BAI2, MT942, CFONB 120, CAMT.054 and BACS Standard 18 | Formats beyond the core |
| Writers and transport | XLSX, QIF, OFX and SWIFT writers; EBICS retrieval | Exporting transactions and fetching statements |
bankstatementparser-mcp, bankstatementparser-lsp |
Agent tools and editor diagnostics over the core | AI agents and MT940 editing |
flowchart LR
A["PAIN.002 / PAIN.008 XML"] -->|load_sepa / load_sepa_file| B["bankstatementparser-loader-sepa"]
B -->|list of Transaction, source=sepa| C["bankstatementparser pipeline"]
A -->|summarize_sepa| D["SepaMessageSummary"]
Capabilities at a glance
| Area | Capability | Status |
|---|---|---|
| Loading | load_sepa (str or bytes) and load_sepa_file (path) to list[Transaction] |
Shipped |
| Summary | summarize_sepa to a SepaMessageSummary (type, message id, creation time, account, currency, count, total) |
Shipped |
| Core integration | SepaStatementParser, a BankStatementParser registered as sepa, pain002 and pain008 in bankstatementparser.loaders |
Shipped |
| Messages | PAIN.002 TxInfAndSts statuses and PAIN.008 DrctDbtTxInf collections, any pain.00x.001.xx namespace |
Shipped |
| XML safety | defusedxml refuses entity declarations, internal or external |
Shipped |
| Group status | GrpSts and OrgnlGrpInfAndSts |
Not read |
| Other messages | PAIN.001, PAIN.009 to PAIN.012 mandates, camt | Not in this loader |
Ecosystem comparison
Two other Python packages on PyPI handle SEPA PAIN messages; neither reads PAIN.002. Every cell comes from the projects' own source code, read on 2026-11-27.
| Project | Reads PAIN.002 | Reads PAIN.008 | Output |
|---|---|---|---|
| bankstatementparser-loader-sepa | Yes | Yes, any version | Signed Transaction objects |
sepa 0.5.4 |
No | pain.008.001.07 |
Nested dicts of element text |
sepaxml 2.7.0 |
No | No (writes it) | XML |
See docs/COMPARISON.md for the evidence and complete matrix.
Benchmarks
benches/bench_load_sepa.py times load_sepa and summarize_sepa on PAIN.008 collections and PAIN.002 reports of 10 to 50,000 transactions. From 10 to 50,000 transactions the cost per transaction rises 1.16x for PAIN.008 and 1.68x for PAIN.002; parsing the XML dominates, so a summary costs nearly as much as a load.
| Scenario | Result | Environment |
|---|---|---|
load_sepa, PAIN.008, 1,000 transactions (327 KiB) |
17.37 ms | Apple M1 Pro, macOS 27.2.1, CPython 3.12.16 |
load_sepa, PAIN.008, 50,000 transactions (16.4 MiB) |
1,148.20 ms | Apple M1 Pro, macOS 27.2.1, CPython 3.12.16 |
load_sepa, PAIN.002, 50,000 transactions (8.9 MiB) |
1,297.52 ms | Apple M1 Pro, macOS 27.2.1, CPython 3.12.16 |
See docs/BENCHMARKS.md for methodology and full results.
Features
Public API
from bankstatementparser_loader_sepa import (
SepaMessageSummary,
SepaStatementParser,
load_sepa,
load_sepa_file,
summarize_sepa,
)
| Class / Function | Signature | Returns |
|---|---|---|
load_sepa |
load_sepa(xml_content): a str or bytes |
list[Transaction] |
load_sepa_file |
load_sepa_file(path): a str or os.PathLike |
list[Transaction] |
summarize_sepa |
summarize_sepa(xml_content): a str or bytes |
SepaMessageSummary |
SepaStatementParser |
SepaStatementParser(file_name) |
BankStatementParser with parse() (DataFrame), to_transactions() and get_summary() (dict) |
SepaMessageSummary is a frozen dataclass with the fields message_type (PAIN.002, PAIN.008, or the root element's name when neither is found), message_id (MsgId), creation_date (CreDtTm), account_id and currency (the first transaction's, EUR when there is none), item_count and total_amount (the sum of absolute amounts).
Message detection
Elements are matched by local name, so the namespace and the message version do not matter. The first CstmrPmtStsRpt or CstmrDrctDbtInitn element decides the type. Without either, the loader falls back to PAIN.002 or PAIN.008 only when a TxInfAndSts or PmtInf element carries text of its own (not only child elements); otherwise the message gives no transactions and message_type is the root element's name.
PAIN.008: one transaction per DrctDbtTxInf
Transaction field |
Source |
|---|---|
account_id |
The PmtInf block's CdtrAcct (IBAN, else Id), else the transaction's first IBAN or Id, else SEPA_DD |
currency |
The InstdAmt Ccy attribute, else EUR |
amount |
InstdAmt, positive |
booking_date, value_date |
The block's ReqdColltnDt |
description |
SEPA Direct Debit - <first Nm>, followed by the Ustrd (else Strd) remittance text in parentheses when there is one |
reference |
EndToEndId, else MndtId |
category |
pain008:direct_debit |
PAIN.002: one transaction per TxInfAndSts
Transaction field |
Source |
|---|---|
account_id |
The status's first IBAN, else Id, else none |
currency |
The amount's Ccy attribute, else EUR |
amount |
The first OrgnlTxAmt, InstdAmt or Amt, negative when TxSts is RJCT |
booking_date, value_date |
AccptncDtTm, when present |
description |
SEPA Status: <TxSts>, followed by the first Cd (else AddtlInf) in parentheses when there is one |
reference |
OrgnlEndToEndId, else OrgnlTxId, else StsId, else the message's MsgId |
category |
pain002:<TxSts> |
A status with no TxSts is read as RJCT.
Amounts
An amount is ISO 20022's plain decimal: ASCII digits with an optional fraction, converted to decimal.Decimal, never float. Anything else (an empty element, a sign, an exponent, NaN, Infinity, other scripts' digits) reads as 0.00, as does a transaction with no amount element.
Errors
load_sepa, load_sepa_file and summarize_sepa raise xml.etree.ElementTree.ParseError when the payload is not well-formed XML or declares an encoding the parser cannot use, and a defusedxml.DefusedXmlException (a ValueError) when it declares an entity, internal or external. Missing or unreadable elements never raise: they take the defaults above. load_sepa_file also raises OSError when the file cannot be read.
Configuration
The loader has no options, configuration file or environment variables: the element mapping and the sign convention above are fixed, so the same message always loads the same way. Installing the package registers SepaStatementParser under the sepa, pain002 and pain008 names in the bankstatementparser.loaders entry-point group, which is how the core discovers it; nothing needs to be configured for that.
Examples
examples/ holds two runnable scripts, each run in CI against an inline sample, so no data files are needed:
| Example | Demonstrates |
|---|---|
01_basic_usage.py |
load_sepa and summarize_sepa on a PAIN.008 collection and the PAIN.002 report that settles one debit and rejects the other |
02_advanced_workflow.py |
SepaStatementParser reading a status report from disk as a DataFrame and a summary, then listing the rejections |
python examples/01_basic_usage.py
When not to use bankstatementparser-loader-sepa
- You need account statements. Booked transactions come in camt.053 (the core) or camt.054 (
bankstatementparser-loader-camt054); PAIN.002 and PAIN.008 are instructions and statuses, not bookings. - You need the group status.
GrpStsand the original group details are not read; only transaction-level statuses become transactions. - You need to write PAIN messages. This loader only reads.
- You need schema validation. Elements are found by name wherever they sit; a message that is valid XML but not valid against the XSD still loads.
Development
git clone https://github.com/sebastienrousseau/bankstatementparser-loader-sepa.git
cd bankstatementparser-loader-sepa
poetry install
make check
make check runs the local gates: ruff lint and format, mypy --strict, the complexity baseline (scripts/check_complexity.py), bandit, pytest with a 100% line + branch coverage floor, interrogate at 100% docstring coverage, and the examples. Other targets: make fuzz (Atheris, 60 s, Linux x86_64 with Python 3.12+), make bench, make audit (pip-audit on every locked set), make docs (the MkDocs manual, --strict) and make demo (re-renders the GIF above with VHS from .github/demo.tape). CI adds the OS by Python matrix, the fuzz run, CodeQL, pip-audit and the Docs Lint gates. CONTRIBUTING.md covers branches and commit signing.
Security
- Read-only. The loader only reads text and files you pass it; it writes nothing.
- Hardened XML. Parsing goes through
defusedxml, which refuses entity declarations, internal or external, so a message cannot pull in files or expand into gigabytes; an external DTD is never fetched. - No network, no code execution. Parsing is element lookups into dataclasses.
- Decimal arithmetic for every amount, and only ISO 20022 decimals count as amounts.
- Fuzzing.
fuzz/fuzz_load_sepa.pydrivesload_sepaandsummarize_sepawith Atheris in CI, seeded with the repository's fixtures, and fails on any exception but the two documented refusals, on any malformedTransactionand on any disagreement between the load and the summary. - Supply chain. Dependencies are locked in
poetry.lock, CI installs hash-pinned exports of it, andpip-auditand CodeQL run on every change. Releases publish to PyPI through OIDC trusted publishing and carry cosign signatures, SLSA provenance and SBOMs; every workflow action is pinned by commit SHA except the SLSA generator, which must be referenced by tag.
Report vulnerabilities according to SECURITY.md.
Documentation
- User manual: sebastienrousseau.com/bankstatementparser-loader-sepa, built from
docs/with MkDocs - API reference: the manual's API page, generated from the docstrings
- Developer docs:
CONTRIBUTING.md,ARCHITECTURE.md - The suite:
docs/suite.md, with everybankstatementparserpackage - History:
CHANGELOG.md - Project site: bankstatementparser.com
Stability guarantees
- Versioning. Releases stay on the
0.0.xline and step by exactly0.0.1, in lockstep with the rest of thebankstatementparsersuite. Under SemVer a0.0.xrelease may break anything; this project names each break in the CHANGELOG instead. - The breaking axis is the output: which elements produce a
Transaction, the sign of each amount, and how eachTransactionfield is filled. Changing any of them for a message that loaded before is a breaking change and is called out in the CHANGELOG, even when no Python signature moves. - Output stability. The loader is deterministic: the same payload gives the same transactions in document order.
- Python API.
load_sepa,load_sepa_file,summarize_sepa,SepaMessageSummaryandSepaStatementParserkeep their names and fields; names starting with_are internal. - Minimum toolchain. Python 3.10 is the floor; it moves only in a release, for the whole suite at once, with the reason in the CHANGELOG (
docs/POLICIES.md).
License
Dual-licensed under Apache License, Version 2.0 or MIT, at your option (SPDX-License-Identifier: Apache-2.0 OR MIT). Built on the core bankstatementparser library. Any contribution submitted for inclusion in the work shall be dual-licensed as above, without additional terms or conditions.
Metadata
Release files for bankstatementparser-loader-sepa 0.0.36
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bankstatementparser_loader_sepa-0.0.36.tar.gz | 23.7 kB | With provenance | Details for bankstatementparser_loader_sepa-0.0.36.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bankstatementparser_loader_sepa-0.0.36-py3-none-any.whl | Python 3 | none | any | Details for bankstatementparser_loader_sepa-0.0.36-py3-none-any.whl |
Total release size: 42.9 kB
Release files / bankstatementparser_loader_sepa-0.0.36.tar.gz
| Download URL | bankstatementparser_loader_sepa-0.0.36.tar.gz |
|---|---|
| Size | 23.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
736d45760adf0b6dd410f8af2139f4217bd39da88fe7eff7c34ffb42d1260a50
|
|
BLAKE2b-256 checksum How to use checksums |
7f335ccb7d6ed990befbd6893599556ec9969ff91686bdc1fd3f6defcfc0e22a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logRelease files / bankstatementparser_loader_sepa-0.0.36-py3-none-any.whl
| Download URL | bankstatementparser_loader_sepa-0.0.36-py3-none-any.whl |
|---|---|
| Size | 19.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
64d0df9de0b918381e8f6c0d64c3f8042cf350ebc483611a70cb6c582d36c999
|
|
BLAKE2b-256 checksum How to use checksums |
4ed670bbcf2dded8db4503af4084d30d606f9fb97aec06c667e704ac094c3d60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logSecurity for bankstatementparser-loader-sepa 0.0.36
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for bankstatementparser_loader_sepa-0.0.36.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.