Skip to main content

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 and development with uv

Install uv. To add pyxroad to another uv project:

uv add git+https://github.com/AndreyShapovalovVN/pyxroad.git

To work on this repository:

git clone https://github.com/AndreyShapovalovVN/pyxroad.git
cd pyxroad
uv sync --locked --extra dev

uv creates .venv and installs the project and development tools. The .python-version file selects Python 3.12 for development and CI; the library continues to support Python 3.10+. For runtime dependencies only, use uv sync --locked.

Dependencies are declared in pyproject.toml; uv.lock records exact versions. Commit both files when changing dependencies with uv add, uv remove, or uv lock --upgrade-package PACKAGE. Refresh the component license inventory when runtime dependencies change. --locked rejects a stale lockfile.

Code Quality Checks

Run the same checks locally as in CI:

uv run --locked --extra dev python scripts/check_licenses.py
uv run --locked --extra dev ruff check . --extend-exclude 'tests/~*.py'
uv run --locked --extra dev mypy . --ignore-missing-imports --pretty --show-error-codes
uv run --locked --extra dev pytest --maxfail=2 --disable-warnings --ignore-glob='tests/~*.py'

Build and publish

Build using the setuptools version installed from uv.lock, then verify that both distributions contain the license materials:

uv sync --locked
uv build --no-build-isolation
uv run --locked python scripts/check_licenses.py --dist-dir dist

The release workflow runs tests and these checks, then publishes with uv publish --trusted-publishing always using the existing PyPI Trusted Publisher and pypi GitHub environment.

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. Third-party components retain their own licenses. See the component inventory and third-party notices and redistribution guidance.

Support

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

Metadata

Release files for pyxroad 1.5.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyxroad 1.5.11
File Size Uploaded
pyxroad-1.5.11.tar.gz 140.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyxroad 1.5.11
File Interpreter ABI Platform
pyxroad-1.5.11-py3-none-any.whl Python 3 none any Details

Total release size: 249.6 kB

Release files / pyxroad-1.5.11.tar.gz

Download URL pyxroad-1.5.11.tar.gz
Size 140.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a5572452fbe2b8aaa6dcd8447dd3c6227b9958d19b21853237cdc4b15253b557
BLAKE2b-256 checksum
How to use checksums
406e2643458b138dbde402c1d47e74a60bb25c95dfe9772419e748c1d8bda673
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pyxroad-1.5.11-py3-none-any.whl

Download URL pyxroad-1.5.11-py3-none-any.whl
Size 108.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e68c59df56b56906d7deba607e2c06da64877a21d95f4631e5f4aaa013a0f498
BLAKE2b-256 checksum
How to use checksums
ae0c685032500f98e414c82606622f7bcd89807453b188be79713b6bbb1eabdc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

1.5.11 This release

2 release files

1.5.10

2 release files

1.5.9

2 release files

1.5.8

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page