Hi there! 👋
I just made an Indonesia Region API that provides structured data for provinces, regencies, districts, and villages.
This API is built to help developers easily access Indonesian administrative region data for learning purposes, personal projects, or production use.
Public Indonesia Region API for provinces, regencies, districts, and villages. Free to use for learning, personal projects, and production.
Node Js, Express Js, Supabase, Prisma ORM
Follow these steps to run the project locally:
- Clone this repository
- Install dependencies
npm install
- running project
npm run dev
npm run dev– run in development modenpm run build– build projectnpm run start– run production buildnpm run test- testing projectnpm run seed- seeding data
To run this project, you will need to add the following environment variables to your .env file
-
Connect to Supabase via connection pooling
DATABASE_URL="postgresql://USER:PASSWORD@HOST:PORT/DATABASE?pgbouncer=true" -
Direct connection to the database. Used for migrations
DIRECT_URL="postgresql://USER:PASSWORD@HOST:PORT/DATABASE" -
port
PORT=8000 -
node env
NODE_DEV="development" -
documentation link
DOCUMENTATION="https://github.com/fento2/indonesia-region-api/tree/main#api-reference"
Try it yourself: https://indonesia-region-api.vercel.app/province
All list endpoints (province, regency, district, village) use the same query format and response structure.
You only need to change the endpoint name
Base endpoints:
/province/regency/district/village
| Query | Type | Required | Description |
|---|---|---|---|
limit |
number | No | Number of data per page (default: 10) |
page |
number | No | Page number (default: 1) |
sortBy |
string | No | Field used for sorting (ex: name, createdAt, code) |
sortOrder |
string | No | Sort direction: asc or desc (default: asc) |
search |
string | No | Search data by keyword (can search by name or code. For village, it can also search by postalCode) |
type |
string | No | Filter regency by type. Allowed values: Kabupaten or Kota. (Only available on regency endpoint) |
postalCode |
string | No | Filter village by postal code. Only available on village endpoint. |
GET https://indonesia-region-api.vercel.app/province?limit=5&page=1&sortBy=name&sortOrder=asc&search=sulawesi{
"result": {
"message": "list province success",
"data": [
{
"code": "76",
"name": "Sulawesi Barat"
},
{
"code": "73",
"name": "Sulawesi Selatan"
},
{
"code": "72",
"name": "Sulawesi Tengah"
},
{
"code": "74",
"name": "Sulawesi Tenggara"
},
{
"code": "71",
"name": "Sulawesi Utara"
}
],
"meta": {
"total": 5,
"page": 1,
"limit": 5,
"totalPage": 1
},
"documentation": "See documentation: https://github.com/fento2/indonesia-region-api/tree/main#api-reference"
}
}All detail endpoints (/province/detail, /regency/detail, /district/detail, /village/detail) use the same query format and response structure.
You only need to change the endpoint name.
Base endpoints:
/province/detail/regency/deatail/district/detail/village/detail
| Query | Type | Required | Description |
|---|---|---|---|
code |
string | Yes | Unique region code (example: 11) |
include |
string | No | Related data to include (comma separated) |
- Province →
regencies,districts,villages - Regency →
province,districts,villages - District →
regency,province,villages - Village →
district,regency,province
GET https://indonesia-region-api.vercel.app/village/detail?code=8102192005&include=district,regency,province{
"result": {
"message": "detail village code: 8102192005 success",
"data": {
"code": "8102192005",
"name": "Elaar Lamagorang",
"postalCode": "97626",
"district": {
"code": "810219",
"name": "Kei Kecil Timur Selatan",
"regency": {
"code": "8102",
"name": "Maluku Tenggara",
"type": "Kabupaten",
"province": {
"code": "81",
"name": "Maluku"
}
}
}
},
"documentation": "See documentation: https://github.com/fento2/indonesia-region-api/tree/main#api-reference"
}
}⭐ Support This Project
If you find this project useful, please consider giving it a star on GitHub 🌟 It helps the project grow and motivates me to keep improving it.