Weather forecast (US)

$0.001 per call · USDC via x402 · GET /api/weather-forecast · Cached 10m

Multi-period weather forecast for a US location from api.weather.gov (NWS, public domain). Send GET /api/weather-forecast with the required fields lat and lon and pay $0.001 per call over x402 or MPP (there is no free tier). It returns a JSON object with location, lat, lon and periods.

Give latitude and longitude; returns the place plus upcoming forecast periods (temp, wind, conditions). US coverage only. ?lat=40.71&lon=-74.01

Category: Live public data · Tags: weather forecast nws noaa us

TRY IN PLAYGROUND →

Parameters

NameTypeRequiredDescription
latnumberyeslatitude (US) Also accepted as latitude.
lonnumberyeslongitude (US) Also accepted as lng, long, longitude.

Example request

curl -i "https://agent402.tools/api/weather-forecast?lat=40.71&lon=-74.01"

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

Example response

{
  "location": {
    "city": "New York",
    "state": "NY"
  },
  "lat": 40.71,
  "lon": -74.01,
  "periods": [
    {
      "name": "Today",
      "temperature": 72,
      "unit": "F",
      "wind": "10 mph",
      "shortForecast": "Sunny"
    }
  ]
}
FieldTypeAlways presentIn the example
locationobjectyes2 fields: city, state
latnumberyes40.71
lonnumberyes-74.01
periodsarray of objectsyes1 item in the example

From an MCP client

catalog.call {
  "slug": "weather-forecast",
  "params": {
    "lat": 40.71,
    "lon": -74.01
  }
}

The hosted connector at https://agent402.tools/mcp needs a payment for weather-forecast; the stdio package pays it from a wallet or from AGENT402_CREDITS_KEY. Local install: npx -y agent402-mcp.

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?.(false); // keep your own spending ceiling in code
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agent402.tools/api/weather-forecast?lat=40.71&lon=-74.01");

Part of these workflows

Weather forecast (US) is one step in these 2 skill packs, each sold as a single call:

Related tools

US weather alerts

$0.002 · GET /api/weather-alerts

Active National Weather Service alerts for a US state as clean JSON: event, severity, headline, affected areas, onset/ex…

Daily forecast (global)

$0.002 · GET /api/weather-daily

7-day daily weather forecast for any location: high/low temp, precipitation sum and probability, max wind, UV index, sun…

Hourly forecast (global)

$0.002 · GET /api/weather-hourly

48-hour hourly weather forecast for any location: temperature, precipitation probability and amount, wind, cloud cover, …

Forecast backtest (MAPE + RMSE)

FREE w/ compute · or $0.001 · POST /api/forecast-eval

Backtest a forecasting method on the input series by holding out the last `testSize` observations, forecasting them, and…

Forecast (Holt linear trend)

FREE w/ compute · or $0.001 · POST /api/forecast-holt

Holt's linear trend method - level + trend (no seasonality). Two smoothing parameters: alpha (level) and beta (trend). F…

Forecast (Holt-Winters seasonal)

FREE w/ compute · or $0.001 · POST /api/forecast-holt-winters

Holt-Winters triple exponential smoothing - level + trend + seasonal component. Use for series with a repeating cycle (w…