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 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


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.7.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.7-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: openpurse-0.1.7.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.7.tar.gz
Algorithm Hash digest
SHA256 f1f724c3bf14e4a7b33f2d2497f0731fe4ecc36b82c6ad110d869912173c5ac3
MD5 ff1a91d07e3fb7d7e94e8083df1004a4
BLAKE2b-256 1fa358e96dd2dd069d47e17a42cec16c37d9dd7200c3fd7a5134b9809ed18f0a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: openpurse-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 24.6 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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 faf534736f4cc9fdf5919130932ea0567dae2e89da8187d8afcddab9a3a6f9fa
MD5 d3fb4a9c90ded8e2d58bad42c9745b09
BLAKE2b-256 55814a314e92a1d2f009418ccbe144333f07972e6dec9fa8f720544c3939767f

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