SkyFeed / Guides

Weather forecast API without an API key, for agents

An agent that plans a trip or schedules an outdoor task needs a forecast, and signing up for a key per provider is friction it cannot do on its own.

The problem

Most weather APIs want an account, a key and often a credit card, and many free tiers forbid commercial use. A headless agent cannot complete that sign-up flow, and a key hard-coded in its prompt or environment is a liability if it leaks.

How /forecast answers it

GET /forecast takes a city (about 260 built-in major cities, no geocoder needed) or lat and lon, plus hours from 1 to 48 (default 24). Each hourly row has temperature in Celsius, wind in m/s and km/h with direction, humidity, cloud cover, pressure, precipitation in millimetres and a weather symbol such as clearsky_night. A summary block gives minimum and maximum temperature, peak wind, total precipitation, the number of wet hours and a one-line text you can paste into an answer. For the current hour only, /current returns the same fields for $0.003. The only credential is a USDC payment settled over x402, which an agent wallet can sign on its own.

Request and response

Example: the next two hours in Tokyo.

$ curl -i "https://skyfeed.imac2014ville.workers.dev/forecast?city=Tokyo&hours=2"
HTTP/2 402
payment-required: eyJ4NDAyVmVyc2lvbiI6Mi4uLn0=   # base64 JSON: scheme "exact", network eip155:8453,
                                                  # asset USDC, amount 5000 (= $0.005)
# An x402 client signs the payment, then retries with a PAYMENT-SIGNATURE header.

The paid response (sample at time of capture):

{
  "ok": true,
  "location": { "city": "Tokyo", "country": "JP", "lat": 35.677, "lon": 139.65 },
  "hours": 2,
  "summary": { "minTempC": 16.2, "maxTempC": 16.5, "maxWindMs": 2.2, "totalPrecipMm": 0, "wetHours": 0,
    "text": "16.2 to 16.5 C, 0 mm precipitation, peak wind 2.2 m/s over the next 2 h" },
  "forecast": [{
    "time": "2026-10-09T18:00:00Z", "tempC": 16.5, "windMs": 2.1, "windKmh": 7.6,
    "humidityPct": 83.9, "cloudPct": 0, "pressureHpa": 1023.3, "precipMm": 0,
    "symbol": "clearsky_night", "stepHours": 1
  }],
  "source": "MET Norway Locationforecast (CC BY 4.0)"
}

JavaScript with @x402/fetch

import { wrapFetchWithPaymentFromConfig } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm";
import { privateKeyToAccount } from "viem/accounts";

const signer = privateKeyToAccount(process.env.PRIVATE_KEY); // wallet holding USDC on Base
const pay = wrapFetchWithPaymentFromConfig(fetch, {
  schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(signer) }],
});
const res = await pay("https://skyfeed.imac2014ville.workers.dev/forecast?lat=48.8566&lon=2.3522&hours=24");
const { summary, forecast } = await res.json();
console.log(summary.text, forecast.filter(h => h.precipMm > 0.5).map(h => h.time));

Pricing

/forecast costs $0.005 per call. There is no API key and no account: each request is paid in USDC on Base over x402. Malformed input returns 400 and failed lookups return a non-2xx status, so those are not charged.

Limitations

More guides

Sister services