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.
- In the Dashboard, switch to sandbox mode.
- Create an API key.
- 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/healthz3. 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
{
"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_quantityis the total for all items, incarbon_unit: here 454,070 g, about 454 kg of COβe.itemslists each item's result because the request asked for"expand": ["items"]. Useexternal_referenceto match results to the items you sent; SQUAKE doesn't guarantee their order.- Every response carries a
SQUAKE-Request-Idheader. 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
- Choose a methodology for each activity you calculate: flights, trains, hotels, freight and more.
- Price and purchase compensation for the emissions you calculated.
- Turn on audit mode for immutable records of finalised calculations.
- Send trips as travel data for reporting.
- Get notified with webhooks when purchases change.
- Follow the API changelog for changes to requests and responses.