indian-postalcode-details
v1.0.4
Published
A simple Node.js utility to get **city** and **state** from an Indian **PIN code**, powered by the India Post API.
Downloads
21
Maintainers
Readme
🇮🇳 indian-postalcode-details
A simple Node.js utility to get city and state from an Indian PIN code, powered by the India Post API.
✨ Features
- Get city & state using just a PIN code
- Fast and lightweight
- Uses official India Post API
- Easy to integrate
Installation
npm install indian-postalcode-details
##
const { getCityStateFromPincode } = require('indian-postalcode-details');
(async () => {
const result = await getCityStateFromPincode('560001');
console.log(result);
})();
---
## Output:
{
"city": "Bengaluru",
"state": "Karnataka"
}
---
## API
getCityStateFromPincode(pincode)
| Parameter | Type | Description |
| --------- | -------- | ----------------------- |
| `pincode` | `string` | 6-digit Indian PIN code |
---
## Returns a Promise that resolves to:
{ city: 'City Name', state: 'State Name' }
---
## Error Handling
If the PIN code is invalid or the API fails:
throw new Error('Invalid PIN code' or 'Failed to fetch data');
---
## 🔗 Powered By
India Post API
---
## 📝 License
MIT © 2025 Abhinav Anand