# Weather API
GET/v1/weatherdata/forecast/hourly
GFS 0.25 degree hourly forecast at the nearest grid cell to a coordinate in the contiguous United States or Australia, 1 to 120 hours ahead (hourly to 48 h, then 3-hourly). Refreshes every 60 minutes or on a new model cycle.
Price
$0.005/ callEdge cache
1800s
Uptime 24h
100.00%
p95
258ms
MCP tool
weatherdata_forecast-hourly
The Weather API provides active weather alerts, current observations, and hourly and daily forecasts for the United States and Australia. It offers a normalized schema with a coverage field. The API includes endpoints for hourly forecasts, which can be retrieved using the GET method. Parameters include latitude, longitude, and hours. The data is refreshed every 60 minutes or on a new model cycle.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
| lat* | query | number | |
| lon* | query | number | |
| hours | query | integer = 48 |
Code
# 1. No key, no payment: the gateway answers 402 with the price
curl -i "https://api.realtimeapi.ai/v1/weatherdata/forecast/hourly?lat=-33.87&lon=151.21"
# 2. Pay: retry with a signed x402 payment (any x402 client builds this header)
curl "https://api.realtimeapi.ai/v1/weatherdata/forecast/hourly?lat=-33.87&lon=151.21" -H "PAYMENT-SIGNATURE: $X402_PAYMENT"// npm i @x402/fetch @x402/core @x402/evm viem
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { ExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = x402Client.fromConfig({ schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(privateKeyToAccount(PRIVATE_KEY)) }] });
const pay = wrapFetchWithPayment(fetch, client);
const data = await (await pay("https://api.realtimeapi.ai/v1/weatherdata/forecast/hourly?lat=-33.87&lon=151.21")).json();
console.log(data);# pip install "x402[requests,evm]==2.27.0" eth-account
from eth_account import Account
from x402 import x402ClientSync
from x402.http.clients import x402_requests
from x402.mechanisms.evm import EthAccountSigner
from x402.mechanisms.evm.exact import register_exact_evm_client
client = x402ClientSync()
register_exact_evm_client(client, EthAccountSigner(Account.from_key(PRIVATE_KEY)))
session = x402_requests(client)
print(session.get("https://api.realtimeapi.ai/v1/weatherdata/forecast/hourly?lat=-33.87&lon=151.21").json())curl "https://api.realtimeapi.ai/v1/weatherdata/forecast/hourly?lat=-33.87&lon=151.21" -H "X-API-Key: $RTAPI_KEY"Frequently asked questions
What is the cost of the API?
The API costs $0.005 per request
What parameters are required for the hourly forecast endpoint?
The parameters required are lat, lon, and hours
How often is the data refreshed?
The data is refreshed every 60 minutes or on a new model cycle