API Endpoint
https://co2.observer/api/
					Request Parameters
| Parameter | Description | Required | Example | 
|---|---|---|---|
key | 
								The API key for authentication. | Yes | rt1bvhJY9v7bxSTHi449O6A7b9Ml86LJTC67kr4wMJ | 
url | 
								The URL of the website you want to scan. | Yes | triss.dev | 
scan | 
								If set to true, it forces a new scan. If not provided or set to false, it retrieves the last scan result from the database. | No | true | 
Response Format
The API returns a JSON object with the following fields:
| Field | Description | Type | Example | 
|---|---|---|---|
url | 
								The scanned website's URL. | String | triss.dev | 
greenHost | 
								Indicates if the website is hosted on a green host. | Boolean | true | 
size | 
								The size of the website in bytes. | Number | 30311 | 
sizeFormatted | 
								The formatted size of the website. | String | 29.6 KB | 
energiConsumption | 
								The energy consumption of the website. | Number | 1.3660912680156121e-5 | 
| co2 | An object containing details about the CO2 emissions. | Object | - | 
co2.grams | 
								Estimated CO2 emissions in grams. | Number | 0.005880841491886818 | 
co2.litres | 
								Estimated CO2 emissions in liters. | Number | 0.0032709240377874482 | 
| result | An object containing performance scores and grades. | Object | - | 
result.sizeScore | 
								The size score of the website. | Number | 0.98 | 
result.performanceScore | 
								The performance score of the website. | Number | 1 | 
result.grade | 
								The overall grade of the website. | Number | 0.99 | 
result.gradeFormatted | 
								The formatted grade of the website. | String | A+ | 
timestamp | 
								The timestamp of the last scan. | Number | 1694932603 | 
Response Example
{
    "url": "triss.dev",
    "greenHost": true,
    "size": 30357,
    "sizeFormatted": "29.65 KB",
    "energiConsumption": 1.3681644493137784e-5,
    "co2": {
        "grams": 0.005889766262056947,
        "litres": 0.003275887994956074
    },
    "result": {
        "sizeScore": 0.99,
        "performanceScore": 1,
        "grade": 1,
        "gradeFormatted": "A+"
    },
    "timestamp": 1695110052
}
					Example Usage
To get the CO2 emission details of the website triss.dev:
cURL
curl "https://co2.observer/api/?key=[APIKEY]&url=triss.dev&scan=false"
					
					WGET
wget -qO- "https://co2.observer/api/?key=[APIKEY]&url=triss.dev&scan=false"
					Others
<?php
// Your API key
$apiKey = 'YOUR_API_KEY'; // Replace with your actual API key
// Domain to query
$domain = 'triss.dev'; // Replace with your actual domain
// Initialize new scan
$scan = false; // Set to true if you want to perform a new scan. Defaults to "false"
// The API endpoint you want to hit
$url = 'https://co2.observer/api/?key=' . $apiKey . '&url=' . $domain . '&scan=' . $scan;
// Initialize cURL session
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);         // Set the URL
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Return the transfer as a string
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Optional: Disable SSL verification if needed
// Execute cURL session and store the response
$response = curl_exec($ch);
// Check for errors
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    // Decode the JSON response
    $data = json_decode($response, true);
    // Use the data as needed
    print_r($data);
}
// Close cURL session
curl_close($ch);
?>
						// Your API key
const apiKey = 'YOUR_API_KEY'; // Replace with your actual API key
// Domain to query
const domain = 'triss.dev'; // Replace with your actual domain
// Initialize new scan
const scan = false; // Set to true if you want to perform a new scan. Defaults to "false"
// The URL with your API key and other parameters
const url = `https://co2.observer/api/?key=${apiKey}&url=${domain}&scan=${scan}`;
// Use the Fetch API to get the data
fetch(url)
  .then(response => {
    if (!response.ok) {
        throw new Error(`HTTP error! status: ${response.status}`);
    }
    return response.json();
  })
  .then(data => {
    // Process your data here
    console.log(data);
  })
  .catch(error => {
    // Handle any errors here
    console.error('Fetch error:', error);
  });
async function fetchData() {
  try {
    const response = await fetch(url);
    if (!response.ok) {
        throw new Error(`HTTP error! status: ${response.status}`);
    }
    const data = await response.json();
    console.log(data);
  } catch (error) {
    console.error('Fetch error:', error);
  }
}
fetchData();
						// Your API key
