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

Uploaded Python 3

File details

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

File metadata

  • Download URL: openpurse-0.1.5.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.5.tar.gz
Algorithm Hash digest
SHA256 e829000af58314521cbd6e1fd78beaaa3674415f627c8c9d8b5f2cb2f2e80139
MD5 983fe77087e7ec08ef8f38567e739f60
BLAKE2b-256 a013fb2a77e3c00b966b91e379abe5728fb7de946c2aeb5cee1ad797eb611ccc

See more details on using hashes here.

File details

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

File metadata

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

Hashes for openpurse-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 b093aa2ac782b57c31862ba6091e78c6af8b8d3d0916f5669d752215e805afd7
MD5 df5f48a2d24e20d26d1351d041baee64
BLAKE2b-256 fc2784d156a1cc5df917efe978b84c4f756062f4698b92b0eb57db5282809110

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