Search Domestic Destination
Overviewβ
The Search Domestic Destination endpoint allows you to retrieve destination data for domestic shipments using the RajaOngkir integration. This is typically used to populate dropdowns or validate destination locations before calculating shipping costs or creating shipments.
It supports searching by value (city
, district
, subdistrict
, or zip_code
) and is essential for ensuring accurate shipping data entry in e-commerce platforms and logistics systems.
Key Featureβ
-
β Real-time destination lookup
Instantly retrieve location data across Indonesia based on value params. -
π Multi-level location support
Returns province, city, district, subdistrict, and zip code information in a single query. -
π Flexible search
Search using partial names or keywords β ideal for autocomplete fields. -
β‘ Optimized for performance
Lightweight endpoint designed to be used on page loads or form interactions.
How it Worksβ
-
Send a POST request to the endpoint with a
search
payload:- This keyword may include city names like
"jakarta"
or"bandung"
, or subdistricts like"kemayoran"
.
- This keyword may include city names like
-
The API returns a list of matched locations based on the keyword:
- Each result includes
id
,label
,province
,city
,district
,subdistrict
, andzip_code
.
- Each result includes
-
Use the returned
id
when calculating shipping cost.
Request Bodyβ
- cURL
- JavaScript
- PHP
- GoLang
- Node
curl --location 'https://rajaongkir.komerce.id/api/v1/destination/domestic-destination?search={{search_location}}&limit=999&offset=999' \
--header 'key: inputapikey'
const myHeaders = new Headers();
myHeaders.append("key", "inputapikey");
const requestOptions = {
method: "GET",
headers: myHeaders,
redirect: "follow"
};
fetch("https://rajaongkir.komerce.id/api/v1/destination/domestic-destination?search={{search_location}}&limit=999&offset=999", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://rajaongkir.komerce.id/api/v1/destination/domestic-destination?search={{search_location}}&limit=999&offset=999',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'key: inputapikey'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://rajaongkir.komerce.id/api/v1/destination/domestic-destination?search={{search_location}}&limit=999&offset=999"
method := "GET"
client := &http.Client {
}
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("key", "inputapikey")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
const axios = require('axios');
let config = {
method: 'get',
maxBodyLength: Infinity,
url: 'https://rajaongkir.komerce.id/api/v1/destination/domestic-destination?search={{search_location}}&limit=999&offset=999',
headers: {
'key': 'inputapikey'
}
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
Query Parameterβ
Headersβ
Key | Type | Description |
---|---|---|
key * | string | this Value contain an secret APIKEY identic for Shipping Cost API |
Query Paramsβ
Key | Type | Description |
---|---|---|
search * | string | This parameter is used to search for the intended area, can use the search for city names, sub-districts, villages, and postal codes. |
limit | int | The maximum number of rows (or records) to be returned by the query. |
offset | int | This is often used with LIMIT to limit query results in "pages" or "sections". |
For each header and parameter that has a *
sign, it is a parameter that must be Required when making a request, otherwise there will be a system error that will warn the user regarding the request made.
Responseβ
Response Structureβ
Key | Value (Description) |
---|---|
meta.message | Response for searching address. |
meta.code | Any response have different code. |
meta.status | Boolean status for checking address. |
data[].id | A uniqe id that is used as a parameter in the shipping cost. |
data[].label | Full format for delivery location. |
data[].province_name | Name of the search province |
data[].city_name | Name of the search city |
data[].district_name | Name of the search district |
data[].subdistrict_name | Name of the search subdistrict |
data[].zip_code | Name of the search zip code |
Success Respons for Search Domestics Destinationβ
{
"meta": {
"message": "Success Get Domestic Destinations",
"code": 200,
"status": "success"
},
"data": [
{
"id": {{ id_location }},
"label": "{{ label_location }}",
"province_name": "{{ province_location }}",
"city_name": "{{ city_location }}",
"district_name": "{{ distric_location }}",
"subdistrict_name": "{{ subdistrict_location }}",
"zip_code": "{{ zipcode_location }}"
}
]
}
Error Respons for Search Domestic Destinationβ
{
"meta": {
"message": "Domestic Destinations Data not found",
"code": 404,
"status": "error"
},
"data": null
}
Error Codeβ
Code | Status | Description | How to Fix |
---|---|---|---|
200 | Success | ||
404 | Error | Domestic Destinations Data not found | Make sure the name of the city, sub-district, village, or zip code you are looking for is correct. |
422 | Error | Parameter Missing | Make sure the required parameters are given when requesting data. |
500 | Error | Server Error |
Tips to Avoid Errorβ
- β
Always validate the value input
Ensure it is a non-empty string. Avoid sending numeric or symbol-only strings. - π Debounce user input on the frontend
If youβre using this for search-as-you-type, add a debounce delay to reduce API calls. - π¦ Cache popular destination results
For performance improvement, cache results for frequent searches (like βJakartaβ). - β Avoid calling the endpoint without a request location
Requests with an empty or missing request will return an error or no data. - π Set the Key header
Donβt forget to include your APIKEY in the header.