Calculate
Overview
The Calculate Endpoint is designed to help users retrieve accurate shipping cost estimates based on various factors such as origin, destination, and package weight. This endpoint is a crucial part of the Komship Delivery API, which integrates six courier services to facilitate seamless shipping operations.
By leveraging this endpoint, users can efficiently determine shipping fees without needing manual calculations, ensuring a faster, error-free, and automated process.
Key Feature
✅ Multi-Courier Support – Access shipping costs from six courier services in one request.
✅ Automated Data Validation – Ensures accurate calculations based on verified origin & destination IDs.
✅ Decimal Weight Handling – Supports precise weight calculations with automatic rounding.
✅ Seamless API Workflow – Integrates with the Search Destination Endpoint for smooth data transition.
How it Works
Required Data for Simulate Calculation
To perform a shipping cost calculation, users must provide:
- Origin
ID
– Obtained from the Search Destination Endpoint. - Destination
ID
– Also retrieved from the Search Destination Endpoint. - Origin and Destination
pinpoint
- If you want to deliver you order into customer using the instant courier, you must filled this param's to check availability for instant delivery or maybe a one of regular shipping needed - Package
weight
– Expressed in kilograms (kg).
💡 Important: Incorrect origin or destination IDs will lead to inaccurate shipping costs. Always ensure the data is correct before making a request.
Handling Decimal Weights
Users often ask:
😕 “How does the system handle decimal weights?”
The Calculate Endpoint supports decimal weight values, which should be formatted using a dot (.) as the decimal separator. To comply with courier service standards, the system automatically rounds weights as needed, preventing errors and ensuring smooth validation.
API Processing & Response
Once all required data is submitted:
- The system validates the
origin
,destination
,pinpoint
, andweight
values. - The API fetches real-time shipping cost data from multiple courier services in our systems.
- A JSON response is returned, detailing available shipping options, prices, and simulate our store_order services for your maximize information.
Request Body
- cURL
- JavaScript
- PHP
- GoLang
- Node
curl --location 'https://api-sandbox.collaborator.komerce.id/tariff/api/v1/calculate?shipper_destination_id=31597&receiver_destination_id=46116&weight=1&item_value=300000&cod=yes&origin_pin_point=-7.279849431298132%2C109.35114360314475&destination_pin_point=-7.30585%2C109.36814' \
--header 'x-api-key: inputapikey'
const myHeaders = new Headers();
myHeaders.append("x-api-key", "inputapikey");
const requestOptions = {
method: "GET",
headers: myHeaders,
redirect: "follow"
};
fetch("https://api-sandbox.collaborator.komerce.id/tariff/api/v1/calculate?shipper_destination_id=31597&receiver_destination_id=46116&weight=1&item_value=300000&cod=yes&origin_pin_point=-7.279849431298132,109.35114360314475&destination_pin_point=-7.30585,109.36814", 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://api-sandbox.collaborator.komerce.id/tariff/api/v1/calculate?shipper_destination_id=31597&receiver_destination_id=46116&weight=1&item_value=300000&cod=yes&origin_pin_point=-7.279849431298132%2C109.35114360314475&destination_pin_point=-7.30585%2C109.36814',
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(
'x-api-key: inputapikey'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-sandbox.collaborator.komerce.id/tariff/api/v1/calculate?shipper_destination_id=31597&receiver_destination_id=46116&weight=1&item_value=300000&cod=yes&origin_pin_point=-7.279849431298132%2C109.35114360314475&destination_pin_point=-7.30585%2C109.36814"
method := "GET"
client := &http.Client {
}
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("x-api-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://api-sandbox.collaborator.komerce.id/tariff/api/v1/calculate?shipper_destination_id=31597&receiver_destination_id=46116&weight=1&item_value=300000&cod=yes&origin_pin_point=-7.279849431298132,109.35114360314475&destination_pin_point=-7.30585,109.36814',
headers: {
'x-api-key': 'inputapikey'
}
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
Query Parameter
Headers
Key | Type | Description |
---|---|---|
x-api-key | string | this Value contain an secret APIKEY identic for Shipping API |
Query Parameters
Key | Type | Description |
---|---|---|
shipper_destination_id * | int | this Value containt an id during Search Destination |
receiver_destination_id * | int | this Value containt an id during Search Destination |
origin_pin_point * | string | this Value contain an a geolocation from origin latitude, longitude address |
destination_pin_point * | string | this Value contain an a geolocation from destination latitude, longitude address |
weight * | float | this Value is an Kilogram, use dot(.) for float value |
item_value * | int | this Value is an Item Price |
cod | boolean | this Value is containt an a boolean method (yes/no) method of shipping if cod=yes system will give response of Coverage Area or possibility to COD or not |
Additional information for the using origin or destination,
pin_point
is used to calculate the estimated shipping cost by using instant courier. Make surepin_point
data submitted is in accordance with the estimated delivery from the origin location to the destination.
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 |
---|---|
meta.message | Response for searching address |
meta.code | Any response have different code |
meta.status | Boolean status for checking address |
data.calculate_reguler | List of available couriers for regular delivery |
data.calculate_cargo | List of available couriers for cargo delivery |
data.calculate_instant | List of available couriers for instan or sameday delivery |
data.calculate_{{servicetype}}.shipping_name | Name of the courier that can be used for delivery of goods |
data.calculate_{{servicetype}}.service_name | The name of the courier delivery service that can be used to deliver goods |
data.calculate_{{servicetype}}.weight | Weight of goods from request |
data.calculate_{{servicetype}}.is_cod | COD delivery usage information |
data.calculate_{{servicetype}}.shipping_cost | Original shipping price |
data.calculate_{{servicetype}}.shipping_cashback | Discounted price on shipping costs |
data.calculate_{{servicetype}}.shipping_cost_net | Shipping cost price after discount |
data.calculate_{{servicetype}}.grandtotal | The total payment price that the seller gets |
data.calculate_{{servicetype}}.service_fee | Value of 2.8% of grand_total if the package is delivered using COD payment |
data.calculate_{{servicetype}}.net_income | Net income earned by the seller |
data.calculate_{{servicetype}}.etd | Estimated delivery time |
Success Respons for Calculate Price
{
"meta": {
"message": "Success Calculate Shipping",
"code": 200,
"status": "success"
},
"data": {
"calculate_reguler": [
{
"shipping_name": "NINJA",
"service_name": "Standard",
"weight": 5,
"is_cod": true,
"shipping_cost": 83000,
"shipping_cashback": 37350,
"shipping_cost_net": 45650,
"grandtotal": 383000,
"service_fee": 10724,
"net_income": 326626,
"etd": "-"
},
{
"shipping_name": "SAP",
"service_name": "SAPFlat",
"weight": 5,
"is_cod": true,
"shipping_cost": 46500,
"shipping_cashback": 0,
"shipping_cost_net": 46500,
"grandtotal": 346500,
"service_fee": 9702,
"net_income": 290298,
"etd": ""
},
{
"shipping_name": "JNE",
"service_name": "REG23",
"weight": 5,
"is_cod": true,
"shipping_cost": 80000,
"shipping_cashback": 20000,
"shipping_cost_net": 60000,
"grandtotal": 380000,
"service_fee": 10640,
"net_income": 309360,
"etd": "3-4 day"
},
{
"shipping_name": "SICEPAT",
"service_name": "REG",
"weight": 5,
"is_cod": true,
"shipping_cost": 76500,
"shipping_cashback": 22950,
"shipping_cost_net": 53550,
"grandtotal": 376500,
"service_fee": 10542,
"net_income": 312408,
"etd": "2-4 day"
},
{
"shipping_name": "IDEXPRESS",
"service_name": "STD",
"weight": 5,
"is_cod": true,
"shipping_cost": 135500,
"shipping_cashback": 33875,
"shipping_cost_net": 101625,
"grandtotal": 435500,
"service_fee": 12194,
"net_income": 321681,
"etd": "-"
},
{
"shipping_name": "LION",
"service_name": "REGPACK",
"weight": 5,
"is_cod": false,
"shipping_cost": 80000,
"shipping_cashback": 16000,
"shipping_cost_net": 64000,
"grandtotal": 380000,
"service_fee": 10640,
"net_income": 305360,
"etd": "3-5 day"
},
{
"shipping_name": "JNT",
"service_name": "EZ",
"weight": 5,
"is_cod": true,
"shipping_cost": 75000,
"shipping_cashback": 18750,
"shipping_cost_net": 56250,
"grandtotal": 375000,
"service_fee": 10500,
"net_income": 308250,
"etd": "-"
}
],
"calculate_cargo": [
{
"shipping_name": "SAP",
"service_name": "DRGREG",
"weight": 5,
"is_cod": true,
"shipping_cost": 52500,
"shipping_cashback": 15750,
"shipping_cost_net": 36750,
"grandtotal": 352500,
"service_fee": 9870,
"net_income": 305880,
"etd": "3-5 day"
},
{
"shipping_name": "JNE",
"service_name": "JTR23",
"weight": 5,
"is_cod": true,
"shipping_cost": 50000,
"shipping_cashback": 1250,
"shipping_cost_net": 48750,
"grandtotal": 350000,
"service_fee": 9800,
"net_income": 291450,
"etd": "3-4 day"
},
{
"shipping_name": "SICEPAT",
"service_name": "GOKIL",
"weight": 5,
"is_cod": true,
"shipping_cost": 60000,
"shipping_cashback": 3000,
"shipping_cost_net": 57000,
"grandtotal": 360000,
"service_fee": 10080,
"net_income": 292920,
"etd": "3-5 day"
},
{
"shipping_name": "IDEXPRESS",
"service_name": "Idtruck",
"weight": 5,
"is_cod": true,
"shipping_cost": 42500,
"shipping_cashback": 850,
"shipping_cost_net": 41650,
"grandtotal": 342500,
"service_fee": 9590,
"net_income": 291260,
"etd": "-"
},
{
"shipping_name": "LION",
"service_name": "BIGPACK",
"weight": 5,
"is_cod": false,
"shipping_cost": 90000,
"shipping_cashback": 18000,
"shipping_cost_net": 72000,
"grandtotal": 390000,
"service_fee": 10920,
"net_income": 307080,
"etd": "3-7 day"
}
],
"calculate_instant": [
{
"shipping_name": "GOSEND",
"service_name": "Instant",
"weight": 5,
"is_cod": false,
"shipping_cost": 9500,
"shipping_cashback": 0,
"shipping_cost_net": 9500,
"grandtotal": 309500,
"service_fee": 0,
"net_income": 300000,
"etd": "1-2 hours"
}
]
}
}
Error Respons for Calculate Price
- Missing Value
- Missing Item
{
"meta": {
"message": "Success Calculate Shipping",
"code": 200,
"status": "success"
},
"data": {
"calculate_reguler": [],
"calculate_cargo": [],
"calculate_instant": []
}
}
This response can occur if only the parameters shipper_destination_id
, receiver_destination_id
, origin_pin_point
, and destination_pin_point
are not filled in during the request.
{
"meta": {
"message": "Key: '{{ error.error }}",
"code": 422,
"status": "error"
},
"data": null
}
This kind of response can happen if there are missing parameters during the request.
Error Code
Code | Status | Description | How To Fix |
---|---|---|---|
400 | Bad request | The request parameter has an error | Check the desired request parameters again, this usually happens because there is a mismatch between the request and the expectations of the request that occurred. |
401 | Unauthorized | API key invalid or missing from parameter | Make sure your API key is valid using your Account |
422 | Unprocessable Entity | Keywoard parameter is missing | Add an valid keywoard parameter in your requested query. Parameter Request can't be null or missing |
500 | - | - | - |
Tips to Avoid Errors
Ensure required parameters are present:
shipper_destination_id
&receiver_destination_id
→ this value you can get from Search_destination EndPoint when you searching the origin or destination address using District/SubDistrict/PostalCode. This value can helping you to get more information about Regular or Cargo Shipping.origin_pin_point
&destination_pin_point
→ this value you can get from ThirdParty maps to ensure identic pinpoint for origin and destination address for using InstantDelivery like GoSend, etc.weight
→ the total weight of the items (in Calculate EndPoint this value using an grams).item_value
→ the total value of the items (in IDR currency), this value can helping you to understand when using store_order parameter and describe more value to using the service.