Perform a Calculation including a Price Quote

Changed Oct 20
POST
/v2/calculations-with-pricing

Convenience all-in-one endpoint to perform carbon calculation and pricing. A purchase can be performed via API or SQUAKE's checkout page using the returned payment_link. All features supported by either the /calculations or /pricing endpoint are equally valid for this combined endpoint. Please read the respective descriptions for details. If you need only either pricing or carbon emissions, SQUAKE advises using the specific endpoints for lower latency and reduced implementation complexity.'

Authorization

Bearer-Auth
headerAuthorizationBearer <token>

Request Body

application/json
  1. body
expand?array<>

If you include "items", SQUAKE returns emissions per item. Include "legs" for per-leg flight rows when using routing. If you include items.pricing a pricing token will be returned for each item.

items*array<one of 20 types>
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
product*string
Matchproduct_[A-Za-z0-9]*
payment_link_return_url?string

If the customer does not exit the browser after the purchase, on success, SQUAKE will redirect the customer to this link.

currency?Currency

3-letter ISO 4217 alpha code of the currency.

Match^[A-Z]{3}$
Length3 <= length <= 3
Default"EUR"
Value in"AED""AMD""ARS""AUD""AZN""BAM""BGN""BHD""BRL""CAD""CHF""CLP""CNY""COP""CRC""CZK""DKK""DZD""EGP""ETB""EUR""GBP""GEL""HKD""HUF""IDR""INR""ISK""JMD""JOD""JPY""KES""KRW""KWD""KZT""LKR""LYD""MAD""MUR""MXN""MYR""NOK""NZD""OMR""PHP""PKR""PLN""QAR""RSD""RUB""SAR""SEK""SGD""SYP""THB""TND""TRY""TTD""TWD""UAH""USD""VND""XAF""XOF""ZAR"
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"
payment_method?payment_method

Controls the way you want to process the purchase.

If stripe is used then you''ll receive a payment_link in response.

If batch_settlement is used, then you''ll have to use /purchases endpoint to finalise the purchase.

Default"batch_settlement"
Value in"stripe""batch_settlement"

Response Body

OK

application/json
  1. response
id*string

A token encoding the pricing. Used to make a purchase.

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"
payment_link?string
price*|
product*|
valid_until*ISO-8601-Date

Date in ISO 8601 notation.

Match^\d{4}-\d{2}-\d{2}$
Formatdate
currency*Currency

3-letter ISO 4217 alpha code of the currency.

Match^[A-Z]{3}$
Length3 <= length <= 3
Default"EUR"
Value in"AED""AMD""ARS""AUD""AZN""BAM""BGN""BHD""BRL""CAD""CHF""CLP""CNY""COP""CRC""CZK""DKK""DZD""EGP""ETB""EUR""GBP""GEL""HKD""HUF""IDR""INR""ISK""JMD""JOD""JPY""KES""KRW""KWD""KZT""LKR""LYD""MAD""MUR""MXN""MYR""NOK""NZD""OMR""PHP""PKR""PLN""QAR""RSD""RUB""SAR""SEK""SGD""SYP""THB""TND""TRY""TTD""TWD""UAH""USD""VND""XAF""XOF""ZAR"
total*integer

The total amount in the lower denomination of the currency; e.g. 12.34 USD would be 1234.

items?array<>

Expand items to receive emissions per item. By default, this is not included.

Example Request
curl -X POST 'https://api.sandbox.squake.earth/v2/calculations-with-pricing' \  -H 'Content-Type: application/json' \  -d '{  "items": [    {}  ],  "product": "product_afg3465afg3"}'
Example Response
{  "id": "string",  "carbon_quantity": 0,  "carbon_unit": "tonne",  "payment_link": "string",  "price": "price_1MMroL2eZvKYlo2CxbxAACvb",  "product": "product_01fa2d8f04e424",  "valid_until": "2023-01-28",  "currency": "EUR",  "total": 0,  "items": [    {      "carbon_quantity": 0,      "carbon_unit": "tonne",      "external_reference": "string",      "type": "air_freight",      "methodology": "GLEC",      "methodology_version": "2025",      "distance": 0,      "distance_unit": "kilometer",      "routing": "string",      "legs": [        {          "carbon_quantity": 0,          "carbon_unit": "tonne",          "distance": 0,          "distance_unit": "kilometer",          "type": "flight",          "methodology": "string",          "external_reference": "string",          "audit": {},          "emission_factors": {}        }      ],      "pricing": {        "id": "string",        "total": "string",        "currency": "EUR"      }    }  ]}

Perform a Calculation

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](https://squake.notion.site/Databases-2a5a8e757fc74b62bef3be7c5ac2f699).

Quote a Pricing

Returns pricing for a given product and carbon quantity (or a fixed total amount in any supported currency). <br><br> By default, requested pricing is valid for two weeks starting the moment you request it. Expired pricings can still be used as long as the underlying price hasn''t changed for your convenience. <br><br> Repeated purchases using the same pricing are possible via API and the checkout page using the pricing id or `payment_link`, respectively. <br><br> You can append additional parameters to the `payment_link`; SQUAKE's checkout page supports the following: * **localization**: Please use a two-letter ISO 639-1 code, for example: `&locale=en` for English. * **utm_***: any valid UTM tracking parameters, e.g., `&utm_medium=email`. <br><br> This is a low-latency endpoint, useful for previewing pricing before making a purchase either via API or on the SQUAKE checkout page via the returned `payment_link`.'