Quickstart

Get a sandbox API key, check your connection and make your first carbon calculation.

Make your first carbon calculation against the SQUAKE sandbox: get an API key, check that you can reach the API, send a request and read the result.

1. Get a sandbox API key

SQUAKE authenticates every request with an API key. You create and revoke keys in the SQUAKE Dashboard; to get access to the Dashboard, contact product@squake.earth.

  1. In the Dashboard, switch to sandbox mode.
  2. Create an API key.
  3. Store it securely. The Dashboard shows each key only once.

Sandbox and production are separate

The sandbox at https://api.sandbox.squake.earth and production at https://api.squake.earth share no data, and each needs its own API key. Both run the same version of the API.

The examples below read the key from an environment variable:

export SQUAKE_API_KEY="<your sandbox API key>"

2. Check that you can reach the API

The health check is the only endpoint that needs no authentication. A 200 response means the sandbox is reachable:

curl -i https://api.sandbox.squake.earth/v2/healthz

3. Make your first calculation

Calculate the emissions of one business-class flight from Berlin to New York with the ICAO methodology. Pass the API key as a bearer token; all requests must use HTTPS.

curl https://api.sandbox.squake.earth/v2/calculations \
  -H "Authorization: Bearer $SQUAKE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "expand": ["items"],
    "items": [{
      "type": "flight",
      "methodology": "ICAO",
      "external_reference": "test_7",
      "origin": "BER",
      "destination": "JFK",
      "aircraft_type": "737",
      "number_of_travelers": 1,
      "booking_class": "business",
      "airline": "AA",
      "fare_class": "Y"
    }]
  }'

4. Read the response

200 OKapplication/json
{
  "carbon_quantity": 454070,
  "carbon_unit": "gram",
  "items": [{
    "carbon_quantity": 454070,
    "carbon_unit": "gram",
    "external_reference": "test_7",
    "type": "flight",
    "methodology": "ICAO",
    "distance": 6522.0,
    "distance_unit": "kilometer"
  }]
}
  • carbon_quantity is the total for all items, in carbon_unit: here 454,070 g, about 454 kg of COβ‚‚e.
  • items lists each item's result because the request asked for "expand": ["items"]. Use external_reference to match results to the items you sent; SQUAKE doesn't guarantee their order.
  • Every response carries a SQUAKE-Request-Id header. Include it when you contact support about a request.

5. Go live

Create a production API key in the Dashboard's production mode and send the same request to https://api.squake.earth. Nothing else changes.

Next steps

On this page

POST/v2/calculations

Run this request against the sandbox with your test key.

Open in API reference