Perform a Calculation

Changed Oct 20
POST
/v2/calculations

The calculations endpoint can calculate carbon emissions for one or multiple activities. The carbon footprint or your journey consisting of, for example, a return flight, two cab rides, and a hotel stay can be computed all at once, passing all five activities in the items array. Include the string literal "items" in the "expand" array to retrieve values for each item separately in addition to the total carbon quantity.

This is a low-latency endpoint. SQUAKE does not provide you with a unique identifier for any calculation results. You must quote a price on the pricing endpoint to purchase compensation for your carbon emissions.

Some data sets are extensive and thus documented separately here.

Authorization

Bearer-Auth
headerAuthorizationBearer <token>

Request Body

application/json
  1. body
expand?array<>

Include "items" to return emissions per item (in addition to the total). Include "legs" to return per-leg rows for flight items that use routing (multi-leg itineraries). legs is only meaningful when combined with items. See Flight routing.

carbon_unit?Carbon Unit

SQUAKE uses The International System of Units (SI), commonly referred to as "metric system".

Value in"tonne""kilogram""gram"
distance_unit?Distance-Unit

SQUAKE uses common distance units

Default"kilometer"
Value in"meter""kilometer""feet""mile""nautical_mile"
audit_for?string

(Optional) Provide when calculating on behalf of a specific Auditable entity; otherwise omit.

If you make a calculation on behalf of a specific legal entity, you can specify the ID of the auditable entity. This will associate all audit logs created for that calculation with the given Auditable entity.

items*array<one of 20 types>

One entry per activity you want calculated. A single request can mix activity types freely — a flight, two taxi rides, and a hotel stay are one call, and the response returns their combined carbon_quantity. Add "items" to expand to also get the emissions of each entry separately.

Every item is shaped by two fields:

  • type — the activity, e.g. flight, hotel, car, train, road_freight, expenditure.
  • methodology — the standard to calculate it with, e.g. DEFRA, ICAO, TIM, GREENVIEW, GLEC.

Those two decide which further fields the item takes, and which of them are required: flight + ICAO expects origin and destination (or routing for a multi-leg itinerary), while hotel + GREENVIEW expects country, city, and number_of_nights. Not every methodology is available for every activity type.

Two fields are accepted on any item: external_reference, echoed back on the matching response item so you can reconcile results with your own records, and audit for the immutable audit log of a final calculation.

Pick your activity type below to see the fields it accepts per methodology. For copy-paste request and response pairs, see the calculation examples in the integration docs.

type
variant

Accommodation considers only activities related to short-term rentals, lodging, sublets, etc.

SQUAKE has country-specific values for most parameters. If the country is omitted, default values will apply.

audit?Audit mode

SQUAKE provides you the option to create audit records for your calculations requests. These records are immutable, once they are created they cannot be altered, please use this feature only for final calculations.

Note: to use this feature you need to have it enabled for your account, please contact us for more information.

Defaultfalse
type*"accommodation"
methodology*"SQUAKE"

Detailed documentation of the methodology can be found in the integration docs.

Default"SQUAKE"
external_reference?external_reference

A unique identifier that helps you link the resulting emissions to the requested item. Especially useful if multiple items are requested since SQUAKE cannot guarantee to keep the same order. The maximum length is 128 characters.

Lengthlength <= 128
number_of_nights?integer

Required if start and end dates are omitted; else this is ignored.

Formatint32
Range1 <= value
starts_on*string

The format is ISO 8601 Date, YYYY-MM-DD. Required if season-specific methodology shall be used, or number of nights is omitted.

Formatdate
ends_on*string

The format is ISO 8601 Date, YYYY-MM-DD. Required if season-specific methodology shall be used, or number of nights is omitted.

Formatdate
country?Country

Two-letter or three-letter code as defined in ISO 3166-1 alpha-2 and alpha-3 respectively.

Match^[A-Z]{2,3}$
Length2 <= length <= 3
number_of_travelers*integer

The default value depends on the country.

Range1 <= value
square_meters*number

The default value depends on the country.

Formatdouble
Range1 <= value
sauna?boolean
Defaultfalse
parking?boolean
Defaulttrue
swimming_pool?boolean
Defaultfalse
air_conditioner?boolean
Defaultfalse
garage?boolean
Defaultfalse

Response Body

OK

application/json
  1. response
carbon_quantity*number
carbon_unit*Carbon Unit

SQUAKE uses The International System of Units (SI), commonly referred to as "metric system".

Value in"tonne""kilogram""gram"
items?array<>

Present when expand includes items. Per-item emissions; for routed flights, include legs in expand to also receive routing and per-leg rows on the item.

curl -X POST 'https://api.sandbox.squake.earth/v2/calculations' \  -H 'Content-Type: application/json' \  -d '{  "expand": [    "items"  ],  "carbon_unit": "tonne",  "distance_unit": "kilometer",  "items": [    {      "type": "flight",      "audit": false,      "methodology": "DEFRA",      "external_reference": "string",      "booking_class": "economy",      "number_of_travelers": 1,      "aircraft_type": "7M7",      "fare_class": "Y",      "origin": "BER",      "destination": "CDG",      "airline": "LH",      "radiative_forcing_index": true,      "sustainable_fuels": {        "carbon_reduction_percentage_of_total": 0.25      },      "energy_scope": "ttw"    }  ]}'
Example Response
{  "carbon_quantity": 0.37,  "carbon_unit": "tonne",  "items": [    {      "carbon_quantity": 0.37,      "carbon_unit": "tonne",      "type": "flight",      "methodology": "DEFRA",      "external_reference": "string"    }  ]}