Calculate International Cost
Overview
The Calculate International Cost endpoint allows users to get shipping rates for international deliveries by specifying Indonesian origin, destination country, weight, courier, and price. This is useful for merchants or platforms that ship products overseas and need to provide accurate shipping costs to end customers before checkout.
This endpoint helps users compare multiple courier options based on price and estimated delivery time for international shipments.
Key Feature
- 🌍 Supports International Shipping Calculation
- 📦 Based on Weight, Origin City, and Destination Country
- 🚚 Courier Selection Flexibility
- 💰 Returns Pricing and Estimated Delivery Time
How it Works
- The client sends a POST request with required information
- RajaOngkir API processes the request using international rate database.
- A list of shipping options is returned.
Request Body
- cURL
- JavaScript
- PHP
- GoLang
- Node
curl --location 'https://rajaongkir.komerce.id/api/v1/calculate/international-cost' \
--header 'key: inputapikey' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'courier={{ courier }}' \
--data-urlencode 'origin={{ origin_id }}' \
--data-urlencode 'destination={{ destination_id }}' \
--data-urlencode 'weight={{ weight }}' \
--data-urlencode 'price={{ sort_price }}'
const myHeaders = new Headers();
myHeaders.append("key", "inputapikey");
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
const urlencoded = new URLSearchParams();
urlencoded.append("courier", "{{ courier }}");
urlencoded.append("origin", "{{ origin_id }}");
urlencoded.append("destination", "{{ destination_id }}");
urlencoded.append("weight", "{{ weight }}");
urlencoded.append("price", "{{ sort_price }}");
const requestOptions = {
method: "POST",
headers: myHeaders,
body: urlencoded,
redirect: "follow"
};
fetch("https://rajaongkir.komerce.id/api/v1/calculate/international-cost", 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/calculate/international-cost',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => 'courier=%7B%7B%20courier%20%7D%7D&origin=%7B%7B%20origin_id%20%7D%7D&destination=%7B%7B%20destination_id%20%7D%7D&weight=%7B%7B%20weight%20%7D%7D&price=%7B%7B%20sort_price%20%7D%7D',
CURLOPT_HTTPHEADER => array(
'key: inputapikey',
'Content-Type: application/x-www-form-urlencoded'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://rajaongkir.komerce.id/api/v1/calculate/international-cost"
method := "POST"
payload := strings.NewReader("courier=%7B%7B%20courier%20%7D%7D&origin=%7B%7B%20origin_id%20%7D%7D&destination=%7B%7B%20destination_id%20%7D%7D&weight=%7B%7B%20weight%20%7D%7D&price=%7B%7B%20sort_price%20%7D%7D")
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("key", "inputapikey")
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
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');
const qs = require('qs');
let data = qs.stringify({
'courier': '{{ courier }}',
'origin': '{{ origin_id }}',
'destination': '{{ destination_id }}',
'weight': '{{ weight }}',
'price': '{{ sort_price }}'
});
let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://rajaongkir.komerce.id/api/v1/calculate/international-cost',
headers: {
'key': 'inputapikey',
'Content-Type': 'application/x-www-form-urlencoded'
},
data : data
};
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 |
Body x-www-form-urlencode
Key | Type | Description |
---|---|---|
origin * | int | this Value containt an id during Search International Destinations |
destination * | int | this Value containt an id during Search International Destinations |
weight * | int | this Value containt an a package weight with grams estimated |
courier * | string | this Value contain an Courier Name |
price | boolean | this Value Contain an boolean value, lowest or highest shipping cost |
danger
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[].name | Information about availability Courier Name |
data[].code | Information about availability Code of Courier |
data[].service | Information about availability Service of Courier |
data[].description | Description about Courier |
data[].currency | Information about availability Currency of Courier |
data[].cost | Information about Courier Service Cost |
data[].etd | Information about estimated time of courier delivery |
data[].currency_updated_at | Information about Updated time for Currency Value |
data[].currency_value | Information about Currency Kurs Updated |
Success Respons for Searching International Cost
{
"meta": {
"message": "Success Calculate International Shipping Cost",
"code": 200,
"status": "success"
},
"data": [
{
"name": "{{ courier.name }}",
"code": "{{ courier.code }}",
"service": "{{ courier.service }}",
"description": "{{ courier.desc }}",
"currency": "{{ availability.currency }}",
"cost": {{ shipping_cost }},
"etd": "{{ estimated_time_delivery }}",
"currency_updated_at": "{{ information_updated_currency }}",
"currency_value": {{ currency_kurs }}
}
]
}
Error Respons for Searching International Cost
{
"meta": {
"message": "{{ message }}",
"code": {{ code }},
"status": "{{ status }}"
},
"data": null
}
Status Code
Code | Status | Description | How to Fix |
---|---|---|---|
200 | Success | ||
400 | Error | Calculate International Shipping Cost not found | This error is unavoidable because the courier may not be able to provide the desired data. |
400 | Error | Missing Params | Make sure the request parameters that are sent match the required parameters. |
422 | Error | Invalid Courier | Make sure the courier code entered is correct according to the courier code guide available for checking. |
Tips to Avoid Error
- ✅ Ensure the
origin
id
is correct — use the RajaOngkir Search Destination endpoint to get a validid
. - 🌐 Use a valid country code for the
destination
. - ⚖️ Weight is mandatory and should be greater than zero (in grams).
- 🚫 Courier must support international shipments — not all couriers are available.
- 🛡️ Authenticate with the correct API Key or the request will be rejected.