Skip to main content

Logistics Truecost | Climes API


Logistics API's are useful to calculate the truecost value of a single shipment that is being delivered via multi chain delivery process.

Request Parameters

Request Schema

This is the schema for the logistics truecost api. Each request payload requires queries

Queries Schema

Each queries object has a legs array which requires individual leg object.

NameDescriptionTypeOptional
legsThe legs denote the individual method of travel done via any of the vehicle type.array
required

Leg Schema

NameDescriptionTypeOptional
shipping_methodIts the type of vehicle used to send the shipment from Point A to B.
Enums :
SHIP
TRUCK_LIGHT
TRUCK_MEDIUM
TRUCK_HEAVY
FLIGHT
TRAIN
MOTORCYCLE
string
required
shipping_distanceIts the total distance in km that the shipment will travel for that particular shipping_method.
Default is set as 100 km.
numberoptional
shipping_weightIts the total weight of the shipment in ton that has to be sent via this shipping_method.
Default is set as 20 tonnes.
numberoptional
truck_capacityIts only applicable to shipping_method which are one of the following : TRUCK_LIGHT , TRUCK_MEDIUM , TRUCK_HEAVY. Its the maximum load bearing capacity of truck in tonnes.

Default values for truck_capacity of types are as below :
TRUCK_LIGHT : 1.75 tonnes
TRUCK_MEDIUM : 7.75 tonnes
TRUCK_HEAVY : 15 tonnes
numberoptional

Endpoint

/v3/logistics

Method

POST

Headers

{
'x-api-key': 'API_KEY',
'Content-Type': 'application/json'
}

Payload

{
"queries": {
"legs": [
{
"shipping_method": "SHIP",
"shipping_distance": 546,
"shipping_weight": 52
},
{
"shipping_method": "TRUCK_LIGHT",
"shipping_distance": 324,
"shipping_weight": 52,
"truck_capacity": 7
},
{
"shipping_method": "TRUCK_MEDIUM",
"shipping_distance": 324,
"shipping_weight": 52,
"truck_capacity": 7
},
{
"shipping_method": "TRUCK_HEAVY",
"shipping_distance": 43534,
"shipping_weight": 52,
"truck_capacity": 15
},
{
"shipping_method": "FLIGHT",
"shipping_distance": 2342,
"shipping_weight": 52
},
{
"shipping_method": "TRAIN",
"shipping_distance": 324,
"shipping_weight": 52
},
{
"shipping_method": "MOTORCYCLE",
"shipping_distance": 23,
"shipping_weight": 52
}
]
}
}

Response Parameters

Response Schema

NameDescriptionType
messageA human readable string describing response for the given request.string
truecostThis object contains the calculated truecost values in tonnes CO2e for the request.object
total_truecostThis object contains the calculated truecost values in tonnes CO2e for the request.number
legsContains the truecost values in tonnes CO2e of each shipping_method in the exact order of the request's legs.array
equivalentsThis object contains the equivalents for the calculated truecost values of legs in request.object
trash_collectedIts the total number of trash bags collected for recycle for the response's total_truecoststring
trees_plantedIts the total number of seedlings planted and grown for 10 years for the amount of response's total_truecoststring
lamps_collectedIts the total lamps' electricity saved for the response's total_truecoststring
caution

The error message is for your information, not the end users.
Please use the status codes and communicate the error to user accordingly
The API returns the first validation error that is encountered even if there are multiple errors with the request

Status Code

200

Response Data

The response will contain the truecost values in tonnes CO2e for each shipping_method as per the request order respectively.

{
"message": "Truecost calculated successfully",
"truecost": {
"total_truecost": 306.933,
"legs": [
0.458,
0.739,
1.427,
111.302,
192.804,
0.16,
0.043
],
"equivalents": {
"trash_collected": "13045",
"trees_planted": "5064",
"lamps_collected": "11633"
}
}
}
tip

Here the response will be in the same order as the request values.

Sample Request

curl --location --request POST 'BASE_URL/v3/logistics'  
--header 'x-api-key: API_KEY'
--header 'Content-Type: application/json'
--data-raw '{
"queries": {
"legs": [
{
"shipping_method": "SHIP",
"shipping_distance": 546,
"shipping_weight": 52
},
{
"shipping_method": "TRUCK_LIGHT",
"shipping_distance": 324,
"shipping_weight": 52,
"truck_capacity": 7
},
{
"shipping_method": "TRUCK_MEDIUM",
"shipping_distance": 324,
"shipping_weight": 52,
"truck_capacity": 7
},
{
"shipping_method": "TRUCK_HEAVY",
"shipping_distance": 43534,
"shipping_weight": 52,
"truck_capacity": 15
},
{
"shipping_method": "FLIGHT",
"shipping_distance": 2342,
"shipping_weight": 52
},
{
"shipping_method": "TRAIN",
"shipping_distance": 324,
"shipping_weight": 52
},
{
"shipping_method": "MOTORCYCLE",
"shipping_distance": 23,
"shipping_weight": 52
}
]
}
}
'

Sample Response

Below are sample responses for the above request.

Responses

{
"message": "Truecost calculated successfully",
"truecost": {
"total_truecost": 306.933,
"legs": [
0.458,
0.739,
1.427,
111.302,
192.804,
0.16,
0.043
],
"equivalents": {
"trash_collected": "13045",
"trees_planted": "5064",
"lamps_collected": "11633"
}
}
}