https://github.com/epicx67/indian_places
A npm package to get all the recognized places of india including pincode
https://github.com/epicx67/indian_places
citylist json library npm package townlist
Last synced: about 1 year ago
JSON representation
A npm package to get all the recognized places of india including pincode
- Host: GitHub
- URL: https://github.com/epicx67/indian_places
- Owner: epicX67
- License: mit
- Created: 2022-06-22T18:31:30.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-07-28T21:43:35.000Z (almost 4 years ago)
- Last Synced: 2025-04-08T19:52:31.502Z (about 1 year ago)
- Topics: citylist, json, library, npm, package, townlist
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/indian_places
- Size: 2.88 MB
- Stars: 11
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Indian Places
List of india places including pincode. [Demo](https://epicx67.github.io/indian_places_demo/)
### Installation
npm i indian_places
## Example
```javascript
const ip = require("indian_places");
// To get the states
const states = ip.getStates();
// To get the district of a state
const westBengal = states.find((item) => item.name === "West Bengal");
const districtsOfWb = westBengal.getDistricts();
// To get places of a specific district
const north24Pgs = districtsOfWb.find(
(item) => item.name === "North 24 parganas"
);
const places = north24Pgs.getPlaces();
// To get places by pincode
// This function will return empty array if that pincode doesn't exists
const places = ip.getPlacesByPin(743271);
```
## Functions
To get place data, package contains essential functions which will help you to retrive exact place from mapped data. I described little bit about object types below.
| func() | parameter | returns |
| ----------------------- | -------------------- | ------------------------- |
| getStates() | None | Array of **State** Obj |
| getDistrictsByState() | **State** - obj | Array of **District** Obj |
| getPlacesByDistrict() | **District** - obj | Array of **Place** Obj |
| getPlacesByPin() | **pincode** - number | Array of State Obj |
## Objects
#### State Object
| member | description |
| -------------- | ------------------------------------- |
| name | State name |
| getDistricts() | Method to get districts of that state |
#### District Object
| member | description |
| ----------- | ------------------------------------- |
| name | District name |
| state | State name of that district |
| getPlaces() | Method to get places of that district |
#### Place Object
| member | description |
| -------- | --------------------------- |
| name | Place name |
| district | District name of that place |
| state | State name of that place |
| pin | Pincode of that place |
### At last
> If you like this wrapper package please give this repo a star :)
Credits,
[India gov data portal](https://data.gov.in/)