Skip to main content

Bus Truecost | Climes API


This endpoint provides the truecost value for bus transportation.

Request Parameters

Request Schema

This is the schema for the bus transportation truecost api. Each request payload contains 2 objects

  • queries
  • configs

Here configs are the params that will apply to all the queries objects

Configs Schema

NameDescriptionTypeOptional
distanceThe total distance of the journey in km.
Default will be set as 100(km)
numberoptional
vehicle_typeType of vehicle used for the journey.
Enum : BUS
string
required

Queries Schema

Each queries object has a seats array which requires individual seat object.

NameDescriptionTypeOptional
seatsIt holds the array of individual type of seats available for that bus.array
required

Seat Schema

NameDescriptionTypeOptional
seat_typeIt the type of seat selected by the user in the ticket for the journey.
Enum : SEATER, SLEEPER
string
required
no_of_seatsThis is the seats booked by the individual user.
Default will be set to 12 for SEATER seat_type and 35 for SLEEPER
numberoptional
total_seatsThis is the total capacity of seats that the bus has for that particular seat_type.
Default will be set as 14 for SEATER and 40 for SLEEPER seat_type
numberoptional

Endpoint

/v3/transportation

Method

POST

Headers

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

Payload

{
"configs": {
"distance": 250,
"vehicle_type": "BUS"
},
"queries": {
"seats": [
{
"seat_type": "SEATER",
"no_of_seats": 3,
"total_seats": 15
},
{
"seat_type": "SLEEPER",
"no_of_seats": 3,
"total_seats": 40
}
]
}
}

Response Parameters

Response Schema

NameDescriptionType
messageA human readable string describing response for the given request.string
truecostThis object contains the calculated truecost values for the request.object
totalTotal truecost value in kg CO2e of all types of seats that were in the requestnumber
seatsIt is an object with different types of seats and their truecost values as a key value pair.object
SEATERTotal truecost value in kg CO2e for the no_of_seats occupied of SEATER type in the busnumber
SLEEPERTotal truecost value in kg CO2e for the no_of_seats occupied of SLEEPER type in the busnumber
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

{
"message": "Truecost data calculated successfully!",
"truecost": {
"total": 35,
"seats": {
"SEATER": 15,
"SLEEPER": 20
}
}
}

Sample Request

curl --location --request POST 'BASE_URL/v3/transportation'  
--header 'x-api-key: API_KEY'
--header 'Content-Type: application/json'
--data-raw '{
"configs": {
"distance": 250,
"vehicle_type": "BUS"
},
"queries": {
"seats": [
{
"seat_type": "SEATER",
"no_of_seats": 3,
"total_seats": 15
},
{
"seat_type": "SLEEPER",
"no_of_seats": 3,
"total_seats": 40
}
]
}
}'

Sample Response

Below are sample responses for the above request.

Responses

{
"message": "Truecost data calculated successfully!",
"truecost": {
"total": 35,
"seats": {
"SEATER": 15,
"SLEEPER": 20
}
}
}