A lightweight Python package to flatten complex ISO 20022 XML messages into usable data.
Project description
OpenPurse
The Ultra-Lightweight ISO 20022 & SWIFT MT Engine for Modern Finance
⚡️ Why OpenPurse?
Financial messaging is messy. Deeply nested XML (ISO 20022) and archaic block-based formats (SWIFT MT) shouldn't slow down your engineering team. OpenPurse flattens the complexity into clean, structured Python objects.
- 🚀 Performance-First: Built on
lxmlfor lightning-fast parsing. - 🛡️ Production-Hardened: Handles malformed inputs, Unicode, and huge amounts gracefully.
- 🔌 Context-Aware: Automatically identifies schema versions (770+ ISO namespaces supported).
- 📦 Zero Bloat: No
pandas, nopydantic. Just pure, native Python@dataclasses.
🛠️ Features at a Glance
| Feature | Description |
|---|---|
| Unified Parser | One API for both ISO 20022 XML and SWIFT MT103/MT202/MT940. |
| Auto-Reconciler | Link initiations, status reports, and notifications into a single lifecycle. |
| PII Anonymizer | Scrub sensitive data while keeping messages valid (checksum-aware). |
| Smart Validator | Offline IBAN Modulo-97 and BIC validation. |
| Translator | Bidirectional conversion between MX and MT formats. |
| Exporter | Generate OpenAPI 3.0 specs directly from your financial models. |
🏗️ Architecture
graph TD
A[Raw Message] --> B{OpenPurseParser}
B -- XML --> C[ISO 20022 Engine]
B -- Block --> D[SWIFT MT Engine]
C --> E[PaymentMessage @dataclass]
D --> E
E --> F[Validator]
E --> G[Reconciler]
E --> H[Translator]
E --> I[Anonymizer]
🚀 Quick Start
1. Installation
pip install openpurse
2. Basic Parsing
import openpurse
# Works for both XML and legacy SWIFT MT!
data = b"{1:F01BANKUS33XXX...}{4::20:MSG001...}"
parser = openpurse.OpenPurseParser(data)
# Get a structured, typed object
msg = parser.parse()
print(f"💰 {msg.currency} {msg.amount} from {msg.debtor_name}")
3. Smart Anonymization (Safe for Testing)
from openpurse.anonymizer import Anonymizer
# Scrub PII but keep the IBAN checksums VALID
safe_data = Anonymizer().anonymize_xml(raw_xml_bytes)
🛡️ Reconciliation Engine
Link a pain.001 initiation to a camt.054 notification with zero sweat.
from openpurse.reconciler import Reconciler
# Build a chronological timeline of a payment's life
timeline = Reconciler.trace_lifecycle(my_seed_msg, all_parsed_messages)
for step in timeline:
print(f"[{step.__class__.__name__}] {step.message_id}")
📊 Exporting Models
Need to build a REST API? Export OpenPurse models to OpenAPI in seconds.
./scripts/export_schema.py --output openapi.json
🧪 Testing and Quality
OpenPurse is verified against 777+ ISO schemas and real-world edge cases.
pytest tests/
Built with ❤️ for modern financial engineering.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openpurse-0.1.4.tar.gz.
File metadata
- Download URL: openpurse-0.1.4.tar.gz
- Upload date:
- Size: 3.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51d8635aaa9ba8c408fcdbae5f3e25a43592738da28ebf709fa9b3d93aa0ef3c
|
|
| MD5 |
7c71fc9e169e3f16e713a73d9fb1b46f
|
|
| BLAKE2b-256 |
9a65e40b01b307a3857b2d3e9cec7e8e14bdd89b53dbb35f2ab62bc17bd5000c
|
File details
Details for the file openpurse-0.1.4-py3-none-any.whl.
File metadata
- Download URL: openpurse-0.1.4-py3-none-any.whl
- Upload date:
- Size: 22.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6b4936911c05112692d36e0e4c6e91673f495701488dc4af2cc1195abd84f6a
|
|
| MD5 |
f8f08c747d342a7eb56e5af680d2ccd3
|
|
| BLAKE2b-256 |
f6b568161fac5d47362498bac0ce4028075bd0f0658fcd793caeabdb353cd380
|