Get List of Provinsi
Fetches a list of provinces.
Endpoint
https://api.wilayah-nusantara.id
or, if running on local
http://localhost:1945
GET /provinsi
Query Params
Filtering
name
: string (optional)
Name of province. Uses a LIKE
SQL Query behind the scenes. This results in province name substring matches being returned as well. Oh, and it's case insensitive.
code
: string (optional)
Area code of a province.
Pagination
page
: number (optional)
Page number to be fetched. This will have a default value of 1
when a value is not given.
limit
: number (optional)
Number of data to be fetched inside a single page. This will have a default value of 10
when a value is not given.
Sorting
Not yet supported. Very open to contributions if you want to add this feature 😀.
Responses
Meta
We provide a meta
object for paginable response data lists. They should be self explanatory, however here's a brief explanation.
limit
: The number maximum total data in a single page.page
: The current page.total
: The number of total data that matches the given filters. Not just the number of data present in a single page.
200 (success)
GET https://api.wilayah-nusantara.id/provinsi?name=ban
{
"data": [
{
"code": "19",
"province": "KEPULAUAN BANGKA BELITUNG"
},
{
"code": "36",
"province": "BANTEN"
}
],
"meta": {
"limit": 10,
"page": 1,
"total": 2
}
}
Filters not matching any data will still result in a successful (200)
response. However the data
object will be empty.
Using the code
query parameter (200)
When using the code
parameter, the response will be a singular object containing the province data itself. This was done because code
is a unique property that only 1 province can have.
GET https://api.wilayah-nusantara.id/provinsi?code=36
{
"code": "36",
"province": "BANTEN"
}
If no record matches the code
parameter, a null
object will be returned as
a response.
500 (server error)
{
"statusCode": 500,
"message": "Internal server error"
}