indian-pincode (core)
Offline-first Indian pincode validation and pincode → state/district lookup for Python.
No runtime network calls — the dataset is embedded in the package at build time. For
post offices, coordinates, and geospatial search, install the geo extra:
pip install "indian-pincode[geo]". That pulls in
indian-pincode-geo, which re-exports
everything in this package plus geo functions.
Which package do I need?
| You need… | Install |
|---|---|
| Validation, pincode → state/district(s), lists | indian-pincode (this package) |
| Post offices, coordinates, nearby search, reverse lookup | indian-pincode[geo] |
Install
pip install indian-pincode
Usage
import indian_pincode as pincode
pincode.validate("110001") # True — exists in the dataset
pincode.is_well_formed("999999") # True — well-formed 6-digit code, format only
pincode.get_state("560001") # "KARNATAKA"
pincode.get_details("682555")["state"] # "LAKSHADWEEP"
pincode.get_districts("110025") # ["BUDAUN", "SOUTH", "SOUTH EAST"] — cross-state pincode
pincode.list_states() # 36 states/UTs
pincode.list_districts("KERALA")[:3] # ["ALAPPUZHA", "ERNAKULAM", "IDUKKI"]
pincode.get_pincodes(state="GOA") # every pincode in Goa
API reference
| Function | Returns |
|---|---|
validate(pin) |
bool — pincode exists in the dataset |
is_well_formed(pin) |
bool — format check only (6 digits); doesn't imply it exists |
get_state(pin) |
primary state name, or None |
get_districts(pin) |
list of every district the pincode touches |
get_details(pin) |
{pincode, state, states, state_source, districts} |
list_states() |
every state/UT name in the dataset |
list_districts(state) |
districts that occur in that state (scoped, not global) |
get_pincodes(state=None, district=None) |
pincodes matching the given filter(s) |
preload() |
force an eager data load instead of lazy-loading on first call |
DATA_VERSION |
dataset snapshot version string, e.g. "2025.10.03" |
get_details(pin) returns state — the primary state for that pincode (the one
with the most post offices; ties broken alphabetically) — and states, a list of every
state the pincode actually touches. These differ only for the ~52 pincodes that straddle
a state boundary; for everything else states has exactly one entry. state_source
tells you whether the state was read directly from source data or inferred during
cleaning.
Keys throughout are snake_case, matching Python convention (the Node package uses camelCase instead — see its own README).
Requirements
Python >=3.10.
Data freshness
DATA_VERSION is the India Post snapshot date this build was compiled from (currently
2025.10.03, read from the dataset's updated_date field). The upstream dataset hasn't
changed content since at least October 2025; releases of this package are
content-gated, not calendar-gated — you get a new snapshot when India Post actually
revises the data, not on a fixed monthly schedule.
Data quality
India Post's own state/district labeling has some gaps and inconsistencies at the
source. This package's build pipeline normalizes state/district names to a single
consistent spelling and backfills a small number of rows with missing state data from
unambiguous evidence, tagging every backfilled row via state_source. Full methodology
and stats: data/REPORT.md.
License
- Code: MIT.
- Data: derived from India Post / data.gov.in under the Government Open Data License – India (GODL-India), which requires attribution — see DATA_LICENSE.md.
Links
- Full project README (both languages, both packages, benchmarks, FAQ)
- Geo companion package
- v1 → v2 migration guide
- Report a data issue
Metadata
Release files for indian-pincode 2.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 | |
|---|---|---|---|
| indian_pincode-2.1.0.tar.gz | 35.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| indian_pincode-2.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 68.2 kB
Release files / indian_pincode-2.1.0.tar.gz
| Download URL | indian_pincode-2.1.0.tar.gz |
|---|---|
| Size | 35.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0ec7b8933787e321666437695dc403da1f0025c43d69be4e866eecf317e5e886
|
|
BLAKE2b-256 checksum How to use checksums |
bd7a06cc7e1191724ae9415f3a0d4534e6176638f061807a4ec07d6ec3746030
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 19, 2026.
Transparency logRelease files / indian_pincode-2.1.0-py3-none-any.whl
| Download URL | indian_pincode-2.1.0-py3-none-any.whl |
|---|---|
| Size | 32.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fea4c1a3a83d691bec669731a29bdbbacf60025c2d4ef544022e16c75c7430f8
|
|
BLAKE2b-256 checksum How to use checksums |
9103ace759d7da01cbd7219c854cf7dbb968b97e0458e796a752cc1699535e9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 19, 2026.
Transparency log