Validate and decode national ID numbers — extract structured data from government-issued personal IDs
Project description
nidx
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
assert albania.is_valid("J00101999W")
assert not albania.is_valid("invalid")
decode raises 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.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
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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nidx-0.2.1-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: nidx-0.2.1-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 131.7 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
654b27377dce5dc359b634d1d24303c8467171ebc73db58be7cab3970a019e40
|
|
| MD5 |
4d7cb000b02dd07b6f05481e153f24ad
|
|
| BLAKE2b-256 |
8e5868c396b993c034a5dbaf1a5cb57b3e6525a8faa0edbdbbcd9e62d6675877
|
Provenance
The following attestation bundles were made for nidx-0.2.1-cp312-cp312-win_amd64.whl:
Publisher:
release.yml on dedal-io/nidx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nidx-0.2.1-cp312-cp312-win_amd64.whl -
Subject digest:
654b27377dce5dc359b634d1d24303c8467171ebc73db58be7cab3970a019e40 - Sigstore transparency entry: 1004143497
- Sigstore integration time:
-
Permalink:
dedal-io/nidx@f3f3c2c8695c19283d622ec6f3e360eebfcea6f8 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/dedal-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f3f3c2c8695c19283d622ec6f3e360eebfcea6f8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file nidx-0.2.1-cp312-cp312-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: nidx-0.2.1-cp312-cp312-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 274.7 kB
- Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
934c008e242c2342b8f97357096893a08c25a0f5c50445adfec7734fc6cf16a8
|
|
| MD5 |
28a63a07522d4c16e64a0cf947d21759
|
|
| BLAKE2b-256 |
c1b3810fac119500d21fe9b062faeeb7729ee97820b42662f7310a1bd0117134
|
Provenance
The following attestation bundles were made for nidx-0.2.1-cp312-cp312-manylinux_2_34_x86_64.whl:
Publisher:
release.yml on dedal-io/nidx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nidx-0.2.1-cp312-cp312-manylinux_2_34_x86_64.whl -
Subject digest:
934c008e242c2342b8f97357096893a08c25a0f5c50445adfec7734fc6cf16a8 - Sigstore transparency entry: 1004143493
- Sigstore integration time:
-
Permalink:
dedal-io/nidx@f3f3c2c8695c19283d622ec6f3e360eebfcea6f8 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/dedal-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f3f3c2c8695c19283d622ec6f3e360eebfcea6f8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file nidx-0.2.1-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: nidx-0.2.1-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 242.5 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d20cd3560c77c38c194a3acb619fa20022d469dae51927acd2991c3bb32b717b
|
|
| MD5 |
15ed90119beb7c3b6e2137824ecccfb5
|
|
| BLAKE2b-256 |
bc1dcd828c6a8529416272428f79e5b80b55ad4b3bbf87f0110b11d41a138c91
|
Provenance
The following attestation bundles were made for nidx-0.2.1-cp312-cp312-macosx_11_0_arm64.whl:
Publisher:
release.yml on dedal-io/nidx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nidx-0.2.1-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
d20cd3560c77c38c194a3acb619fa20022d469dae51927acd2991c3bb32b717b - Sigstore transparency entry: 1004143496
- Sigstore integration time:
-
Permalink:
dedal-io/nidx@f3f3c2c8695c19283d622ec6f3e360eebfcea6f8 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/dedal-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f3f3c2c8695c19283d622ec6f3e360eebfcea6f8 -
Trigger Event:
push
-
Statement type: