indiapost-geocode
v1.0.0
Published
DIGIPIN encoder/decoder CLI and library for India Post
Maintainers
Readme
DIGIPIN API by Department of Posts
A Geospatial Addressing Solution by India Post
DIGIPIN (Digital PIN) is a 10-character alphanumeric geocode developed by the Department of Posts, India. It provides a precise, user-friendly way to encode geographic coordinates that can be easily shared and decoded back to latitude/longitude pairs.
This open-source Node.js project exposes a public API to generate and decode DIGIPINs, supporting geolocation services, postal logistics, and spatial analysis applications.
🏛️ About DIGIPIN
The Department of Posts has undertaken an initiative to establish a Digital Public Infrastructure (DPI) for a standardized, geo-coded addressing system in India. DIGIPIN represents the foundation layer of this infrastructure.
Developed in collaboration with IIT Hyderabad and NRSC (National Remote Sensing Centre, ISRO), DIGIPIN is an open-source national-level addressing grid that serves as a key component of India's digital address ecosystem.
After extensive public consultation and expert review, the DIGIPIN Grid has been finalized to provide simplified addressing solutions for seamless delivery of public and private services, enabling "Address as a Service" (AaaS) across the country.
Key Highlights
- Uniform Referencing Framework: Provides logical, precise location identification both offline and online
- GIS Integration: Bridges the gap between physical and digital addresses
- Cross-Sector Support: Enhances service delivery across emergency response, e-commerce, logistics, BFSI, and governance
- Policy Alignment: Complies with the National Geospatial Policy 2022, enriching India's geospatial knowledge stack
DIGIPIN simplifies address management and enhances service delivery accuracy, promoting a thriving geospatial ecosystem for India's digital economy.
✨ Features
- Encode: Convert latitude and longitude into a compact 10-character DIGIPIN
- Decode: Transform a DIGIPIN back to its center-point coordinates
- Lightweight: Optimized for performance and minimal resource usage
- RESTful API: Clean, standard-compliant endpoints
- Interactive Documentation: Comprehensive Swagger UI for easy exploration
- Production-Ready: Built with Node.js and Express for reliability
📦 Installation & Usage
Option 1: Use as NPM Package (Recommended)
Install Globally (CLI Usage)
npm install -g digi-pinCLI Commands:
# Encode coordinates to DIGIPIN
digipin encode 28.6139 77.2090
# Output: FFF-3MF-34F8
# Decode DIGIPIN to coordinates
digipin decode FFF-3MF-34F8
# Output: Latitude: 28.613900, Longitude: 77.209000Install Locally (Library Usage)
npm install digi-pinJavaScript Code:
const { getDigiPin, getLatLngFromDigiPin } = require('digi-pin');
// Encode
const pin = getDigiPin(28.6139, 77.2090);
console.log(pin); // FFF-3MF-34F8
// Decode
const coords = getLatLngFromDigiPin('FFF-3MF-34F8');
console.log(coords); // { latitude: '28.613900', longitude: '77.209000' }Option 2: Use Public API
Access our hosted API at: https://your-render-url.onrender.com
Endpoints:
# Encode
curl "https://your-render-url.onrender.com/api/digipin/encode?latitude=28.6139&longitude=77.2090"
# Decode
curl "https://your-render-url.onrender.com/api/digipin/decode?digipin=FFF-3MF-34F8"Interactive docs: https://your-render-url.onrender.com/api-docs
Option 3: Self-Host the API
Clone and run your own instance:
git clone https://github.com/divyanshpandey/digipin.git
cd digipin
npm install
npm start