Skip to main content

Commute Truecost | Climes API


Commute truecost endpoint allows user to calculate the truecost value for their entire journey with different types of vehicles for different distances through their journey.

Request Parameters

Request Schema

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

Queries Schema

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

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

Leg Schema

Name DescriptionTypeOptional
commute_methodThis is the type of vehicle used for the travel over that much distance.
Enums :
TRAIN
AUTO
INTRACITY_BUS
CAB
BIKE_COMMUTER
BIKE_SPORTS
BIKE_CRUISER
CAR_HATCHBACK_ELECTRIC
CAR_HATCHBACK_CNG
CAR_HATCHBACK_DIESEL
CAR_HATCHBACK_PETROL
CAR_SEDAN_ELECTRIC
CAR_SEDAN_CNG
CAR_SEDAN_PETROL
CAR_SEDAN_DIESEL
CAR_SUV_ELECTRIC
CAR_SUV_CNG
CAR_SUV_PETROL
CAR_SUV_DIESEL
string
required
commute_distanceThe total distance traveled using that particular commute_method.numberoptional

Endpoint

/v3/commute

Method

POST

Headers

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

Payload

{
"queries": {
"legs": [
{
"commute_method": "TRAIN",
"commute_distance": 50
},
{
"commute_method": "AUTO",
"commute_distance": 50
},
{
"commute_method": "INTRACITY_BUS",
"commute_distance": 50
},
{
"commute_method": "CAB",
"commute_distance": 50
},
{
"commute_method": "BIKE_COMMUTER",
"commute_distance": 50
},
{
"commute_method": "BIKE_SPORTS",
"commute_distance": 50
},
{
"commute_method": "BIKE_CRUISER",
"commute_distance": 50
},
{
"commute_method": "CAR_HATCHBACK_ELECTRIC",
"commute_distance": 50
},
{
"commute_method": "CAR_HATCHBACK_CNG",
"commute_distance": 50
},
{
"commute_method": "CAR_HATCHBACK_DIESEL",
"commute_distance": 50
},
{
"commute_method": "CAR_HATCHBACK_PETROL",
"commute_distance": 50
},
{
"commute_method": "CAR_SEDAN_ELECTRIC",
"commute_distance": 50
},
{
"commute_method": "CAR_SEDAN_CNG",
"commute_distance": 50
},
{
"commute_method": "CAR_SEDAN_PETROL",
"commute_distance": 50
},
{
"commute_method": "CAR_SEDAN_DIESEL",
"commute_distance": 50
},
{
"commute_method": "CAR_SUV_ELECTRIC",
"commute_distance": 50
},
{
"commute_method": "CAR_SUV_CNG",
"commute_distance": 50
},
{
"commute_method": "CAR_SUV_PETROL",
"commute_distance": 50
},
{
"commute_method": "CAR_SUV_DIESEL",
"commute_distance": 50
}
]
}
}

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 contains total truecost for all the legs in tonnes CO2e for the request.number
legs_truecostThis object contains the calculated truecost values for each leg in tonnes CO2e. It is same order as the request.object
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 commute_method as per the request order respectively.

{
"message": "Truecost calculated successfully",
"truecost": {
"total_truecost": 2.337,
"legs_truecost": {
"TRAIN": 0.123,
"AUTO": 0.123,
"INTRACITY_BUS": 0.123,
"CAB": 0.123,
"BIKE_COMMUTER": 0.123,
"BIKE_SPORTS": 0.123,
"BIKE_CRUISER": 0.123,
"CAR_HATCHBACK_ELECTRIC": 0.123,
"CAR_HATCHBACK_CNG": 0.123,
"CAR_HATCHBACK_DIESEL": 0.123,
"CAR_HATCHBACK_PETROL": 0.123,
"CAR_SEDAN_ELECTRIC": 0.123,
"CAR_SEDAN_CNG": 0.123,
"CAR_SEDAN_PETROL": 0.123,
"CAR_SEDAN_DIESEL": 0.123,
"CAR_SUV_ELECTRIC": 0.123,
"CAR_SUV_CNG": 0.123,
"CAR_SUV_PETROL": 0.123,
"CAR_SUV_DIESEL": 0.123
}
}
}
tip

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

Sample Request

curl --location --request POST 'BASE_URL/v3/commute'  
--header 'x-api-key: API_KEY'
--header 'Content-Type: application/json'
--data-raw '{
"queries": {
"legs": [
{
"commute_method": "TRAIN",
"commute_distance": 50
},
{
"commute_method": "AUTO",
"commute_distance": 50
},
{
"commute_method": "INTRACITY_BUS",
"commute_distance": 50
},
{
"commute_method": "CAB",
"commute_distance": 50
},
{
"commute_method": "BIKE_COMMUTER",
"commute_distance": 50
},
{
"commute_method": "BIKE_SPORTS",
"commute_distance": 50
},
{
"commute_method": "BIKE_CRUISER",
"commute_distance": 50
},
{
"commute_method": "CAR_HATCHBACK_ELECTRIC",
"commute_distance": 50
},
{
"commute_method": "CAR_HATCHBACK_CNG",
"commute_distance": 50
},
{
"commute_method": "CAR_HATCHBACK_DIESEL",
"commute_distance": 50
},
{
"commute_method": "CAR_HATCHBACK_PETROL",
"commute_distance": 50
},
{
"commute_method": "CAR_SEDAN_ELECTRIC",
"commute_distance": 50
},
{
"commute_method": "CAR_SEDAN_CNG",
"commute_distance": 50
},
{
"commute_method": "CAR_SEDAN_PETROL",
"commute_distance": 50
},
{
"commute_method": "CAR_SEDAN_DIESEL",
"commute_distance": 50
},
{
"commute_method": "CAR_SUV_ELECTRIC",
"commute_distance": 50
},
{
"commute_method": "CAR_SUV_CNG",
"commute_distance": 50
},
{
"commute_method": "CAR_SUV_PETROL",
"commute_distance": 50
},
{
"commute_method": "CAR_SUV_DIESEL",
"commute_distance": 50
}
]
}
}'

Sample Response

Below are sample responses for the above request.

Responses

{
"message": "Truecost calculated successfully",
"truecost": {
"total_truecost": 2.337,
"legs_truecost": {
"TRAIN": 0.123,
"AUTO": 0.123,
"INTRACITY_BUS": 0.123,
"CAB": 0.123,
"BIKE_COMMUTER": 0.123,
"BIKE_SPORTS": 0.123,
"BIKE_CRUISER": 0.123,
"CAR_HATCHBACK_ELECTRIC": 0.123,
"CAR_HATCHBACK_CNG": 0.123,
"CAR_HATCHBACK_DIESEL": 0.123,
"CAR_HATCHBACK_PETROL": 0.123,
"CAR_SEDAN_ELECTRIC": 0.123,
"CAR_SEDAN_CNG": 0.123,
"CAR_SEDAN_PETROL": 0.123,
"CAR_SEDAN_DIESEL": 0.123,
"CAR_SUV_ELECTRIC": 0.123,
"CAR_SUV_CNG": 0.123,
"CAR_SUV_PETROL": 0.123,
"CAR_SUV_DIESEL": 0.123
}
}
}