Tsallake zuwa abun ciki

Bayyanar API na pacs008 Bayyanar API na pacs008

Aikin yana ba da REST API da CLI don ayyukan sarrafa saƙonnin biyan kuɗi.

Installation Installation

Install the package from PyPI. Requires Python 3.9.2 or later.

bash
python -m pip install pacs008

REST API REST API

Start the FastAPI server to validate payment data and generate XML.

Start the server Start the server

bash
uvicorn pacs008.api.app:app --reload --host 0.0.0.0 --port 8000

Endpoints Endpoints

EndpointDescription
GET /healthHealth check that returns service status
POST /validateValidate payment data without generating XML
POST /generateGenerate XML now and return the file
POST /generate/asyncSubmit an async generation job
GET /status/{job_id}Check job status by ID
GET /download/{job_id}Download XML after the job completes
DELETE /jobs/{job_id}Cancel a pending or running job
GET /docsSwagger UI for testing all endpoints

Validation example Validation example

Validate payment data before generating XML.

bash
curl -X POST http://localhost:8000/api/validate \
  -H "Content-Type: application/json" \
  -d '{
    "message_type": "pacs.008.001.13",
    "data": [{
      "msg_id": "MSG-2026-001",
      "creation_date_time": "2026-01-15T10:30:00",
      "nb_of_txs": "1",
      "settlement_method": "CLRG",
      "interbank_settlement_date": "2026-01-15",
      "end_to_end_id": "E2E-INV-2026-001",
      "interbank_settlement_amount": "25000.00",
      "interbank_settlement_currency": "EUR",
      "charge_bearer": "SHAR",
      "debtor_name": "Acme Corp GmbH",
      "debtor_agent_bic": "DEUTDEFF",
      "creditor_agent_bic": "COBADEFF",
      "creditor_name": "Widget Industries SA"
    }]
  }'
json
{
  "valid": true,
  "message_type": "pacs.008.001.13",
  "errors": [],
  "warnings": []
}

Synchronous generation example Synchronous generation example

Generate a pacs.008.001.13 XML file from JSON data.

bash
curl -X POST http://localhost:8000/api/generate \
  -H "Content-Type: application/json" \
  -d '{
    "message_type": "pacs.008.001.13",
    "template": "pacs008/templates/pacs.008.001.13/template.xml",
    "schema": "pacs008/templates/pacs.008.001.13/pacs.008.001.13.xsd",
    "data": [{
      "msg_id": "MSG-2026-001",
      "creation_date_time": "2026-01-15T10:30:00",
      "nb_of_txs": "1",
      "settlement_method": "CLRG",
      "interbank_settlement_date": "2026-01-15",
      "end_to_end_id": "E2E-INV-2026-001",
      "tx_id": "TX-001",
      "interbank_settlement_amount": "25000.00",
      "interbank_settlement_currency": "EUR",
      "charge_bearer": "SHAR",
      "debtor_name": "Acme Corp GmbH",
      "debtor_agent_bic": "DEUTDEFF",
      "creditor_agent_bic": "COBADEFF",
      "creditor_name": "Widget Industries SA"
    }]
  }' --output pacs008_output.xml

Asynchronous generation Asynchronous generation

For large files, submit an async job and poll until it finishes.

bash
# Submit the job
JOB=$(curl -s -X POST http://localhost:8000/api/generate/async \
  -H "Content-Type: application/json" \
  -d '{"message_type":"pacs.008.001.13","data":[...]}')

JOB_ID=$(echo $JOB | jq -r '.job_id')

# Poll for completion
curl http://localhost:8000/api/status/$JOB_ID

# Download the result
curl http://localhost:8000/api/download/$JOB_ID --output result.xml
json
{
  "job_id": "8f7f0d4b-7df9-4d1a-8d47-19f4f28b6d38",
  "status": "completed",
  "message_type": "pacs.008.001.13",
  "download_url": "/api/download/8f7f0d4b-7df9-4d1a-8d47-19f4f28b6d38"
}

CLI CLI

The CLI takes a data file, message version, template, and schema. It validates the input and writes XML to the output directory.

Basic usage Basic usage

bash
pacs008 -t <message_type> \
  -m <template_file> \
  -s <schema_file> \
  -d <data_file>

Example Example

bash
pacs008 -t pacs.008.001.13 \
  -m pacs008/templates/pacs.008.001.13/template.xml \
  -s pacs008/templates/pacs.008.001.13/pacs.008.001.13.xsd \
  -d payments.csv

Dry-run mode Dry-run mode

