Perform a Calculation

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.

application/json

Body

  • expand array

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

    Value is items.

  • 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.

  • If you make a calculation on behalf of a specific legal entity, you can specify their details here.

    Hide audit_for attributes Show audit_for attributes object
    • legal_name string Required

      Legal name of the entity you're performing calculation for.

    • external_id string(email)

      External id of the entity you're performing audit for.

  • items array[object] Required
    Any of:

    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.

    Hide attributes Show attributes
    • audit boolean

      SQUAKE provides you the option to create audit records for your calculations requests. Note: to use this feature you need to have it enabled for your account, please contact us for more information.

      Default value is false.

    • type Required

      Value is accommodation.

    • methodology Required

      Value is SQUAKE. Default value is SQUAKE.

    • 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.

      Maximum length is 128.

    • number_of_nights integer(int32) Required

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

      Minimum value is 1.

    • starts_on string(date) Required

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

    • ends_on string(date) Required

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

    • country string

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

      Minimum length is 2, maximum length is 3. Format should match the following pattern: ^[A-Z]{2,3}$.

    • number_of_travelers integer Required

      The default value depends on the country.

      Minimum value is 1.

    • square_meters number(double) Required

      The default value depends on the country.

      Minimum value is 1.

    • sauna boolean

      Default value is false.

    • parking boolean

      Default value is true.

    • Default value is false.

    • Default value is false.

    • garage boolean

      Default value is false.

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
    • 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.

    • 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.

    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
      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.

    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
      Hide source attributes Show source attributes object
POST /v2/calculations
curl \
 --request POST 'https://api.squake.earth/v2/calculations' \
 --header "Authorization: Bearer $ACCESS_TOKEN" \
 --header "Content-Type: application/json" \
 --data '{"expand":["items"],"carbon_unit":"tonne","distance_unit":"kilometer","audit_for":{"legal_name":"string","external_id":"hello@example.com"},"items":[{"audit":false,"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}]}'
Request examples
{
  "expand": [
    "items"
  ],
  "carbon_unit": "tonne",
  "distance_unit": "kilometer",
  "audit_for": {
    "legal_name": "string",
    "external_id": "hello@example.com"
  },
  "items": [
    {
      "audit": false,
      "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
    }
  ]
}
Response examples (200)
# Headers

# Payload
{
  "carbon_quantity": 0.37,
  "carbon_unit": "tonne",
  "items": [
    {
      "carbon_quantity": 0.37,
      "carbon_unit": "tonne",
      "external_reference": "string",
      "type": "air_freight",
      "methodology": "GLEC"
    }
  ]
}
Response examples (400)
# Headers

# Payload
[
  {
    "code": "field_validation_error",
    "detail": "string",
    "source": {
      "id": "string",
      "attribute": "string",
      "model": "string"
    }
  }
]
Response examples (401)
# Headers

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