Skip to main content

BeddrokClient

Python client for the Beddrok API: personnummer in, stable numbers out.

Installation

pip install BeddrokClient

Usage

from beddrokclient import BeddrokClient

with BeddrokClient(
    user="cint-clean",
    password="...",
    api_url="http://beddrok-api.rst-vdp-lake-beddrok-prod.svc:8000",
) as beddrok:
    pseudonyms = beddrok.pseudonymize(["199204062355", "920406-2355"])
    pseudonyms["199204062355"].number
    pseudonyms["199204062355"].removed

    resolved = beddrok.resolve([12345])
    resolved[12345].pin
    resolved[12345].status
Method Endpoint Access Returns
pseudonymize(pins) POST /pseudonymize encrypt {pin: Pseudonym(pin, number, removed)}
resolve(numbers) POST /resolve decrypt {number: Resolved(number, pin, status)}, status ok, removed or unknown
health() GET /health/api none True if the API answers

What it does for you

  • Logs in through POST /auth/token and renews the token 5 minutes before it expires, reading the expiry from the JWT. On a 401 it logs in again once and retries.
  • Splits input into batches: 1000 pins per /pseudonymize call, 20 numbers per /resolve call, the API's default limits. Duplicates are sent once.
  • Retries connection errors and 503 with exponential backoff, backoff_base ** attempt seconds, up to max_retries.

What it never does

  • It never changes a pin. Pins are sent exactly as given. Beddrok gives 920406-2355 and 199204062355 two different numbers, so pass values exactly as the source has them.
  • It never returns a partial answer. If any pin or number is missing from the response, it raises BeddrokError. It never falls back to the original value.
  • It never puts a personnummer in an error. BeddrokError carries path, status and the HTTP reason only. Response bodies are never included, because a 422 echoes the request.

Configuration

BeddrokClient(
    user="...",
    password="...",
    api_url="...",
    timeout=30,
    max_retries=3,
    backoff_base=2.0,
    pseudonymize_batch_size=1000,
    resolve_batch_size=20,
    refresh_token_before_seconds=300,
)

Upgrading from 2.x

3.0 targets the Beddrok API as it is deployed. The 2.x methods called endpoints that API does not have (/encrypt, /decrypt, /validate) and have been removed: encrypt_pins, decrypt_pins, validate_pins, and the pandas and polars DataFrame helpers. Use pseudonymize and resolve instead. pandas, polars and roskarl are no longer dependencies.

Development

pip install -e ".[dev]"
ruff check . && ruff format --check .
pyright
pytest

The tests run against a local fake Beddrok server, no cluster needed.

Metadata

Release files for BeddrokClient 3.0.2

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

Source distribution (sdist)

Source distribution for BeddrokClient 3.0.2
File Size Uploaded Provenance
beddrokclient-3.0.2.tar.gz 8.8 kB With provenance Details

Built distribution (wheel)

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

Total release size: 15.9 kB

Release files / beddrokclient-3.0.2.tar.gz

Download URL beddrokclient-3.0.2.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8c585b8b0b8fd262e9f5c4f54ac80bc308be7ddf32dd00734b39445c874213ad
BLAKE2b-256 checksum
How to use checksums
326d665bb7d148f2d8424acc96727f10e8b9e3db0553006a4bd3009e3c2a9006
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Release files / beddrokclient-3.0.2-py3-none-any.whl

Download URL beddrokclient-3.0.2-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f03f643aade7fc7c544acb6a01f188c7836190b08a8d7bfc00beb0defc232d9b
BLAKE2b-256 checksum
How to use checksums
5f733fd7f01b1cbae5c72a4de616c2573e0cbbf6e233dd4831c60a2c5caf8922
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Security for BeddrokClient 3.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for beddrokclient-3.0.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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