Skip to content

Degree days calculator

FREE with proof-of-workor $0.001 in USDCPOST /api/degree-days-calc

Heating, cooling and growing degree days from a daily temperature series you supply: daily means, or min/max pairs (the mean is their midpoint). Send POST /api/degree-days-calc with the required field days and pay $0.001 per call over x402 or MPP, or call it free by solving a proof-of-work challenge. It returns a JSON object with count, unit, base, growingBase, growingCap and 3 more.

Heating and cooling use one base (default 18 °C or 65 °F); growing degree days use their own base (default 10 °C or 50 °F) and an optional upper cutoff applied to each day's min and max. Returns the totals and each day's values, for up to 400 days.

Category: Live public dataTags: degree-days hdd cdd gdd energy agriculture calculator

Try in playground →

Parameters

NameTypeRequiredDescription
daysarrayyes1-400 days: each a daily mean temperature (number), or { min, max }, or { mean }
unitsstringnocelsius (default) or fahrenheit
basenumbernoBase for heating and cooling degree days (default 18 °C or 65 °F)
growingBasenumbernoBase for growing degree days (default 10 °C or 50 °F)
growingCapnumbernoOptional upper cutoff for growing degree days: each day's min and max are held at or below it

Example request

curl -i -X POST https://agent402.tools/api/degree-days-calc \
  -H "Content-Type: application/json" \
  -d '{"days":[{"min":8,"max":19},{"min":12,"max":24},{"min":15,"max":29}],"base":18,"growingBase":10}'

Without payment this returns HTTP 402 Payment Required with the exact price for degree-days-calc; any x402 v2 or MPP client pays it and retries.

Example response

{
  "count": 3,
  "unit": "°C",
  "base": 18,
  "growingBase": 10,
  "growingCap": null,
  "totals": {
    "heatingDegreeDays": 4.5,
    "coolingDegreeDays": 4,
    "growingDegreeDays": 23.5
  },
  "days": [
    {
      "mean": 13.5,
      "heating": 4.5,
      "cooling": 0,
      "growing": 3.5
    },
    {
      "mean": 18,
      "heating": 0,
      "cooling": 0,
      "growing": 8
    },
    {
      "mean": 22,
      "heating": 0,
      "cooling": 4,
      "growing": 12
    }
  ],
  "method": "Degree days per day: heating = max(0, base - mean), cooling = max(0, mean - base), growing = max(0, mean - growingBase); mean is (min + max) / 2 when a pair is given."
}
FieldTypeAlways presentIn the example
countnumberyes3
unitstringyes°C
basenumberyes18
growingBasenumberyes10
growingCapnullnonull
totalsobjectyes3 fields: heatingDegreeDays, coolingDegreeDays, growingDegreeDays
daysarray of objectsyes3 items in the example
methodstringyesDegree days per day: heating = max(0, base - mean), cooling = max(0, mean - b...

From an MCP client

catalog.call {
  "slug": "degree-days-calc",
  "params": {
    "days": [
      {
        "min": 8,
        "max": 19
      },
      {
        "min": 12,
        "max": 24
      },
      {
        "min": 15,
        "max": 29
      }
    ],
    "base": 18,
    "growingBase": 10
  }
}

On the hosted connector at https://agent402.tools/mcp, catalog.call runs degree-days-calc free (rate-limited, no wallet). Local install: npx -y agent402-mcp@0.13.32.

Errors and behavior

Paid call (JavaScript agent)

import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
client.setSpendControls?.({ maxAmountPerPayment: "$0.001" }); // refuse any quote above this tool's price
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agent402.tools/api/degree-days-calc", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "days": [
      {
        "min": 8,
        "max": 19
      },
      {
        "min": 12,
        "max": 24
      },
      {
        "min": 15,
        "max": 29
      }
    ],
    "base": 18,
    "growingBase": 10
  }),
});

No wallet? Pay with compute

Fetch a challenge, solve the sha256 puzzle (16 leading zero bits, a fraction of a second of CPU), and resend with the X-Pow-Solution header:

import { createHash } from "node:crypto";
const lz = (b) => { let t = 0; for (const x of b) { if (!x) { t += 8; continue; } t += Math.clz32(x) - 24; break; } return t; };
const c = await (await fetch("https://agent402.tools/api/pow/challenge?slug=degree-days-calc")).json();
let n = 0;
while (lz(createHash("sha256").update(c.challenge + ":" + n).digest()) < c.difficulty) n++;
await fetch("https://agent402.tools/api/degree-days-calc", { method: "POST", headers: { "X-Pow-Solution": c.token + ":" + n, "Content-Type": "application/json" }, body: JSON.stringify({"days":[{"min":8,"max":19},{"min":12,"max":24},{"min":15,"max":29}],"base":18,"growingBase":10}) });

Related tools

AQI calculator (US EPA)

FREE w/ computeor $0.001GET /api/aqi-calc

US EPA Air Quality Index from the pollutant concentrations you supply: PM2.5 and PM10 (µg/m³, 24-hour), ozone (ppb.

Heat index and wind chill calculator

FREE w/ computeor $0.001GET /api/heat-index-calc

Heat index, wind chill, humidex, dew point and wet-bulb temperature from the temperature, humidity and wind you supply.

A2A Agent Card validate

FREE w/ computeor $0.002POST /api/a2a-card-validate

Validate an A2A (Agent2Agent protocol) Agent Card: required fields, skill shape, transport names, capability flags.

Amortization schedule

FREE w/ computeor $0.001POST /api/amortization

Build the full per-period amortization schedule for a fully-amortizing loan.

Annuity present/future value

FREE w/ computeor $0.001POST /api/annuity

Present and future value of a level annuity (equal periodic payments).

Barcode / QR decode

FREE w/ computeor $0.001POST /api/barcode-decode

Decode a barcode or QR code from an image.