Carbon Interface API
www.carboninterface.com · Science
Carbon emissions estimates for flights, vehicles, shipping, electricity, and fuel. Calculate your carbon footprint programmatically. Free tier: 10 requests/month.
Authentication
Bearer Token
Free API key at carboninterface.com. Pass as Authorization: Bearer YOUR_KEY.
Sample Requests
POST
Flight emissions
Calculate CO2 emissions for 2 passengers flying JFK→LHR.
https://www.carboninterface.com/api/v1/estimates
Hover any highlighted part to learn what it does
Headers — extra info sent with the request
| Content-Type | application/json |
| Authorization | Bearer YOUR_KEY |
Request Body — data you're sending
{
"legs": [
{
"departure_airport": "JFK",
"destination_airport": "LHR"
}
],
"type": "flight",
"passengers": 2
}
curl -X POST "https://www.carboninterface.com/api/v1/estimates" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"legs":[{"departure_airport":"JFK","destination_airport":"LHR"}],"type":"flight","passengers":2}'import requests
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_ACCESS_TOKEN"
}
data = {
"legs": [
{
"departure_airport": "JFK",
"destination_airport": "LHR"
}
],
"type": "flight",
"passengers": 2
}
response = requests.post(
"https://www.carboninterface.com/api/v1/estimates",
headers=headers,
json=data,
)
print(response.json())const url = 'https://www.carboninterface.com/api/v1/estimates';
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
},
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
"legs": [
{
"departure_airport": "JFK",
"destination_airport": "LHR"
}
],
"type": "flight",
"passengers": 2
}),
});
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"bytes"
"encoding/json"
)
func main() {
targetURL := "https://www.carboninterface.com/api/v1/estimates"
jsonData, _ := json.Marshal({"legs":[{"departure_airport":"JFK","destination_airport":"LHR"}],"type":"flight","passengers":2})
req, _ := http.NewRequest("POST", targetURL, bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://www.carboninterface.com/api/v1/estimates")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Post.new(uri)
req["Content-Type"] = "application/json"
req["Authorization"] = "Bearer YOUR_ACCESS_TOKEN"
req["Content-Type"] = "application/json"
req.body = "{\"legs\":[{\"departure_airport\":\"JFK\",\"destination_airport\":\"LHR\"}],\"type\":\"flight\",\"passengers\":2}"
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://www.carboninterface.com/api/v1/estimates";
$opts = ["http" => [
"method" => "POST",
"header" => implode("\r\n", [
"Content-Type: application/json",
"Authorization: Bearer YOUR_ACCESS_TOKEN",
"Content-Type: application/json"
]),
"content" => json_encode({"legs":[{"departure_airport":"JFK","destination_airport":"LHR"}],"type":"flight","passengers":2}),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Postman Setup Guide
- Get a free API key at carboninterface.com
- Set Authorization: Bearer YOUR_KEY
- POST /estimates with type: flight, vehicle, shipping, electricity, or fuel
- Flight: type=flight, departure_airport, destination_airport, passengers
- Vehicle: type=vehicle, distance_unit=km, distance_value=100, vehicle_model_id