No key needed

Quick Start Guide

The API is plain JSON over HTTPS. There is nothing to install.

1. Make a request

Electricity, fuel and flight calculations work without a key in a rate-limited test mode. Paste this into a terminal:

terminalbash
curl -X POST https://zerocarbon.org.in/api/v1/calculate/electricity \
  -H "Content-Type: application/json" \
  -d '{"kwh": 1000, "country_code": "IN"}'
responsejson
{
  "success": true,
  "data": {
    "emissions_kg_co2e": 675,
    "emission_factor": 0.675,
    "emission_factor_label": "0.675 kgCO2e/kWh (CEA_CO2_Baseline_v22_FY2025-26 (weighted_average, AR5))",
    "emission_factor_source": "CEA_CO2_Baseline_v22_FY2025-26",
    "scope": "scope_2",
    "activity": { "value": 1000, "unit": "kWh" },
    "formula": "1000 kWh × 0.675 kgCO2e/kWh = 675.0000 kgCO2e",
    "details": {
      "kwh": 1000,
      "country_code": "IN",
      "state": null,
      "state_applied": false,
      "methodology": "Location-based Scope 2 (GHG Protocol), national grid average"
    }
  }
}

Every answer names its factor, the dataset it comes from and the formula, so the number can be checked by hand.

2. Call it from code

Node.js 18+

calculate.mjstypescript
const res = await fetch('https://zerocarbon.org.in/api/v1/calculate/fuel', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ fuel_type: 'diesel', amount: 100, unit: 'L', country: 'IN' }),
});
const body = await res.json();

if (body.success) {
  console.log(body.data.emissions_kg_co2e, 'kg CO2e');  // 268.795
  console.log(body.data.formula);
} else {
  // Refusals carry a code and guidance; malformed requests carry an error object.
  console.error(res.status, body.code ?? body.error?.code, body.guidance ?? body.error?.message);
}

Run it with node calculate.mjs.

Python

calculate.pypython
import requests

res = requests.post(
    "https://zerocarbon.org.in/api/v1/calculate/flight",
    json={"distance_km": 1150, "passengers": 2, "cabin_class": "economy", "country": "IN"},
    timeout=30,
)
body = res.json()

if body["success"]:
    print(body["data"]["emissions_kg_co2e"], "kg CO2e")  # 296.7
    print(body["data"]["formula"])
else:
    print(res.status_code, body)

Needs pip install requests.

3. Get a key when you need more

An API key lifts the test-mode limit to 120 requests per minute per endpoint and unlocks /calculate/spend. Generate one at API Keys in your dashboard and send it as Authorization: Bearer zc_.... See Authentication.

What's next