const apiKey = 'YOUR_API_KEY'; // Replace with your actual API key
// Domain to query
const domain = 'triss.dev'; // Replace with your actual domain
// Initialize new scan
const scan = false; // Set to true if you want to perform a new scan. Defaults to "false"
// The URL with your API key and other parameters
const url = `https://co2.observer/api/?key=${apiKey}&url=${domain}&scan=${scan}`;
// Define the callback function
xhr.onreadystatechange = function() {
    if (xhr.readyState === 4) { // Check if request is complete
        if (xhr.status === 200) { // Check if status is OK
            // Parse the JSON response
            var data = JSON.parse(xhr.responseText);
            // Process the data
            console.log(data);
        } else {
            // Handle HTTP error
            console.error('XHR Error: ' + xhr.status);
        }
    }
};
// Open a GET request
xhr.open('GET', url);
// Send the request
xhr.send();
						// Your API key
const apiKey = 'YOUR_API_KEY'; // Replace with your actual API key
// Domain to query
const domain = 'triss.dev'; // Replace with your actual domain
// Initialize new scan
const scan = false; // Set to true if you want to perform a new scan. Defaults to "false"
// The URL with your API key and other parameters
const url = `https://co2.observer/api/?key=${apiKey}&url=${domain}&scan=${scan}`;
https.get(url, (res) => {
    let data = '';
    // A chunk of data has been received.
    res.on('data', (chunk) => {
        data += chunk;
    });
    // The whole response has been received. Print out the result.
    res.on('end', () => {
        try {
            const jsonData = JSON.parse(data);
            console.log(jsonData);
        } catch (e) {
            console.error('Error parsing JSON:', e);
        }
    });
}).on('error', (err) => {
    console.error('Error:', err);
});
						// TOML
[dependencies]
reqwest = "0.11"
serde_json = "1.0"
tokio = { version = "1", features = ["full"] }
// RUST
use reqwest;
use serde_json::Value;
use tokio;
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
    // Your API key
    let api_key = 'YOUR_API_KEY'; // Replace with your actual API key
    // Domain to query
    let domain = 'triss.dev'; // Replace with your actual domain
    // Initialize new scan
    let scan = false; // Set to true if you want to perform a new scan. Defaults to "false"
    // The URL with your API key and other parameters
    let url = format!("https://co2.observer/api/?key={}&url={}&scan={}", api_key, domain, scan);
    // Make a GET request
    let res = reqwest::get(&url).await?;
    // Parse the response body as JSON
    let body = res.json::().await?;
    // Print the JSON data
    println!("{:#?}", body);
    Ok(())
} 
						package main
import (
    "encoding/json"
    "fmt"
    "io/ioutil"
    "net/http"
)
func main() {
    // API key
    apiKey := "YOUR_API_KEY" // Replace with your actual API key
    // Domain to query
    domain := "triss.dev" // Replace with your actual domain
    // Initialize new scan
    scan := false // Set to true if you want to perform a new scan. Defaults to false
    // The URL with your API key and other parameters
    url := fmt.Sprintf("https://co2.observer/api/?key=%s&url=%s&scan=%s", apiKey, domain, scan)
    // Make a GET request
    resp, err := http.Get(url)
    if err != nil {
        fmt.Printf("Error making request: %s\n", err)
        return
    }
    defer resp.Body.Close()
    // Read the response body
    body, err := ioutil.ReadAll(resp.Body)
    if err != nil {
        fmt.Printf("Error reading response: %s\n", err)
        return
    }
    // A map to hold the JSON data
    var data map[string]interface{}
    // Unmarshal the JSON data
    if err := json.Unmarshal(body, &data); err != nil {
        fmt.Printf("Error decoding JSON: %s\n", err)
        return
    }
    // Print the data
    fmt.Println(data)
}
						import requests
# Your API key
api_key = 'YOUR_API_KEY' #Replace with your actual API key
#Domain to query
domain = 'triss.dev' # Replace with your actual domain
# Initialize new scan
scan = false # Set to true if you want to perform a new scan. Defaults to "false"
# The URL with your API key and other parameters
url = f'https://co2.observer/api/?key={api_key}&url={url}&scan={scan}'
# Make a GET request
response = requests.get(url)
# Check if the request was successful
if response.status_code == 200:
    # Parse JSON response
    data = response.json()
    print(data)
else:
    print('Failed to retrieve data:', response.status_code)
						Notes
- API keys are available upon request. Contact us for more detailes.
 - Ensure that you use a valid API key for authentication.
 - You don't need to explicitly set the scan parameter to false; it will default to false if not specified.