api-wilayah-indonesia

repository·master·Indexed 20 days ago

https://github.com/emsifa/api-wilayah-indonesia

A 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.

Tokens
2.5K
Snippets
14
Records
17
Agent score
71%

What's inside api-wilayah-indonesia

  1. Overview of API Data Wilayah Indonesia

    master
    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.
  2. Deploy the API to your own GitHub Pages

    master

    To host this API on your own GitHub account to avoid bandwidth limits, follow these steps:

    1. Fork the repository: Click 'Fork' in the top right corner. IMPORTANT: Uncheck "Copy the master branch only" during the forking process.
    2. 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.
    3. Verify Deployment: Wait 5-10 minutes. Check the "Environments" section on the repository home page. Once github-pages appears, click "View Deployment" to confirm it is live.
  3. Initialize the Repository with a data directory

    master

    To use the Emsifa\ApiWilayah\Repository class, 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');
  4. Understand API bandwidth limitations

    master

    Because 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.

  5. Get specific Village details by ID

    master

    Retrieve 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.json
  6. Get specific Regency/City details by ID

    master

    Retrieve 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.json
  7. Get list of Regencies/Cities by Province ID

    master

    Retrieve 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.json
  8. Get list of Districts by Regency ID

    master

    Retrieve 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.json
  9. Get list of Villages by District ID

    master

    Retrieve 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.json
  10. Get specific Province details by ID

    master

    Retrieve 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.json
  11. Get specific District details by ID

    master

    Retrieve 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