Skip to main content

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

Project description

harriers-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:

pip install harriers-lustr

Usage

import harriers_lustr

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

# Method 2 — the company data for a registration id.
subject = harriers_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).

harriers_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:

harriers_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:

harriers_lustr.configure_cache(my_cache)

Django

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

import harriers_lustr
from harriers_lustr.contrib.django import DjangoCache

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

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

Adding a jurisdiction

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

import harriers_lustr

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

harriers_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.2.0.tar.gz (24.9 kB 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.2.0-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: harriers_lustr-0.2.0.tar.gz
  • Upload date:
  • Size: 24.9 kB
  • 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.2.0.tar.gz
Algorithm Hash digest
SHA256 a66eb7d93d8b3009656da3692a7a650887fd716dafa9be1978e0284b7fc86b23
MD5 09927107d79933836c54974257631af8
BLAKE2b-256 e0dafa0ee52a66c7e0fb063cc193278474c979eaeff4125c668419b418342298

See more details on using hashes here.

File details

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

File metadata

  • Download URL: harriers_lustr-0.2.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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4f53a6cb518883840bab5db02ca676bd72f68254a7d6b9831cc8f5ef6207b9d
MD5 6cbcd2721c5eb5d45c42ddb82c808c27
BLAKE2b-256 48bfed7c0852e7a2b7956e0f23872ff5f24609e04915d5e8ef55947bef63372d

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