Skip to main content

Validate and decode national ID numbers — extract structured data from government-issued personal IDs

Project description

nidx

PyPI CI License: MIT

Validate and extract information from national ID numbers across multiple countries.

Also available for Rust and JavaScript.

Installation

pip install nidx

Requires Python 3.9+.

Supported countries

Country Module Extracted fields
Albania albania Date of birth, sex, national status
Kosovo kosovo Validation only

Usage

Albania

from nidx import albania

info = albania.decode("J00101999W")
print(info.birthday)    # 1990-01-01
print(info.sex)         # M
print(info.is_national) # True
print(info.year)        # 1990
print(info.month)       # 1
print(info.day)         # 1

albania.validate("J00101999W")  # raises on invalid input
assert albania.is_valid("J00101999W")
assert not albania.is_valid("invalid")

validate and decode raise NidFormatError, NidChecksumError, or NidInvalidDateError on invalid input (all subclasses of NidError, which is a ValueError).

Kosovo

from nidx import kosovo

kosovo.validate("1234567892")  # raises on invalid input

assert kosovo.is_valid("1234567892")
assert not kosovo.is_valid("invalid")

API

Albania

albania.validate(nid: str) -> None — validates a 10-character Albanian NID. Raises on invalid input.

albania.decode(nid: str) -> NidInfo — validates and decodes a 10-character Albanian NID. Input is case-insensitive.

Field Type Description
birthday str Date of birth (ISO 8601)
year int Birth year
month int Birth month
day int Birth day
sex str "M" or "F"
is_national bool Whether the person is an Albanian national

albania.is_valid(nid: str) -> bool — returns True if the NID is valid.

Kosovo

kosovo.validate(nid: str) -> None — validates a 10-digit Kosovo personal number. Raises on invalid input.

kosovo.is_valid(nid: str) -> bool — returns True if the personal number is valid.

Exceptions

Exception Parent Raised when
NidError ValueError Base exception for all NID errors
NidFormatError NidError Input has wrong length or characters
NidChecksumError NidError Checksum digit doesn't match
NidInvalidDateError NidError Encoded date is not a valid calendar date

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

nidx-0.2.7-cp312-cp312-win_amd64.whl (132.0 kB view details)

Uploaded CPython 3.12Windows x86-64

nidx-0.2.7-cp312-cp312-manylinux_2_34_x86_64.whl (275.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

nidx-0.2.7-cp312-cp312-macosx_11_0_arm64.whl (243.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

Details for the file nidx-0.2.7-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: nidx-0.2.7-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 132.0 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nidx-0.2.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f38d4641e3ba463d4b6ed08f71731581771cb3ef802c0db3d8f99e2325622c08
MD5 4d92f64da02c38d19bf5857a2cb4bbf8
BLAKE2b-256 0cde8d49eb02990d1b46e4a7dce06a644b360b955ffb98965e24d1b0eadb3f2b

See more details on using hashes here.

Provenance

The following attestation bundles were made for nidx-0.2.7-cp312-cp312-win_amd64.whl:

Publisher: release.yml on dedal-io/nidx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nidx-0.2.7-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for nidx-0.2.7-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 7758b1868d5507c8f445c17aa9b08b068384f66ab87b108e093f4109f4c4963b
MD5 3eaa24e103e5e273d9c05989a5cc1c21
BLAKE2b-256 2436cd626de7692021ef7c4713544bc81a78e8c3bb963c31569df0bdf1b2354c

See more details on using hashes here.

Provenance

The following attestation bundles were made for nidx-0.2.7-cp312-cp312-manylinux_2_34_x86_64.whl:

Publisher: release.yml on dedal-io/nidx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nidx-0.2.7-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nidx-0.2.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8d157f17bc950eea1d829a7324e0b2db201dc1c88739205bc5e794a3dee91572
MD5 202511211827bb4ecd9311f72b359fe1
BLAKE2b-256 a073971f5fbcffa56a103ee8ecd5cb39ee2c2cc48f3f4cc70da7ea11014fde05

See more details on using hashes here.

Provenance

The following attestation bundles were made for nidx-0.2.7-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on dedal-io/nidx

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