Skip to content

Sustainability Time Series API

Get time series data for carbon and energy consumption.

GET /v1/sustainability/time-series

Overview

Returns carbon and energy data points aggregated by the specified interval (hour, day, week, or month). Use this endpoint for charts and trend analysis.

Request

bash
curl "https://api.gateflow.ai/v1/sustainability/time-series?time_range=last_30_days&interval=day" \
  -H "Authorization: Bearer gw_prod_..."
python
import requests

response = requests.get(
    "https://api.gateflow.ai/v1/sustainability/time-series",
    headers={"Authorization": "Bearer gw_prod_..."},
    params={
        "time_range": "last_30_days",
        "interval": "day"
    }
)

Parameters

ParameterTypeRequiredDefaultDescription
start_datedateNo-Start date (YYYY-MM-DD)
end_datedateNo-End date (YYYY-MM-DD)
time_rangestringNolast_7_daysPreset time range
intervalstringNodayAggregation: hour, day, week, month
project_idstringNonullFilter by project
team_idstringNonullFilter by team

Response

json
{
  "data_points": [
    {
      "timestamp": "2024-01-01T00:00:00Z",
      "carbon_gco2e": 180.5,
      "energy_kwh": 0.36,
      "requests": 2150,
      "tokens": 4500000,
      "avg_carbon_per_request": 0.084,
      "cache_hit_rate": 0.25
    },
    {
      "timestamp": "2024-01-02T00:00:00Z",
      "carbon_gco2e": 175.2,
      "energy_kwh": 0.35,
      "requests": 2100,
      "tokens": 4200000,
      "avg_carbon_per_request": 0.083,
      "cache_hit_rate": 0.28
    }
  ],
  "interval": "day",
  "date_range": {
    "start": "2024-01-01",
    "end": "2024-01-30"
  }
}

Data Point Fields

FieldTypeDescription
timestampstringISO 8601 timestamp
carbon_gco2enumberCarbon emissions in grams CO₂e
energy_kwhnumberEnergy consumption in kWh
requestsintegerNumber of requests
tokensintegerTotal tokens processed
avg_carbon_per_requestnumberAverage carbon per request
cache_hit_ratenumberCache hit percentage (0-1)

Interval Options

IntervalMax Time RangeUse Case
hour7 daysReal-time monitoring
day90 daysDaily trends
week1 yearWeekly reports
month2 yearsLong-term analysis

See Also

Built with reliability in mind.