Weather Aggregate

Weather Aggregate

Agriculture Math & Calculations Weather Credits / request: 3

Sum / mean / min / max, or the count of days crossing a threshold, for a chosen metric over a date range.

GET https://api.apikodu.com/api/v1/weather/aggregate
Documentation
Overview

Sum / mean / min / max for a chosen metric over a date range, or the number of days crossing a threshold per a comparator (op=count).

Authentication

Every request requires the x-api-key header. Credits used and remaining quota are returned in response headers (x-api-credits-used, x-api-remaining-credits, x-rate-limit-*).

Request
GET https://api.apikodu.com/api/v1/weather/aggregate?latitude=39.92&longitude=32.87&fromDate=2026-06-01&toDate=2026-06-30&metric=precip&op=sum
GET query.
Parameters
Name Type Required Default Options Description
latitude number * Required — — Point latitude -90..90.
longitude number * Required — — Point longitude -180..180.
fromDate string * Required 2026-06-01 — Start YYYY-MM-DD. Range ≤ 366 days.
toDate string * Required 2026-06-30 — End YYYY-MM-DD. At most yesterday (UTC): aggregates use observed days only.
metric string * Required precip temp tmin tmax precip snow wind humidity et0 temp, tmin, tmax, precip, snow, wind, humidity, et0.
op string * Required sum sum mean min max count sum, mean, min, max, count. count requires threshold.
threshold number Optional — — Threshold. Only for op=count.
comparator string Optional gt gt gte lt lte gt, gte, lt, lte. Default gt. Only for op=count.
Response
Name Type Description
metric string Metric used.
op string Operation used.
threshold number Threshold when op=count, else null.
comparator string Comparator when op=count, else null.
fromDate string Window start.
toDate string Window end.
daysTotal integer Calendar days in the window.
daysWithData integer Days the metric could be computed.
missingCount integer Days without data.
value number sum/mean/min/max result. null when op=count.
count integer Days crossing the threshold when op=count. null otherwise.
unit string Result unit (°C, mm, km/h, %). days when op=count.
gridLatitude number Latitude of the 0.1° grid corner around the request (interpolation reference).
gridLongitude number Longitude of the 0.1° grid corner.
gridInterpolated boolean true: values bilinearly blended from the 4 surrounding cells. false: single cell.
sources array Data sources that contributed: copernicus-era5-land, open-meteo, openweather, met-norway. For past days (older than about a week) Copernicus ERA5 / ERA5-Land takes precedence; UV, precipitation probability and the weather code of wet hours / days are derived from ERA5-Land variables, wind gust comes from ERA5 (0.25°); cloud cover and the weather code of dry hours / days are filled from other sources when available. At coastal / sea points ERA5-Land values come from the nearest land grid point.
disclaimer string Decision-support disclaimer and source attribution.
Errors
HTTP code Description
400 -257 latitude/longitude missing or out of range (lat -90..90, lon -180..180).
400 -258 fromDate/toDate not YYYY-MM-DD, range exceeds 366 days, or outside the last 2 years / after yesterday.
400 -259 granularity/days/hours/metric/op/comparator is invalid.
429 -316 Daily new location (cell) limit (50) reached. Previously requested locations keep working; new locations next day (UTC). Retry-After header gives seconds until end of day.
503 -261 No stored weather for this location yet. Cells were created; the collector is filling them. Retry shortly.
401 -100 x-api-key is missing, empty, malformed, inactive, banned, expired, IP-restricted, or not allowed for this API.
429 -221 Per-minute request limit exceeded. Response headers: x-rate-limit-limit, x-rate-limit-remaining, x-rate-limit-reset.
429 — Package credit quota cannot cover this request. Body may be { error, limit, currentUsage, requestCost } (no code field).
500 -1 Unexpected server error. message is a generic error text without technical details.
Notes
  • Success body is { data: { ... } }. Error body is { code, message }. code is an ApiResponseCode enum value (negative integer).

Sample response

{
  "data": {
    "gridLatitude": 39.90,
    "gridLongitude": 32.90,
    "gridInterpolated": true,
    "metric": "precip",
    "op": "sum",
    "threshold": null,
    "comparator": null,
    "fromDate": "2026-06-01",
    "toDate": "2026-06-30",
    "daysTotal": 30,
    "daysWithData": 30,
    "missingCount": 0,
    "value": 41.7,
    "count": null,
    "unit": "mm",
    "sources": [
      "open-meteo"
    ],
    "disclaimer": "Weather data aggregated from Copernicus ERA5 / ERA5-Land, Open-Meteo, OpenWeather and MET Norway. Contains modified Copernicus Climate Change Service information. Decision support only."
  }
}

Code samples

  
      const response = await fetch('https://api.apikodu.com/api/v1/weather/aggregate', {
        method: 'GET',
        headers: {
          'x-api-key': 'YOUR_API_KEY'
        }
      });

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

      headers = {
          'x-api-key': 'YOUR_API_KEY'
      }

      response = requests.get('https://api.apikodu.com/api/v1/weather/aggregate', headers=headers)
      print(response.json())
  
  
      using var client = new HttpClient();
      client.DefaultRequestHeaders.Add("x-api-key", "YOUR_API_KEY");

      var response = await client.GetStringAsync("https://api.apikodu.com/api/v1/weather/aggregate");
      Console.WriteLine(response);
  
  
      $response = file_get_contents('https://api.apikodu.com/api/v1/weather/aggregate', false, stream_context_create([
          'http' => [
              'header' => "x-api-key: YOUR_API_KEY"
          ]
      ]));

      print_r(json_decode($response, true));
  
  
      curl -X GET 'https://api.apikodu.com/api/v1/weather/aggregate' \
        -H 'x-api-key: YOUR_API_KEY'
  

Start building in minutes

Create a free account, get your API key and send your first request in minutes.

Get started free