The data provided here is sourced from the nomor.net website, which is updated based on official Indonesian government regulations:
- Kepmendagri RI No. 100.1.1-6117 Tahun 2022
- Permendagri RI No. 58 Tahun 2021
References for the regional formation regulations are also available on the source website:
This database covers all administrative regions in Indonesia:
- 38 Provinces
- 514 Cities
- 7,277 Districts (Kecamatan)
- 83,763 Subdistricts (Desa/Kelurahan)
The generated SQL files contain INSERT statements for their respective tables, tested on PostgreSQL databases; usage with other database systems may require adjustments.
The following DDL (Data Definition Language) script defines the required table structure:
CREATE TABLE provinces (
id int4 NOT NULL GENERATED BY DEFAULT AS IDENTITY,
name varchar NOT NULL,
CONSTRAINT pk_pronvinces PRIMARY KEY (id)
);
CREATE TABLE cities (
id int4 NOT NULL GENERATED BY DEFAULT AS IDENTITY,
province_id int4 NOT NULL,
"name" varchar NOT NULL,
CONSTRAINT pk_cities PRIMARY KEY (id),
CONSTRAINT fk_cities_province_id FOREIGN KEY (province_id) REFERENCES provinces(id)
);
CREATE TABLE districts (
id int4 NOT NULL GENERATED BY DEFAULT AS IDENTITY,
city_id int4 NOT NULL,
"name" varchar NOT NULL,
CONSTRAINT pk_districts PRIMARY KEY (id),
CONSTRAINT fk_districts_city_id FOREIGN KEY (city_id) REFERENCES cities(id)
);
CREATE TABLE subdistricts (
id int4 NOT NULL GENERATED BY DEFAULT AS IDENTITY,
district_id int4 NOT NULL,
"name" varchar NOT NULL,
"code" varchar NOT NULL, -- subdistrict's administrative code
postal_code varchar NOT NULL,
CONSTRAINT pk_subdistricts PRIMARY KEY (id),
CONSTRAINT fk_subdistricts_district_id FOREIGN KEY (district_id) REFERENCES districts(id)
);All data in this repository is accessible for free via a public Open API. This is the easiest way to integrate Indonesian location data into your application without the need to set up and maintain your own database.
Explore the API documentation and get started at: https://rayon.practical.web.id
Special thanks to: