IndiaID 🇮🇳
IndiaID is a lightweight, zero-dependency Python library for validating, parsing, and masking Indian government IDs, identity numbers, and document codes.
Designed for FinTechs, KYC onboarding pipelines, HRMS, and modern web applications.
✨ Features
- ⚡ Zero Runtime Dependencies: Pure Python 3.9+ standard library.
- 🧮 Algorithmic Validation: Verhoeff algorithm for Aadhaar, Luhn mod-36 for GSTIN.
- 🎭 Privacy & Masking: UIDAI-compliant Aadhaar masking (
XXXXXXXX1234). - 🧩 Metadata Extraction: Parse state, entity type (PAN), issue year (DL), and circle.
- 🔌 Framework Integrations: First-class support for Pydantic v2, Django, and DRF.
- 🛡️ Fully Type-Hinted: PEP 561 compliant (
py.typed) with strict typing.
📦 Installation
pip install indiaid
With optional integrations:
# With Pydantic v2 support
pip install "indiaid[pydantic]"
# With Django support
pip install "indiaid[django]"
# With all integrations
pip install "indiaid[all]"
🚀 Quickstart
1. Direct Document Imports (Most Popular)
Import document validators directly:
from indiaid import pan, aadhaar, gstin
# Validate directly (returns True / False)
pan.is_valid("ABCPE1234F") # True
aadhaar.is_valid("3675 9834 6215") # True (checks Verhoeff checksum)
# Or use callable shortcut
if pan("ABCPE1234F"):
print("Valid PAN!")
# Mask for privacy / compliance
pan.mask("ABCPE1234F") # "ABXXXXXX4F"
aadhaar.mask("3675 9834 6215") # "XXXXXXXX6215"
2. Rich Validation & Metadata Extraction
from indiaid import validate
# Parse PAN details
result = validate("pan", "ABCPE1234F")
if result.is_valid:
print(result.cleaned_value) # "ABCPE1234F"
print(result.metadata["entity_type"]) # "Individual"
print(result.metadata["surname_initial"]) # "E"
# Parse GSTIN details
result = validate("gstin", "27ABCPE1234F1Z5")
if result.is_valid:
print(result.metadata["state_code"]) # "27"
print(result.metadata["state_name"]) # "Maharashtra"
print(result.metadata["pan"]) # "ABCPE1234F"
# Vehicle State Lookup
from indiaid import vehicle
print(vehicle.state("MH01A2925")) # "Maharashtra"
print(vehicle.state("MH")) # "Maharashtra"
print(vehicle.state("22BH1234AA")) # "Bharat Series (All India)"
3. Masking for Privacy Compliance
import indiaid
# Mask Aadhaar for UIDAI/RBI compliance
masked = indiaid.mask("aadhaar", "3675 9834 6215")
print(masked) # "XXXXXXXX6215"
📑 Supported Documents
| Document | Type Key | Algorithm / Checks | Masking |
|---|---|---|---|
| Aadhaar | aadhaar |
Verhoeff checksum, starting digit rules | ✅ |
| PAN Card | pan |
Entity type, surname initial, sequence | ✅ |
| GSTIN | gstin |
State code, embedded PAN, Luhn mod-36 | ✅ |
| Passport | passport |
8-character Indian passport format | ✅ |
| Driving Licence | driving_licence, dl |
State RTO code, year validation | ❌ |
| Voter ID (EPIC) | voter_id, epic |
10-char standard + legacy formats | ✅ |
| Vehicle RC | vehicle, rc |
State RTO codes + Bharat (BH) series | ❌ |
| Bank IFSC | ifsc |
RBI 11-char alphanumeric format | ❌ |
| Mobile Phone | phone |
Indian 10-digit mobile series | ✅ |
| Pincode | pincode |
6-digit postal circle validation | ❌ |
🛠️ Framework Integrations
Pydantic v2
from pydantic import BaseModel
from indiaid.integrations.pydantic import AadhaarStr, PanStr, GstinStr
class UserKYC(BaseModel):
pan: PanStr
aadhaar: AadhaarStr
gstin: GstinStr
Django Models & Forms
from django.db import models
from indiaid.integrations.django import validate_pan, validate_aadhaar
class Profile(models.Model):
pan = models.CharField(max_length=10, validators=[validate_pan])
aadhaar = models.CharField(max_length=12, validators=[validate_aadhaar])
📄 License
MIT © IndiaID Contributors
Metadata
Release files for indiaid 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| indiaid-0.1.0.tar.gz | 25.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| indiaid-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 48.5 kB
Release files / indiaid-0.1.0.tar.gz
| Download URL | indiaid-0.1.0.tar.gz |
|---|---|
| Size | 25.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9b87fda367f4a481fd7ef723f6291f6aa1f701ba70b4a4692852008777e012b1
|
|
BLAKE2b-256 checksum How to use checksums |
fd1b7e8e8dd7ecd64b48116890c53425506a9faf9d3f5a375868e7f301744380
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / indiaid-0.1.0-py3-none-any.whl
| Download URL | indiaid-0.1.0-py3-none-any.whl |
|---|---|
| Size | 23.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
489ad319b1c8d764a2a6acf478b1292e129fd748e7f259b02df30e33a3d61f9f
|
|
BLAKE2b-256 checksum How to use checksums |
04a3e52d3d6784d799432e1b7018ee73dd1bfffe564c1f228a00f5de81f17e0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for indiaid 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.