Skip to main content

Flight Truecost | Climes API


This endpoint provides the truecost value for flights (upto 10 flights per request).

Request Parameters

Request Schema

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

Queries Schema

Each queries object has a flights array which requires individual flight object.

Name DescriptionTypeOptional
flightsIt is an array of individual flights whose truecost needs to be calculated.array
required

Flight Schema

Name DescriptionTypeOptional
flight_idThis field has to generated and sent from your end. This has to be unique in order to map each flight truecost data to its original request for tally purposes. If this field is not set then an auto generated unique flight_id will be automatically assigned to that request.unique stringoptional
departureThe destination airport's IATA code where the flight is going.string
required
arrivalThe arrival airport's IATA code where the flight will arrive at.string
required
no_of_ticketsNumber of tickets for which the truecost is being calculated.number
required
aircraft_modelThe aircraft model that is being used for the journey.
Default will be set as 320
stringoptional
flight_classThe class of flight ticket for which the truecost is being calculated.
Default will be set as ECONOMY
Enums : ECONOMY , PREMIUM_ECONOMY , FIRST , BUSINESS
stringoptional
flight_typeThis is an enum denoting the type of the flight.
Default will be set as ONE_WAY
Enums : ONE_WAY , ROUND_TRIP
stringoptional

Endpoint

/v3/flight

Method

POST

Headers

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

Payload

{
"queries": {
"flights": [{
"flight_id": "BWESYZZE6ECOFOMFDH4",
"departure": "BOS",
"arrival": "YYZ",
"aircraft_model": "DH4",
"flight_class": "ECONOMY",
"no_of_tickets": 1,
"flight_type": "ONE_WAY"
},
{
"flight_id": "FWYSYZZE6ECOFOMOME",
"departure": "BOS",
"arrival": "YYZ",
"aircraft_model": "DH4",
"flight_class": "ECONOMY",
"no_of_tickets": 1,
"flight_type": "ONE_WAY"
}
]
}
}
caution

The length of the flights array should not be more than 10 individual objects per request.

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
flight_idThe flight_id that was sent during the request for each object requeststring
truecostCalculated truecost value in tonnes CO2e for that object of requeststring
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 calculated successfully",
"truecost": [{
"flight_id": "BWESYZZE6ECOFOMFDH4",
"truecost": "0.320"
},
{
"flight_id": "FWYSYZZE6ECOFOMOME",
"truecost": "0.320"
}
]
}
tip

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

Sample Request

curl --location --request POST 'BASE_URL/v3/flight'  
--header 'x-api-key: API_KEY'
--header 'Content-Type: application/json'
--data-raw '{
"queries": {
"flights": [{
"flight_id": "BWESYZZE6ECOFOMFDH4",
"departure": "BOS",
"arrival": "YYZ",
"aircraft_model": "DH4",
"flight_class": "ECONOMY",
"no_of_tickets": 1,
"flight_type": "ONE_WAY"
},
{
"flight_id": "FWYSYZZE6ECOFOMOME",
"departure": "BOS",
"arrival": "YYZ",
"aircraft_model": "DH4",
"flight_class": "ECONOMY",
"no_of_tickets": 1,
"flight_type": "ONE_WAY"
}
]
}
}'

Sample Response

Below are sample responses for the above request.

Responses

{
"message": "Truecost calculated successfully",
"truecost": [
{
"flight_id": "BWESYZZE6ECOFOMFDH4",
"truecost": "0.320"
},
{
"flight_id": "FWYSYZZE6ECOFOMOME",
"truecost": "0.320"
}
]
}