• Stars
    star
    436
  • Rank 96,813 (Top 2 %)
  • Language
    HTML
  • Created over 4 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Generator API (statis) data wilayah Indonesia, hosted by Github Page

API Data Wilayah Indonesia

Repository ini berisi source code untuk generate (REST) API statis berisi data wilayah Indonesia serta perintah untuk mendeploynya ke static hosting Github Page.

Demo: https://emsifa.github.io/api-wilayah-indonesia

Apa yang dimaksud API statis?

API statis adalah API yang endpoint-nya terdiri dari file statis.

Keuntungan API statis?

  • Dapat dihosting pada static file hosting seperti Github Page, Netlify, dsb.
  • Proses lebih cepat karena tidak membutuhkan server-side scripting.

Bagaimana cara kerjanya?

  • Daftar provinsi, kab/kota, kecamatan, kelurahan/desa disimpan pada folder data berupa file csv (agar mudah diedit).
  • Kemudian script generate.php dijalankan. Script ini akan membaca file csv didalam folder data, kemudian men-generate ribuan endpoint (file) kedalam folder static/api.
  • API siap 'dihidangkan'.

Saya mau hosting di Github saya sendiri, bagaimana caranya?

  • Klik fork di pojok kanan atas.
  • Pada halaman forking, HAPUS CENTANG "Copy the master branch only".
  • Klik "Create Fork".
  • Setelah selesai di Fork, klik Settings (bukan setting account, tapi setting repository).
  • Klik menu "Pages" untuk masuk ke menu pengaturan GitHub Pages.
  • Pada menu pengaturan GitHub Pages:
    • Pilih Source: Deploy from a Branch
    • Branch: gh-pages
    • Direktori: /root
    • Klik Save
  • Tunggu beberapa menit (5-10 menitan), kembali ke halaman home repository (https://github.com/usernamekamu/api-wilayah-indonesia).
  • Kalau halaman sudah terdeploy, di bagian kanan halaman, akan muncul informasi "Environments". Kalau belum tunggu lagi beberapa menit, lalu refresh.
  • Kalau sudah muncul informasi Environmentsnya, klik bagian "πŸš€ github-pages".
  • Di halaman Deployments, klik "View Deployment" untuk melihat halaman yang berhasil terdeploy.

ENDPOINTS

1. Mengambil Daftar Provinsi

GET https://emsifa.github.io/api-wilayah-indonesia/api/provinces.json

Contoh Response:

[
  {
    "id": "11",
    "name": "ACEH"
  },
  {
    "id": "12",
    "name": "SUMATERA UTARA"
  },
  ...
]

2. Mengambil Daftar Kab/Kota pada Provinsi Tertentu

GET https://emsifa.github.io/api-wilayah-indonesia/api/regencies/{provinceId}.json

Contoh untuk mengambil daftar kab/kota di provinsi Aceh (ID = 11):

GET https://emsifa.github.io/api-wilayah-indonesia/api/regencies/11.json

Contoh Response:

[
  {
    "id": "1101",
    "province_id": "11",
    "name": "KABUPATEN SIMEULUE"
  },
  {
    "id": "1102",
    "province_id": "11",
    "name": "KABUPATEN ACEH SINGKIL"
  },
  ...
]

3. Mengambil Daftar Kecamatan pada Kab/Kota Tertentu

GET https://emsifa.github.io/api-wilayah-indonesia/api/districts/{regencyId}.json

Contoh untuk mengambil daftar kecamatan di Aceh Selatan (ID = 1103):

GET https://emsifa.github.io/api-wilayah-indonesia/api/districts/1103.json

Contoh Response:

[
  {
    "id": "1103010",
    "regency_id": "1103",
    "name": "TRUMON"
  },
  {
    "id": "1103011",
    "regency_id": "1103",
    "name": "TRUMON TIMUR"
  },
  ...
]

4. Mengambil Daftar Kelurahan pada Kecamatan Tertentu

GET https://emsifa.github.io/api-wilayah-indonesia/api/villages/{districtId}.json

Contoh untuk mengambil daftar kelurahan di Trumon (ID = 1103010):

GET https://emsifa.github.io/api-wilayah-indonesia/api/villages/1103010.json

Contoh Response:

[
  {
    "id": "1103010001",
    "district_id": "1103010",
    "name": "KUTA PADANG"
  },
  {
    "id": "1103010002",
    "district_id": "1103010",
    "name": "RAKET"
  },
  ...
]

5. Mengambil Data Provinsi berdasarkan ID Provinsi

GET https://emsifa.github.io/api-wilayah-indonesia/api/province/{provinceId}.json

Contoh untuk mengambil data provinsi Aceh (ID = 11):

GET https://emsifa.github.io/api-wilayah-indonesia/api/province/11.json

Contoh Response:

{
  "id": "11",
  "name": "ACEH"
}

6. Mengambil Data Kab/Kota berdasarkan ID Kab/Kota

GET https://emsifa.github.io/api-wilayah-indonesia/api/regency/{regencyId}.json

Contoh untuk mengambil data kabupaten Aceh Selatan (ID = 1103):

GET https://emsifa.github.io/api-wilayah-indonesia/api/regency/1103.json

Contoh Response:

{
  "id": "1103",
  "province_id": "11",
  "name": "KABUPATEN ACEH SELATAN"
}

7. Mengambil Data Kecamatan berdasarkan ID Kecamatan

GET https://emsifa.github.io/api-wilayah-indonesia/api/district/{districtId}.json

Contoh untuk mengambil data kecamatan Trumon Timur (ID = 1103011):

GET https://emsifa.github.io/api-wilayah-indonesia/api/district/1103011.json

Contoh Response:

{
  "id": "1103011",
  "regency_id": "1103",
  "name": "TRUMON TIMUR"
}

8. Mengambil Data Kelurahan berdasarkan ID Kelurahan

GET https://emsifa.github.io/api-wilayah-indonesia/api/village/{villageId}.json

Contoh untuk mengambil data kelurahan Jambo Dalem (ID = 1103011010):

GET https://emsifa.github.io/api-wilayah-indonesia/api/village/1103011010.json

Contoh Response:

{
  "id": "1103011010",
  "district_id": "1103011",
  "name": "JAMBO DALEM"
}

LIMITASI

Karena API ini dihosting di Github Page, Github Page sendiri memberikan batasan bandwith 100GB/bulan. Rata-rata endpoint disini memiliki ukuran 1KB/endpoint, jadi kurang lebih request yang dapat digunakan adalah 100.000.000 request per bulan, atau sekitar 3.000.000 request/hari.

Karena limitasi ini, disarankan untuk hosting API ini di github kamu sendiri.

Untuk lebih detail tentang limitasi Github Page, bisa dilihat disini.

More Repositories

1

tailwind-pos

Point of sales application built with tailwind.css and alpine.js
HTML
199
star
2

al-ihsan.app

TypeScript
65
star
3

validasaur

Deno validation library
TypeScript
45
star
4

contoh-graphql-php-mysql

Contoh GraphQL pada PHP dengan MySQL dan PDO
PHP
24
star
5

laci-db

PHP flat file JSON DBMS.
PHP
19
star
6

Block

PHP Native Template System Inspired by Laravel Blade
PHP
15
star
7

evo

Evolve your Laravel code
PHP
14
star
8

rakit-framework

another micro-php framework, currently still development
PHP
9
star
9

visual-hashing-yew

Visual Hashing implementation in Yew (WebAssembly)
Rust
9
star
10

stuble

Command line application to simplify working with stubs
PHP
5
star
11

bytefmt

Rust utility to parse byte string into bytes count and vice versa.
Rust
5
star
12

kekinian

Framework PHP kekinian
PHP
4
star
13

random-image

Laravel helper to store random image from LoremFlickr, Unsplash, etc.
PHP
4
star
14

emsifa.github.io

blog
HTML
4
star
15

rakit-cli

Simple PHP CLI app
PHP
4
star
16

cronmu

Form yang memahami CRON kamu
JavaScript
3
star
17

bang

8KB PHP Framework untuk pelajar yang takut menggunakan OOP atau framework MVC untuk tugas akhirnya.
PHP
2
star
18

jakarta-covid-19-heatmap

Covid-19 heatmap in Jakarta, Indonesia
Vue
2
star
19

route-generator

Laravel 4.2 Route and Route Controller Generator
PHP
1
star
20

ReflectionMysql

PHP library for reflecting MySQL database
PHP
1
star
21

evo-benchmark

Laravel Evo application for benchmarking github.com/emsifa/evo
PHP
1
star
22

route-annotation

Laravel 5 route annotation with generator for transforming route annotation into Laravel standart routing
PHP
1
star
23

stuble-examples

Example stubs files
1
star
24

backuper

PHP Backuper to backup database and files to any cloud storage
PHP
1
star
25

vidio-dl

vidio.com video downloader using golang
Go
1
star
26

simple-pdf

PHP Simple PDF Maker, currently its just refactored version of FPDF
PHP
1
star