Copy-paste examples for materials estimation and comparison.

Minimal JavaScript and Python examples for the materials-first Karboncheck API: estimate one option, compare two materials, and plug the result into an AI workflow or product feature.

JavaScript fetch

const apiKey = process.env.KARBONCHECK_API_KEY;

const response = await fetch("https://www.karboncheck.com/api/estimate", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": `Bearer ${apiKey}`,
  },
  body: JSON.stringify({
    query: "aluminium",
    quantity: 1,
    unit: "tonne",
    source: "auto",
  }),
});

const data = await response.json();
console.log(data);

Python requests

import os
import requests

api_key = os.environ["KARBONCHECK_API_KEY"]
response = requests.post(
    "https://www.karboncheck.com/api/estimate",
    headers={"Authorization": f"Bearer {api_key}"},
    json={
        "query": "steel",
        "quantity": 1,
        "unit": "tonne",
        "source": "auto",
    },
    timeout=10,
)
response.raise_for_status()
print(response.json())

JavaScript compare materials

const apiKey = process.env.KARBONCHECK_API_KEY;

const compare = await fetch(
  "https://www.karboncheck.com/api/compare-materials",
  {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: `Bearer ${apiKey}`,
  },
  body: JSON.stringify({
    options: ["steel", "aluminium"],
    quantity: 1,
    unit: "tonne"
  }),
});
console.log(await compare.json());

Python compare materials

import os
import requests

api_key = os.environ["KARBONCHECK_API_KEY"]
headers = {"Authorization": f"Bearer {api_key}"}

compare = requests.post(
    "https://www.karboncheck.com/api/compare-materials",
    headers=headers,
    json={
        "options": ["steel", "aluminium"],
        "quantity": 1,
        "unit": "tonne",
    },
    timeout=10,
)
compare.raise_for_status()
print(compare.json())