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
)

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.8.tar.gz (11.1 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.8-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyxroad-1.5.8.tar.gz
  • Upload date:
  • Size: 11.1 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.8.tar.gz
Algorithm Hash digest
SHA256 b009cb6d401f5b5ae3b312c134fd0cd9c93e66741e2127ecea23ff91ff65ba6a
MD5 8a1c2800636efc70547e1b6bc07a2362
BLAKE2b-256 0af582094b4efc1df50d9b1376048a46ff52b6314ccb576c4ef0215721bb95ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyxroad-1.5.8.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.8-py3-none-any.whl.

File metadata

  • Download URL: pyxroad-1.5.8-py3-none-any.whl
  • Upload date:
  • Size: 9.9 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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 209de854e54d403d760b1aef51729587e96495faedaff6cf32cbc06f538f321f
MD5 55284901a839a7fc8dd5864b7e0f6325
BLAKE2b-256 0e589478ac0b3c9eebea418b920d3de4bd1293db6bd4f989991cfb3fa69b4e8a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyxroad-1.5.8-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