Skip to content

Provides the administrative areas data of Indonesia based on the latest official sources 🇮🇩

License

Notifications You must be signed in to change notification settings

resometoda/idn-area-data

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Indonesian Area Data (Data Wilayah Indonesia)

npm version npm downloads GitHub license

Provides the administrative areas data of Indonesia, from the province, regency, district, to village levels based on the latest official sources. It also provides island data since version 1.3.0.

New PAPUA provinces data is available in version 2.0.0

Table of Contents


Prerequisite

Installation

npm install --save idn-area-data

Use this for yarn user :

yarn add idn-area-data

Usage

Import the package into your project :

// CommonJS
const IdnArea = require('idn-area-data');
// or using ES6
import IdnArea from 'idn-area-data';

Then, you can get the data you need using these methods below.

Methods

provinces()

Get all provinces data.

const provinces = await IdnArea.provinces();

/*
[
  {
    code: '11',
    name: 'ACEH',
  },
]
*/

regencies()

Get all regencies data.

const regencies = await IdnArea.regencies();

/*
[
  {
    code: '1101',
    name: 'KABUPATEN ACEH SELATAN',
    province_code: '11',
  },
]
*/

If options.transform argument is true, the property naming will be changed from snake_case into camelCase.

const regencies = await IdnArea.regencies({ transform: true });

/*
[
  {
    code: '1101',
    name: 'KABUPATEN ACEH SELATAN',
    provinceCode: '11',
  },
]
*/

districts()

Get all districts data.

const districts = await IdnArea.districts();

/*
[
  {
    code: '110101',
    name: 'BAKONGAN',
    regency_code: '1101',
  },
]
*/

If options.transform argument is true, the property naming will be changed from snake_case into camelCase.

const districts = await IdnArea.districts({ transform: true });

/*
[
  {
    code: '110101',
    name: 'BAKONGAN',
    regencyCode: '1101',
  },
]
*/

villages()

Get all villages data.

const villages = await IdnArea.villages();

/*
[
  {
    code: '1101012001',
    district_code: '110101',
    name: 'KEUDE BAKONGAN',
  },
]
*/

If options.transform argument is true, the property naming will be changed from snake_case into camelCase.

const villages = await IdnArea.villages({ transform: true });

/*
[
  {
    code: '1101012001',
    districtCode: '110101',
    name: 'KEUDE BAKONGAN',
  },
]
*/

islands()

Get all islands data.

const islands = await IdnArea.islands();

/*
[
  {
    code: '110140001',
    coordinate: '03°19'03.44" N 097°07'41.73" E',
    name: 'Pulau Batukapal',
    is_outermost_small: '0',
    is_populated: '0',
    regency_code: '1101',
  },
]
*/

If options.transform argument is true, the property naming will be changed from snake_case into camelCase and the data type will be converted (for boolean and number).

const islands = await IdnArea.islands({ transform: true });

/*
[
  {
    code: '110140001',
    coordinate: '03°19'03.44" N 097°07'41.73" E',
    name: 'Pulau Batukapal',
    isOutermostSmall: false,
    isPopulated: false,
    regencyCode: '1101',
  },
]
*/

The regencyCode will be null if the island doesn't belong to any regency and the transform option is enabled.

getData()

You also can use getData() function to get the data by providing the area parameter.

const provinces = await IdnArea.getData('provinces');
const regencies = await IdnArea.getData('regencies');
const districts = await IdnArea.getData('districts');
const villages = await IdnArea.getData('villages');
const islands = await IdnArea.getData('islands');

You also can put the options as the second argument :

const regencies = await IdnArea.getData('regencies', { transform: true });

Try it now

You can try to run this package in the code playground :

Edit idn-area-data

Motivation

This package is a solution that addresses the limitations of other existing packages, repositories, or sources that provides Indonesian area data. Here's why it's the perfect choice for developers :

  1. Up-to-date and Government-Sourced Data

    This package ensures that you have access to the most current Indonesian area data. We rely on official government sources, guaranteeing that the information provided is reliable and up-to-date.

  2. Seamless Database Integration

    This package offers data in a format that seamlessly integrates with various databases. Unlike other sources that provide data solely in SQL query or JSON, this package store the data sources in CSV and use JavaScript to parse it into an array. You can easily insert the data into any database by using database integration tools like Prisma, Sequelize, node-postgres, mongodb, etc. This approach ensures compatibility with a wide range of databases.

  3. Easy Integration and Minimum Package Size

    You just need to install this package as a dependency into your project, just like any other library or module. This package has minimal dependencies on other packages, with the majority of its size being attributed to the data source itself.

Data

The data we used is based on official data from the government and stored in separated CSV files by the levels in data directory.

You can see the list of official sources we refer to here.

Problem Reporting

We have different channels for each problem, please use them by following these conditions :

Reporting a Bug

To report a bug, please open a new issue following the guide here.

Requesting a New Feature

If you have a new feature in mind, please open a new issue following the guide here.

Asking a Question

If you have a question, you can search for answers in the GitHub Discussions Q&A category here. If you don't find a relevant discussion already, you can open a new discussion.

License

  • This package and repository are licensed under the MIT License.
  • All data that included in this package and repository are made available under the Open Database License.

These licenses apply to the current and previous versions, and apply to future versions until changed.

About

Provides the administrative areas data of Indonesia based on the latest official sources 🇮🇩

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%