{"id":15454564,"url":"https://github.com/dekiakbar/indonesia-regions-php-client","last_synced_at":"2025-04-22T08:19:32.471Z","repository":{"id":53592346,"uuid":"281455260","full_name":"dekiakbar/indonesia-regions-php-client","owner":"dekiakbar","description":"This package will retrieve and extract regions of Indonesia from https://bps.go.id","archived":false,"fork":false,"pushed_at":"2021-03-22T16:13:54.000Z","size":3439,"stargazers_count":6,"open_issues_count":0,"forks_count":10,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-20T00:53:18.569Z","etag":null,"topics":["api","bps","indonesia","indonesia-regions","php","region"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dekiakbar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-21T16:57:02.000Z","updated_at":"2024-05-29T16:36:20.000Z","dependencies_parsed_at":"2022-08-21T06:10:16.200Z","dependency_job_id":null,"html_url":"https://github.com/dekiakbar/indonesia-regions-php-client","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dekiakbar%2Findonesia-regions-php-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dekiakbar%2Findonesia-regions-php-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dekiakbar%2Findonesia-regions-php-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dekiakbar%2Findonesia-regions-php-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dekiakbar","download_url":"https://codeload.github.com/dekiakbar/indonesia-regions-php-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249834786,"owners_count":21331988,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","bps","indonesia","indonesia-regions","php","region"],"created_at":"2024-10-01T22:04:02.832Z","updated_at":"2025-04-20T00:53:23.967Z","avatar_url":"https://github.com/dekiakbar.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Indonesia Regions PHP Client\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://travis-ci.com/github/dekiakbar/indonesia-regions-php-client\"\u003e\u003cimg src=\"https://travis-ci.com/dekiakbar/indonesia-regions-php-client.svg?branch=master\" alt=\"Build Status\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/dekiakbar/indonesia-regions-php-client\"\u003e\u003cimg src=\"https://poser.pugx.org/dekiakbar/indonesia-regions-php-client/version\" alt=\"Stable Version\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/dekiakbar/indonesia-regions-php-client\"\u003e\u003cimg src=\"https://poser.pugx.org/dekiakbar/indonesia-regions-php-client/v/unstable\" alt=\"Unstable Version\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/dekiakbar/indonesia-regions-php-client\"\u003e\u003cimg src=\"https://github.styleci.io/repos/281455260/shield?branch=master\" alt=\"StyleCI\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/dekiakbar/indonesia-regions-php-client/blob/master/LICENSE\"\u003e\u003cimg src=\"https://poser.pugx.org/dekiakbar/indonesia-regions-php-client/license\" alt=\"License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n## About Indonesia Regions PHP Client\n\n\u003e This package can be used to retrieve provinces, cities, districts and villages data from [BPS]( https://bps.go.id).\n**Note:** Wherever you use this package please specify [BPS]( https://bps.go.id) as the data source.\n\n## Table of Contents\n\n- [Prerequisites](#prerequisites)\n- [Installation](#installation)\n- [Usage](#usage)\n- [License](#license)\n\n---\n\n## Prerequisites\n\nBefore you install this package, make sure that the requirements below are met\n\n```\nPHP \u003e= 7.2\next-json\next-curl\ndocker (optional)\ndocker-compose (optional)\n```\n\n---\n\n## Development (Docker)\nFor development you can use docker container for this project, here are step to reproduce docker env on your local env :\n- Clone this repository: `git clone https://github.com/dekiakbar/indonesia-regions-php-client.git`\n- Navigate to project directory : `cd indonesia-regions-php-client`\n- Snd run : `docker-compose up -d`\n- Wait a few minutes, the image for docker will build automatic, after the build has been done you will get an image with the name **indonesia-regions-php-client_app** and a container with the name **indonesia-regions-php-client_app_1** and **indonesia-regions-php-client_mysql_1**.\n- Check if the container are exit, you can run : `docker ps -a`\n- If the container is not running, you can run : `docker start indonesia-regions-php-client_app_1` and `docker start indonesia-regions-php-client_mysql_1`\n- You can run interactive shell (SSH) : `docker exec -it indonesia-regions-php-client_app_1 /bin/bash`\n- **NOTE:**\n  - The **indonesia-regions-php-client_app_1** container is used to mount the directory project.\n  - The **indonesia-regions-php-client_mysql_1** container is used to save the database from project.\n  - The default docker workdir is **app** for **indonesia-regions-php-client_app_1** container.\n  - The **app** directory is mounted from **indonesia-regions-php-client** host directory, so if you edit the file inside **indonesia-regions-php-client** in the host Operating system, the file inside docker will be changed or vice versa, the reason I made docker container mount the project root a.k.a **indonesia-regions-php-client** to the app because I am too lazy to mount file from docker, so if docker mount file from **indonesia-regions-php-client** root directory I can simple edit the file directly from my favorite IDE :stuck_out_tongue_closed_eyes:\n\n---\n\n## Installation\n\n- `$ composer require dekiakbar/indonesia-regions-php-client`\n- And You're done.\n\n---\n\n## Usage\n\n- You can pass the parameter to the method, All of this package has 3 mode :\n- For **BPS** and **POS** mode you can use **BPS Id/Code** to retrieve province / city / subdistrict / village data. But you **Can Not** use **BPS Id/Code** to retrieve province / city / subdistrict / village data if you use **dagri** mode, please use **dagri Id/code** to retrieve province / city / subdistrict / village data. \n- If mode is **NULL**, then the method will use default mode, default mode is **bps**.\n- **bps** : only return : **kode** and **nama** of province / city / subdistrict / village.\n- **dagri** : return : **kode_bps**, **nama_bps**, **kode_dagri**, **nama_dagri** of province / city / subdistrict / village.\n- **pos** : return : **kode_bps**, **nama_bps**, **kode_pos**, **nama_pos** of province / city / subdistrict / village.\n\n## Note\n- **Not all method always return `list` and `detail` object, on some method only return `list` or `detail` you must check it again before you use the response**.\n- If you just need the data (not planing to use this API), just import the Database Dump on `export` folder, extract `indonesia_regions_pos.tar.gz` and import to your database. \n- If you want to retrieve data with mode **Dagri** please fill **Parent Id** (Provinde Id / City Id / Subdistrict Id) with valid data. **Parent Id for POS and Dagri are different**. You can get the city Id `(kode)` from `$region-\u003egetCityListByProvinceId('pos',$provinceId)-\u003elist`.\n- please remeber if you want fetch any data you must use parent Id (province Id / City Id / Subdistrict Id) from  **list** collection, **NOT** from detail collection **(If you use ID from detail it will work but you will get duplicate data)**.\n\n- #### Retrieve All province data\n\n    ```php\n    require_once __DIR__ . '/vendor/autoload.php';\n    use Dekiakbar\\IndonesiaRegionsPhpClient\\Region;\n    $region = new Region();\n    print_r( $region-\u003egetAllProvince('pos') );\n\n    // will return something like :\n    stdClass Object\n    (\n        [detail] =\u003e Array\n            (\n                [0] =\u003e stdClass Object\n                    (\n                        [kode_bps] =\u003e 11\n                        [nama_bps] =\u003e ACEH\n                        [kode_pos] =\u003e 20000\n                        [nama_pos] =\u003e ACEH\n                    )\n\n                [1] =\u003e stdClass Object\n                    (\n                        [kode_bps] =\u003e 51\n                        [nama_bps] =\u003e BALI\n                        [kode_pos] =\u003e 80000\n                        [nama_pos] =\u003e BALI\n                    )\n            )\n        [list] =\u003e Array\n            (\n                [0] =\u003e stdClass Object\n                    (\n                        [kode] =\u003e 11\n                        [nama] =\u003e ACEH\n                    )\n\n                [1] =\u003e stdClass Object\n                    (\n                        [kode] =\u003e 12\n                        [nama] =\u003e SUMATERA UTARA\n                    )\n            )\n    )\n\n    ```\n\n- #### Retrieve City List By Province Id\n\n    ```php\n    require_once __DIR__ . '/vendor/autoload.php';\n    use Dekiakbar\\IndonesiaRegionsPhpClient\\Region;\n    $region = new Region();\n\n    // province Id from $region-\u003egetAllProvince('bps')\n    $provinceId = 32;\n    print_r( \n        $region-\u003egetCityListByProvinceId('pos',$provinceId) \n    );\n\n    // will return something like :\n    stdClass Object\n    (\n        [detail] =\u003e Array\n            (\n                [0] =\u003e stdClass Object\n                    (\n                        [kode_bps] =\u003e 3204\n                        [nama_bps] =\u003e BANDUNG\n                        [kode_pos] =\u003e 40300\n                        [nama_pos] =\u003e BANDUNG\n                    )\n\n                [1] =\u003e stdClass Object\n                    (\n                        [kode_bps] =\u003e 3273\n                        [nama_bps] =\u003e BANDUNG\n                        [kode_pos] =\u003e 40100\n                        [nama_pos] =\u003e KOTA BANDUNG\n                    )\n            )\n        [list] =\u003e Array\n            (\n                [0] =\u003e stdClass Object\n                    (\n                        [kode] =\u003e 3201\n                        [nama] =\u003e BOGOR\n                    )\n\n                [1] =\u003e stdClass Object\n                    (\n                        [kode] =\u003e 3202\n                        [nama] =\u003e SUKABUMI\n                    )\n            )\n    )\n    ```\n\n- #### Retrieve Subdistrict List By City Id\n\n    ```php\n    require_once __DIR__ . '/vendor/autoload.php';\n    use Dekiakbar\\IndonesiaRegionsPhpClient\\Region;\n    $region = new Region();\n\n    // POS\n    // city Id from $region-\u003egetCityListByProvinceId('pos',$provinceId)-\u003elist\n    $cityId = 3273;\n    print_r( \n        $region-\u003egetSubdistrictListByCityId('pos',$cityId)\n    );\n\n    // will return something like :\n    stdClass Object\n    (\n        [detail] =\u003e Array\n            (\n                [0] =\u003e stdClass Object\n                    (\n                        [kode_bps] =\u003e 3273180\n                        [nama_bps] =\u003e ANDIR\n                        [kode_pos] =\u003e 40181\n                        [nama_pos] =\u003e Andir\n                    )\n\n                [1] =\u003e stdClass Object\n                    (\n                        [kode_bps] =\u003e 3273180\n                        [nama_bps] =\u003e ANDIR\n                        [kode_pos] =\u003e 40182\n                        [nama_pos] =\u003e Andir\n                    )\n            )\n        [list] =\u003e Array\n            (\n                [0] =\u003e stdClass Object\n                    (\n                        [kode] =\u003e 3273010\n                        [nama] =\u003e BANDUNG KULON\n                    )\n\n                [1] =\u003e stdClass Object\n                    (\n                        [kode] =\u003e 3273020\n                        [nama] =\u003e BABAKAN CIPARAY\n                    )\n            )\n    )\n\n\n\n    // Dagri\n    // city Id from $region-\u003egetCityListByProvinceId('dagri',$provinceId)-\u003elist\n    $cityId = '32.73';\n    print_r(\n        $region-\u003egetSubdistrictListByCityId('dagri',$cityId)\n    );\n\n    // will return something like :\n    stdClass Object\n    (\n        [detail] =\u003e Array\n            (\n                [0] =\u003e stdClass Object\n                    (\n                        [kode_bps] =\u003e 3273050\n                        [nama_bps] =\u003e ASTANAANYAR\n                        [kode_dagri] =\u003e 32.73.10\n                        [nama_dagri] =\u003e ASTANA ANYAR\n                    )\n\n                [1] =\u003e stdClass Object\n                    (\n                        [kode_bps] =\u003e 3273120\n                        [nama_bps] =\u003e UJUNG BERUNG\n                        [kode_dagri] =\u003e 32.73.26\n                        [nama_dagri] =\u003e UJUNGBERUNG\n                    )\n            )\n        [list] =\u003e Array\n            (\n                [0] =\u003e stdClass Object\n                    (\n                        [kode] =\u003e 32.73.01\n                        [nama] =\u003e Sukasari\n                    )\n\n                [1] =\u003e stdClass Object\n                    (\n                        [kode] =\u003e 32.73.02\n                        [nama] =\u003e Coblong\n                    )\n            )\n    )\n    ```\n\n- #### Retrieve Village List By Subdistrict Id\n\n    ```php\n    require_once __DIR__ . '/vendor/autoload.php';\n    use Dekiakbar\\IndonesiaRegionsPhpClient\\Region;\n    $region = new Region();\n    // POS\n    // subdistrict Id from $region-\u003egetSubdistrictListByCityId('pos',$cityId)-\u003elist\n    $subdistrictId = 3273010;\n    print_r( \n        $region-\u003egetVillageListBySubdistrictId('pos',$subdistrictId)\n    );\n\n    // will return something like :\n    stdClass Object\n    (\n        [detail] =\u003e Array\n            (\n                [0] =\u003e stdClass Object\n                    (\n                        [kode_bps] =\u003e 3273010005\n                        [nama_bps] =\u003e CARINGIN\n                        [kode_pos] =\u003e 40212\n                        [nama_pos] =\u003e Caringin\n                    )\n\n                [1] =\u003e stdClass Object\n                    (\n                        [kode_bps] =\u003e 3273010007\n                        [nama_bps] =\u003e CIBUNTU\n                        [kode_pos] =\u003e 40212\n                        [nama_pos] =\u003e Cibuntu\n                    )\n            )\n        [list] =\u003e Array\n            (\n                [0] =\u003e stdClass Object\n                    (\n                        [kode] =\u003e 3273010001\n                        [nama] =\u003e GEMPOL SARI\n                    )\n\n                [1] =\u003e stdClass Object\n                    (\n                        [kode] =\u003e 3273010002\n                        [nama] =\u003e CIGONDEWAH KALER\n                    )\n            )\n    )\n\n    // Dagri\n    // subdistrict Id from $region-\u003egetSubdistrictListByCityId('dagri',$cityId)-\u003elist\n    $subdistrictId = '32.73.10';\n    print_r( \n        $region-\u003egetVillageListBySubdistrictId('dagri',$subdistrictId) \n    );\n\n    // will return something like :\n    stdClass Object\n    (\n        [detail] =\u003e Array\n            (\n                [0] =\u003e stdClass Object\n                    (\n                        [kode_bps] =\u003e 3273050001\n                        [nama_bps] =\u003e KARASAK\n                        [kode_dagri] =\u003e 32.73.10.1001\n                        [nama_dagri] =\u003e KARASAK\n                    )\n\n                [1] =\u003e stdClass Object\n                    (\n                        [kode_bps] =\u003e 3273050002\n                        [nama_bps] =\u003e PELINDUNG HEWAN\n                        [kode_dagri] =\u003e 32.73.10.1006\n                        [nama_dagri] =\u003e PELINDUNG HEWAN\n                    )\n            )\n    )\n\n    ```\n\n- #### Retrieve ISO 3166-2 code for province\n    \u003e **Note : This method only for province**\n    ```php\n    require_once __DIR__ . '/vendor/autoload.php';\n    use Dekiakbar\\IndonesiaRegionsPhpClient\\Region;\n    $region = new Region();\n\n    // Province code get from $region-\u003egetAllProvince('bps')-\u003elist\n    $provinceId = 32;\n    print_r( \n            $region-\u003egetIsoCode($provinceId) \n    );\n\n    // will return String, something like :\n    ID-JB\n\n    ```\n---\n\n## License\n\n[![License](https://poser.pugx.org/dekiakbar/indonesia-regions-php-client/license)](//packagist.org/packages/dekiakbar/indonesia-regions-php-client)\n\n- **[MIT license](https://github.com/dekiakbar/indonesia-regions-php-client/blob/master/LICENSE)**\n- Copyright 2020 © \u003ca href=\"https://github.com/dekiakbar\" target=\"_blank\"\u003eDeki Akbar\u003c/a\u003e.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdekiakbar%2Findonesia-regions-php-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdekiakbar%2Findonesia-regions-php-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdekiakbar%2Findonesia-regions-php-client/lists"}