Use --dry-run to validate input data without generating XML. The exit code shows whether validation passed (0) or failed (1).

bash
pacs008 -t pacs.008.001.13 \
  -m pacs008/templates/pacs.008.001.13/template.xml \
  -s pacs008/templates/pacs.008.001.13/pacs.008.001.13.xsd \
  -d payments.csv \
  --dry-run

Add --verbose for detailed output during generation.


Python API Python API

Use the library directly in Python scripts or services.

Generate XML from payment records Generate XML from payment records

python
from pacs008 import generate_xml_string

payments = [{
    "msg_id": "MSG-2026-001",
    "creation_date_time": "2026-01-15T10:30:00",
    "nb_of_txs": "1",
    "settlement_method": "CLRG",
    "interbank_settlement_date": "2026-01-15",
    "end_to_end_id": "E2E-INV-2026-001",
    "tx_id": "TX-001",
    "interbank_settlement_amount": "25000.00",
    "interbank_settlement_currency": "EUR",
    "charge_bearer": "SHAR",
    "debtor_name": "Acme Corp GmbH",
    "debtor_agent_bic": "DEUTDEFF",
    "creditor_agent_bic": "COBADEFF",
    "creditor_name": "Widget Industries SA",
}]

xml = generate_xml_string(
    payments,
    "pacs.008.001.13",
    "pacs008/templates/pacs.008.001.13/template.xml",
    "pacs008/templates/pacs.008.001.13/pacs.008.001.13.xsd",
)
print(xml)

SWIFT compliance check SWIFT compliance check

Check and clean data against SWIFT character and field-length rules before generation.

python
from pacs008.compliance import cleanse_data_with_report

raw = [{"debtor_name": "Müller & Söhne™", "msg_id": "X" * 50}]
clean, report = cleanse_data_with_report(raw)
print(report.summary())

Docker Docker

Run the API in a container using the bundled Dockerfile.

bash
docker build -t pacs008:latest .
docker run -p 8000:8000 pacs008:latest
bash
docker run --rm   -e PACS008_LOG_LEVEL=INFO   -v $PWD/examples:/data   -p 8000:8000 pacs008:latest

IBAN and BIC validation IBAN and BIC validation

Validate financial identifiers independently of XML generation.

python
from pacs008.validation import validate_iban, validate_bic

is_valid, error = validate_iban("DE89370400440532013000", strict=False)
is_valid, error = validate_bic("DEUTDEFF", strict=False)

Streaming Streaming

Load large datasets in configurable chunks to limit memory usage.

python
from pacs008.data.loader import load_payment_data_streaming

for chunk in load_payment_data_streaming("large_payments.csv", chunk_size=500):
    print(f"Processing {len(chunk)} records")
python
from pacs008.validation import validate_batch

for chunk in load_payment_data_streaming("large_payments.csv", chunk_size=500):
    report = validate_batch(chunk, "pacs.008.001.13")
    print(report.summary())

Validation service Validation service

Run the full pre-generation validation pipeline programmatically.

python
from pacs008.validation import ValidationService, ValidationConfig

service = ValidationService()
report = service.validate_all(ValidationConfig(
    xml_message_type="pacs.008.001.13",
    xml_template_file_path="pacs008/templates/pacs.008.001.13/template.xml",
    xsd_schema_file_path="pacs008/templates/pacs.008.001.13/pacs.008.001.13.xsd",
    data_file_path="payments.csv",
))
print(report.is_valid, report.errors)

Required data fields Required data fields

Each payment record must include these fields. Version-specific fields are listed below.

FieldDescriptionConstraint
msg_idMessage identifierMax 35 characters
creation_date_timeCreation timestampISO 8601 format
nb_of_txsNumber of transactionsPositive integer
settlement_methodSettlement methodCLRG, INDA, COVE, or INGA
end_to_end_idEnd-to-end identifierMax 35 characters
interbank_settlement_amountInterbank settlement amountDecimal, e.g. `25000.00`
interbank_settlement_currencySettlement currencyISO 4217 code
charge_bearerCharge bearerDEBT, CRED, SHAR, or SLEV
debtor_nameDebtor nameMax 140 characters
debtor_agent_bicDebtor agent BIC8 or 11 characters
creditor_agent_bicCreditor agent BIC8 or 11 characters
creditor_nameCreditor nameMax 140 characters

Version-specific fields Version-specific fields

FieldDescriptionConstraint
uetrUnique end-to-end transaction referenceUUID format — available from v08
mandate_idMandate identifierAvailable from v10
expiry_date_timeMessage expiry timestampAvailable in v13

An ƙarshe sabunta: