Skip to main content

X-Road (Trembita) Python client library for SOAP-based service integration

Project description

X-Road (Trembita) Python Client

A powerful Python client library for interacting with X-Road (Trembita) security servers. This library provides a convenient wrapper around the SOAP-based X-Road protocol, allowing developers to easily integrate X-Road services into their Python applications.

Supported Python Versions

  • Python 3.10+
  • Python 3.11+
  • Python 3.12+

Features

  • Easy-to-use SOAP client for X-Road services
  • Support for multiple cache backends (SQLite, Redis, In-Memory)
  • Automatic SOAP header management
  • Transaction ID tracking
  • Configurable logging
  • Type hints for better IDE support

Installation from GitHub

Using pip:

pip install git+https://github.com/AndreyShapovalovVN/pyxroad.git#egg=pyxroad

Or clone and install locally:

git clone https://github.com/AndreyShapovalovVN/pyxroad.git
cd pyxroad
pip install -e .

Requirements

  • lxml >= 5.2.1
  • Requests >= 2.32.3
  • setuptools >= 68.1.2
  • zeep >= 4.0.0
  • redis (optional, for Redis cache support)

Code Quality Checks

Run the same checks locally as in CI:

ruff check . --extend-exclude 'tests/~*.py'
mypy . --ignore-missing-imports --pretty --show-error-codes --exclude 'tests/~.*\.py$'
pytest --maxfail=2 --disable-warnings --ignore-glob='tests/~*.py'

Quick Start

Basic usage example:

from XRoad import XClient, Transport, SqliteCache
import logging
import sys

# Configure logging
logging.basicConfig(
    stream=sys.stdout,
    level=logging.INFO,
    format='%(asctime)s - %(levelname)s - %(name)s - %(message)s'
)
_logger = logging.getLogger('XRoad')

# Create a client instance
client = XClient(
    ssu="http://security-server:8080",
    client='SEVDEIR-TEST/GOV/00013480/100001',
    service='SEVDEIR-TEST/GOV/00032684/MIA_prod/CheckPassportStatus/v0.1'
)

# Make a service request
try:
    response = client.request(
        xroad_id='ABCD123456',  # Optional: set custom request ID
        PasNumber='AA123456',
        PasSerial='654321'
    )
    _logger.info(f"Response: {response}")
except Exception as err:
    _logger.error(f"Error: {err}")

Advanced Usage

Using custom caching backend:

from XRoad import XClient, Transport, RedisCache

# With Redis cache
redis_cache = RedisCache(path='redis://localhost:6379/0', timeout=3600)
transport = Transport(cache=redis_cache)

client = XClient(
    ssu="http://security-server:8080",
    client='SEVDEIR-TEST/GOV/00013480/100001',
    service='SEVDEIR-TEST/GOV/00032684/MIA_prod/CheckPassportStatus/v0.1',
    transport=transport
)

RedisCache now has a safe fallback: if redis package is not installed or Redis server is unavailable, it returns InMemoryCache(timeout=...) instead of raising an exception.

Setting custom headers:

client.userId = '0123456789'  # Custom user ID
client.id = 'ABCD123456'      # Custom request ID

Available Cache Types

  • InMemoryCache: Default, stores cache in application memory
  • SqliteCache: Persistent cache using SQLite database
  • RedisCache: Distributed cache using Redis

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For issues, questions, and contributions, please visit: https://github.com/AndreyShapovalovVN/pyxroad

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

pyxroad-1.5.10.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

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

pyxroad-1.5.10-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file pyxroad-1.5.10.tar.gz.

File metadata

  • Download URL: pyxroad-1.5.10.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyxroad-1.5.10.tar.gz
Algorithm Hash digest
SHA256 8bf3f785a9c377f9060b04da38bd23bdfafef3d928393696e1c1607d4186f687
MD5 cc0f4a834fc6af724c637c36ff21ead2
BLAKE2b-256 9b214389580fadc206ec9f2948db28be1ef11609391daf1fb16a31c0836ba22b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyxroad-1.5.10.tar.gz:

Publisher: python-publish.yml on AndreyShapovalovVN/pyxroad

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyxroad-1.5.10-py3-none-any.whl.

File metadata

  • Download URL: pyxroad-1.5.10-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyxroad-1.5.10-py3-none-any.whl
Algorithm Hash digest
SHA256 1598a635c0af8ab4b31a9a307ff1503b55baeb6e27ae855349af515fce19ea9c
MD5 bbc5307fdd789dba6141b950a49887a2
BLAKE2b-256 e6a5d6fe0582935b2f8abc1e422bab9ac5fe56ec6d7d774870457c112662c9bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyxroad-1.5.10-py3-none-any.whl:

Publisher: python-publish.yml on AndreyShapovalovVN/pyxroad

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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