territory-indonesia
Version:
Territories of Indonesia
188 lines (156 loc) • 4.18 kB
Markdown
Territories of Indonesia
[](https://www.npmjs.com/package/territory-indonesia)
[](https://www.npmjs.com/package/territory-indonesia)
```bash
$ npm install territory-indonesia
or
$ yarn add territory-indonesia
```
```js
import indonesia from 'territory-indonesia'
// Get all provinces
indonesia
.getAllProvinces()
.then(res => console.log(res))
.catch(err => console.log(err))
// Get province by id
indonesia
.getProvinceById('31')
.then(res => console.log(res))
.catch(err => console.log(err))
// result :
// {
// "id": "31",
// "name": "DKI JAKARTA",
// "alt_name": "DKI JAKARTA",
// "latitude": 6.1745,
// "longitude": 106.8227
// },
// Get all regencies
indonesia
.getAllRegencies(31)
.then(res => console.log(res))
.catch(err => console.log(err))
// Get regency by id
indonesia
.getRegencyById('3171')
.then(res => console.log(res))
.catch(err => console.log(err))
// result :
// {
// "id": "3171",
// "province_id": "31",
// "name": "KOTA JAKARTA SELATAN",
// "alt_name": "KOTA JAKARTA SELATAN",
// "latitude": -6.266,
// "longitude": 106.8135
// },
// Get regencies by name
indonesia
.getRegencyByName('Kota Jakarta Selatan')
.then(res => console.log(res))
.catch(err => console.log(err))
// Get regencies by province id
indonesia
.getRegenciesOfProvinceId('31')
.then(res => console.log(res))
.catch(err => console.log(err))
// Get regencies by province name
indonesia
.getRegenciesOfProvinceName('DKI Jakarta')
.then(res => console.log(res))
.catch(err => console.log(err))
// result :
// [
// {
// "id": "3171",
// "province_id": "31",
// "name": "KOTA JAKARTA SELATAN",
// "alt_name": "KOTA JAKARTA SELATAN",
// "latitude": -6.266,
// "longitude": 106.8135
// },
// {
// .....
// }
// ],
// Get all districts
indonesia
.getAllDistricts()
.then(res => console.log(res))
.catch(err => console.log(err))
// Get district by id
indonesia
.getDistrictById('3171090')
.then(res => console.log(res))
.catch(err => console.log(err))
// result :
// {
// "id": "3171090",
// "regency_id": "3171",
// "name": "TEBET",
// "alt_name": "Tebet, South Jakarta City, Special Capital Region of Jakarta, Indonesia",
// "latitude": -6.23186,
// "longitude": 106.84734
// },
// Get district by name
indonesia
.getDistrictByName('Tebet')
.then(res => console.log(res))
.catch(err => console.log(err))
// Get district by regencyId
indonesia
.getDistrictsOfRegencyId('3171')
.then(res => console.log(res))
.catch(err => console.log(err))
// result :
// {
// "id": "3171090",
// "regency_id": "3171",
// "name": "TEBET",
// "alt_name": "Tebet, South Jakarta City, Special Capital Region of Jakarta, Indonesia",
// "latitude": -6.23186,
// "longitude": 106.84734
// },
// Get all villages
indonesia
.getAllVillages()
.then(res => console.log(res))
.catch(err => console.log(err))
// Get village by id
indonesia
.getVillageById('3171090002')
.then(res => console.log(res))
.catch(err => console.log(err))
// Get village by name
indonesia
.getVillageByName('Tebet Barat')
.then(res => console.log(res))
.catch(err => console.log(err))
// Get village by districtId
indonesia
.getVillagesOfDistrictId('3171090')
.then(res => console.log(res))
.catch(err => console.log(err))
```
Thank you to all the people who already to Territories of Indonesia!
<table>
<td align="center">
<a href="https://github.com/eksant">
<img src="https://avatars1.githubusercontent.com/u/32409305?s=460&v=4" width="25px;" alt="Eko" />
<br /><sub><b>Eko</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/leleonardo81">
<img src="https://avatars3.githubusercontent.com/u/47312797?s=460&v=4" width="25px;" alt="Leonardo" />
<br /><sub><b>Leonardo</b></sub>
</a>
</td>
</table>
License - see the [LICENSE](LICENSE) file for details