api-wilayah-indonesia
repository·master·Indexed 20 days ago
https://github.com/emsifa/api-wilayah-indonesiaA static REST API providing hierarchical Indonesian regional data, including provinces, regencies, districts, and villages. Designed for lightweight deployment on static hosting services like GitHub Pages, it includes a PHP-based Generator and Repository system to transform CSV data into structured JSON endpoints.
What's inside api-wilayah-indonesia
- This project provides a static REST API containing Indonesian regional data (provinces, regencies, districts, and villages). Because it is a 'static API', the endpoints consist of static files, allowing it to be hosted on services like GitHub Pages or Netlify without requiring server-side scripting. This results in faster response times and lower hosting costs.
Deploy the API to your own GitHub Pages
masterTo host this API on your own GitHub account to avoid bandwidth limits, follow these steps:
- Fork the repository: Click 'Fork' in the top right corner. IMPORTANT: Uncheck "Copy the master branch only" during the forking process.
- Configure GitHub Pages:
- Go to your repository's Settings.
- Select the Pages menu.
- Set Source to
Deploy from a Branch. - Set Branch to
gh-pages. - Set Directory to
/root. - Click Save.
- Verify Deployment: Wait 5-10 minutes. Check the "Environments" section on the repository home page. Once
github-pagesappears, click "View Deployment" to confirm it is live.
Initialize the Repository with a data directory
masterTo use the
Emsifa\ApiWilayah\Repositoryclass, you must instantiate it by providing the path to the directory containing the CSV data files (e.g.,provinces.csv,regencies.csv, etc.).use Emsifa\ApiWilayah\Repository; $repository = new Repository('/path/to/your/data/directory');Understand API bandwidth limitations
masterBecause the API is hosted on GitHub Pages, it is subject to GitHub's bandwidth limits (typically 100GB/month).
With an average endpoint size of 1KB, this allows for approximately 100,000,000 requests per month (roughly 3,000,000 requests per day). If your application expects higher traffic, it is highly recommended to fork the repository and host the API on your own GitHub Pages or other static hosting provider.
Get specific Village details by ID
masterRetrieve detailed information for a single village using its
villageId.GET https://emsifa.github.io/api-wilayah-indonesia/api/village/{villageId}.json # Example for Jambo Dalem (ID = 1103011010) GET https://emsifa.github.io/api-wilayah-indonesia/api/village/1103011010.jsonGet specific Regency/City details by ID
masterRetrieve detailed information for a single regency or city using its
regencyId.GET https://emsifa.github.io/api-wilayah-indonesia/api/regency/{regencyId}.json # Example for Aceh Selatan (ID = 1103) GET https://emsifa.github.io/api-wilayah-indonesia/api/regency/1103.jsonGet list of all Provinces
masterRetrieve a list of all provinces in Indonesia. Each object contains an
idand aname.GET https://emsifa.github.io/api-wilayah-indonesia/api/provinces.jsonGet list of Regencies/Cities by Province ID
masterRetrieve a list of regencies (Kabupaten) or cities (Kota) belonging to a specific province using its
provinceId.GET https://emsifa.github.io/api-wilayah-indonesia/api/regencies/{provinceId}.json # Example for Aceh (ID = 11) GET https://emsifa.github.io/api-wilayah-indonesia/api/regencies/11.jsonGet list of Districts by Regency ID
masterRetrieve a list of districts (Kecamatan) belonging to a specific regency or city using its
regencyId.GET https://emsifa.github.io/api-wilayah-indonesia/api/districts/{regencyId}.json # Example for Aceh Selatan (ID = 1103) GET https://emsifa.github.io/api-wilayah-indonesia/api/districts/1103.jsonGet list of Villages by District ID
masterRetrieve a list of villages (Kelurahan/Desa) belonging to a specific district using its
districtId.GET https://emsifa.github.io/api-wilayah-indonesia/api/villages/{districtId}.json # Example for Trumon (ID = 1103010) GET https://emsifa.github.io/api-wilayah-indonesia/api/villages/1103010.jsonGet specific Province details by ID
masterRetrieve detailed information for a single province using its
provinceId.GET https://emsifa.github.io/api-wilayah-indonesia/api/province/{provinceId}.json # Example for Aceh (ID = 11) GET https://emsifa.github.io/api-wilayah-indonesia/api/province/11.jsonGet specific District details by ID
masterRetrieve detailed information for a single district using its
districtId.GET https://emsifa.github.io/api-wilayah-indonesia/api/district/{districtId}.json # Example for Trumon Timur (ID = 1103011) GET https://emsifa.github.io/api-wilayah-indonesia/api/district/1103011.json