Skip to main content

A lightweight Python package to flatten complex ISO 20022 XML messages into usable data.

Project description

OpenPurse Logo

OpenPurse

The Ultra-Lightweight ISO 20022 & SWIFT MT Engine for Modern Finance

PyPI version License Python Versions


⚡️ 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 lxml for 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, no pydantic. Just pure, native Python @dataclasses.

🛠️ Features at a Glance

Feature Description
Unified Parser One API for both ISO 20022 XML and SWIFT MT101/103/202/940/942/950.
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}")

🚦 Smart Validation Engine

Ensure your BICs and IBANs are strictly compliant before sending them down the wire.

from openpurse.validator import Validator

report = Validator.validate(msg)
if not report.is_valid:
    print(f"Validation Failed: {report.errors}")

📊 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openpurse-0.1.9.tar.gz (3.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openpurse-0.1.9-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

File details

Details for the file openpurse-0.1.9.tar.gz.

File metadata

  • Download URL: openpurse-0.1.9.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

Hashes for openpurse-0.1.9.tar.gz
Algorithm Hash digest
SHA256 7ddec54250e445382c7b7b1f46d70c5ca0df194a71d70864be3034a6bfc90c78
MD5 9503a9144c21efc251c62339df482d8e
BLAKE2b-256 3d627b09b7bac20284ca36380a4f51a17f11de49471777213d2869ad57e80044

See more details on using hashes here.

File details

Details for the file openpurse-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: openpurse-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 26.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for openpurse-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 ca8a4731c2cf20e5ee3a3b4efb92fee3f0c7cc742a0df9e3006f487e6fdd3013
MD5 6af33d569f2a59145085a2ed93b93282
BLAKE2b-256 24f1e2fc889e09ea2543c4d833bcf0769fe6628e697ef79945cd5c0a10185950

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page