Perform a Calculation including a Price Quote

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.

application/json

Body

  • expand array[string]

    If you choose to expand on e.g. "items", SQUAKE returns emissions per each item separately (in addition to a total value).

    Values are items, product, or price.

  • items array[object] Required
    Any of:
  • product string Required

    Format should match the following pattern: product_[A-Za-z0-9]*.

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

  • currency string

    3-letter ISO 4217 alpha code of the currency.

    Minimum length is 3, maximum length is 3. Format should match the following pattern: ^[A-Z]{3}$. Values are 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, or ZAR. Default value is EUR.

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

    Values are tonne, kilogram, or gram.

  • SQUAKE uses common distance units

    Values are meter, kilometer, feet, mile, or nautical_mile. Default value is kilometer.

Responses

  • 200 application/json

    OK

    Hide headers attribute Show headers attribute
    • Unique identifier linked to this API request. If you need to contact us regarding a specific request, providing the request identifier helps the resolution process.

    Hide response attributes Show response attributes object
    • id string Required

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

    • carbon_quantity number Required
    • carbon_unit string Required

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

      Values are tonne, kilogram, or gram.

    • price string | object Required

      One of:

      ID of a price.

      Format should match the following pattern: price_[A-Za-z0-9]*.

    • product string | object Required

      Any of:

      ID of a product.

      Format should match the following pattern: product_[A-Za-z0-9]*.

    • valid_from string(date) Required

      Used for TIM, GATE4 and IATA.

      Format should match the following pattern: ^\d{4}-\d{2}-\d{2}$.

    • valid_until string(date) Required

      Used for TIM, GATE4 and IATA.

      Format should match the following pattern: ^\d{4}-\d{2}-\d{2}$.

    • currency string Required

      3-letter ISO 4217 alpha code of the currency.

      Minimum length is 3, maximum length is 3. Format should match the following pattern: ^[A-Z]{3}$. Values are 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, or ZAR. Default value is EUR.

    • total integer Required

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

    • items array[object]

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

      Hide items attributes Show items attributes object
      • carbon_quantity number Required
      • carbon_unit string Required

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

        Values are tonne, kilogram, or gram.

      • type string Required

        Values are accommodation, air_freight, bus, camping_site, car, co2_amount, coffee_production, cruise, expenditure, ferry, flight, general, hotel, logistics, logistics_site, money_amount, private_jet, sea_freight, inland_waterways, train, rail_freight, road_freight, or van.

      • methodology string Required

        Values are ACRISS, ADEME, BASIC, CLEAN-CARGO, CO2-EMISSIEFACTOREN-NL, DIN-EN-16258, DEFRA, EU-EEA, EU-EMSA, US-EPA, HCMI, OFNK, ECTA, GLEC, ICAO, TIM, or SQUAKE.

  • 400 application/json

    Example response

    Hide headers attribute Show headers attribute
    • Unique identifier linked to this API request. If you need to contact us regarding a specific request, providing the request identifier helps the resolution process.

      Format should match the following pattern: req_[a-zA-Z0-9-]+.

    Hide response attributes Show response attributes object
    • code string Required

      An application-specific error code, expressed as a string value.

      Values are field_validation_error, server_error, not_authorized, not_found, invalid_methodology, or invalid_type.

    • detail string

      A human-readable explanation specific to this occurrence of the problem. Like title, this field's value can be localized.

    • source object

      An object containing references to the primary source of the error

      Additional properties are allowed.

      Hide source attributes Show source attributes object
  • 401 application/json

    Example response

    Hide headers attribute Show headers attribute
    • Unique identifier linked to this API request. If you need to contact us regarding a specific request, providing the request identifier helps the resolution process.

      Format should match the following pattern: req_[a-zA-Z0-9-]+.

    Hide response attributes Show response attributes object
    • code string Required

      An application-specific error code, expressed as a string value.

      Values are field_validation_error, server_error, not_authorized, not_found, invalid_methodology, or invalid_type.

    • detail string

      A human-readable explanation specific to this occurrence of the problem. Like title, this field's value can be localized.

    • source object

      An object containing references to the primary source of the error

      Additional properties are allowed.

      Hide source attributes Show source attributes object
POST /v2/calculations-with-pricing
curl \
 -X POST https://api.squake.earth/v2/calculations-with-pricing \
 -H "Authorization: Bearer $ACCESS_TOKEN" \
 -H "Content-Type: application/json" \
 -d '{"expand":["items"],"items":[{"type":"accommodation","methodology":"SQUAKE","external_reference":"string","number_of_nights":2,"starts_on":"2020-01-01","ends_on":"2020-01-01","country":"DE","number_of_travelers":1,"square_meters":50,"sauna":false,"parking":true,"swimming_pool":false,"air_conditioner":false,"garage":false}],"product":"product_afg3465afg3","payment_link_return_url":"string","currency":"EUR","carbon_unit":"tonne","distance_unit":"kilometer"}'
Request examples
{
  "expand": [
    "items"
  ],
  "items": [
    {
      "type": "accommodation",
      "methodology": "SQUAKE",
      "external_reference": "string",
      "number_of_nights": 2,
      "starts_on": "2020-01-01",
      "ends_on": "2020-01-01",
      "country": "DE",
      "number_of_travelers": 1,
      "square_meters": 50,
      "sauna": false,
      "parking": true,
      "swimming_pool": false,
      "air_conditioner": false,
      "garage": false
    }
  ],
  "product": "product_afg3465afg3",
  "payment_link_return_url": "string",
  "currency": "EUR",
  "carbon_unit": "tonne",
  "distance_unit": "kilometer"
}
Response examples (200)
# Headers

# Payload
{
  "id": "string",
  "carbon_quantity": 42.0,
  "carbon_unit": "tonne",
  "payment_link": "string",
  "price": "price_1MMroL2eZvKYlo2CxbxAACvb",
  "product": "product_01fa2d8f04e424",
  "valid_from": "2023-01-28",
  "valid_until": "2023-01-28",
  "currency": "EUR",
  "total": 42,
  "items": [
    {
      "carbon_quantity": 42.0,
      "carbon_unit": "tonne",
      "external_reference": "string",
      "type": "air_freight",
      "methodology": "GLEC"
    }
  ]
}
Response examples (400)
# Headers
SQUAKE-Request-Id: req_70394c00-728e-4d70-90bc-2b589c9ebdf8

# Payload
[
  {
    "code": "field_validation_error",
    "detail": "string",
    "source": {
      "id": "string",
      "attribute": "string",
      "model": "string"
    }
  }
]
Response examples (401)
# Headers
SQUAKE-Request-Id: req_70394c00-728e-4d70-90bc-2b589c9ebdf8

# Payload
[
  {
    "code": "field_validation_error",
    "detail": "string",
    "source": {
      "id": "string",
      "attribute": "string",
      "model": "string"
    }
  }
]