Skip to main content

Jurisdiction-agnostic company-register lookup (CZ ARES, …).

Project description

lustr

Jurisdiction-agnostic company-register lookup. Give it a jurisdiction and a registration id (CZ: IČO), get back jurisdiction-neutral company data — name, VAT id, legal form, seat address, responsible tax office — through one small interface.

Bundled providers: CZ → ARES and SK → RPO (both real, public REST APIs). Framework-free (only depends on httpx); an optional Django cache adapter is included.

Install

From PyPI (the distribution is named harriers-lustr; the import stays lustr):

pip install harriers-lustr

To depend on it from another project, pin it by version like any other PyPI package:

# pyproject.toml / requirements.txt
harriers-lustr>=0.1

Installing straight from the repository also works (e.g. before a release is on PyPI):

pip install "harriers-lustr @ git+https://gitlab.com/harriers/lustr@v0.1.0"

Renamed from lustr. Earlier releases were published as lustr in this project's GitLab package registry; that registry no longer receives releases, so switch any lustr dependency to harriers-lustr from PyPI. Do not pip install lustr — the name lustr on public PyPI belongs to an unrelated project.

Usage

import lustr

# Method 1 — the registration-id format for a jurisdiction (drives input UI).
fmt = lustr.id_format("CZ")
print(fmt.label, fmt.example)          # "IČO" "27082440"

# Method 2 — the company data for a registration id.
subject = lustr.fetch_subject("CZ", "27082440")
print(subject.name)                    # "Alza.cz a.s."
print(subject.vat_id)                  # "CZ27082440"
print(subject.legal_form_name)         # "Akciová společnost"
print(subject.tax_office_code)         # "451"  (ÚFO resolved from the seat's kraj)

fetch_subject returns a frozen RegistrySubject dataclass and raises typed errors: InvalidRegistrationId, RegistryNotFound, RegistryUnavailable, UnknownJurisdiction (all subclasses of RegistryError).

lustr.jurisdictions() lists the supported jurisdictions for a picker.

Slovakia

The identity (name, legal form, seat) comes from RPO, which needs no auth. The VAT id (IČ DPH) lives in a separate register — the Financial Administration's OpenData portal — which needs a free, self-service API key:

lustr.configure_sk(fs_dph_key="…")     # or set LUSTR_SK_DPH_KEY in the environment

The key is required: the VAT lookup is a step of every SK company lookup, so a missing key or an unreachable FS register raises RegistryUnavailable instead of returning a subject. That way an empty vat_id always means "not a VAT payer" and never "could not be checked".

Caching

Lookups are cached (12h TTL) so repeated queries don't hit the register. By default the cache is a process-local in-memory store — zero config. To share a cache across processes, inject any backend with get/set/delete:

lustr.configure_cache(my_cache)

Django

An adapter over django.core.cache ships in lustr.contrib.django (imports Django lazily, so it stays an optional dependency). Wire it once at startup:

import lustr
from lustr.contrib.django import DjangoCache

lustr.configure_cache(DjangoCache())          # the "default" cache alias
lustr.configure_cache(DjangoCache("redis"))   # a named alias

Mapping a RegistrySubject onto your own models (an Organization, a contact/party, …) stays in your project — lustr only returns the neutral data.

Adding a jurisdiction

Subclass RegistryProvider (implement id_format + fetch, optionally normalize_id) and register it:

import lustr

class MyProvider(lustr.RegistryProvider):
    jurisdiction = "PL"
    name = "Polska"
    register_name = "KRS"
    def id_format(self): ...
    def fetch(self, registration_id): ...

lustr.register_provider(MyProvider())

Development

pip install -e ".[test]"
pytest

Releasing

The version is derived from the git tag (hatch-vcs). To cut a release:

git tag v0.1.0
git push origin v0.1.0

The CI publish job builds the sdist+wheel and uploads them to PyPI via trusted publishing (OIDC — no API token stored in CI). One-time prerequisite: the PyPI project harriers-lustr must list this GitLab repo as a trusted publisher — for the very first release, register a pending publisher on PyPI for gitlab.com namespace harriers, project lustr.

License

MIT — see LICENSE.

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

harriers_lustr-0.1.0.tar.gz (12.3 MB view details)

Uploaded Source

Built Distribution

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

harriers_lustr-0.1.0-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

Details for the file harriers_lustr-0.1.0.tar.gz.

File metadata

  • Download URL: harriers_lustr-0.1.0.tar.gz
  • Upload date:
  • Size: 12.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for harriers_lustr-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8787dd1a51076c694b122509d4f6639475b96ed545c1ce7987dcee24d37e7cc1
MD5 5a91c415e5ebec8dfe173c35dc4ed4a4
BLAKE2b-256 6131646871d3261adf7ba2be75995e41986f1e47539b35f2ee4643b30aa8e83d

See more details on using hashes here.

File details

Details for the file harriers_lustr-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: harriers_lustr-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 24.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for harriers_lustr-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ec6cdeb3662e7ea07f10a5ece2b4333f07da1f5d7c43bd464be38ebae94dc7c
MD5 e1ebc22aa6f3378822a19f98bdcfe9df
BLAKE2b-256 6233b9f036fe2f73be1b5e5f56f277863752f1ecd640b1e33650c445d1da8fa9

See more details on using hashes here.

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