WeatherAPI
Real-time weather, forecasts, air quality, astronomy and historical weather with a generous free tier.
What it does
WeatherAPI.com offers current weather, forecasts up to 14 days, history, marine and astronomy data, air quality, weather alerts, time zone lookup, sports fixtures and IP/location search — all as JSON or XML from one keyed endpoint.
Base URL
Authentication
Sign up for a free API key and pass it as ?key=YOUR_KEY with a q= location (city name, lat,lon, postcode, IATA code, IP, or auto:ip).
Code examples
curl -s "https://api.weatherapi.com/v1/current.json?key=$WAPI_KEY&q=Nairobi&aqi=no"
import requests
r = requests.get("https://api.weatherapi.com/v1/forecast.json", params={
"key": KEY, "q": "Lisbon", "days": 3, "alerts": "yes"}, timeout=10)
fc = r.json()["forecast"]["forecastday"]
for d in fc:
print(d["date"], d["day"]["maxtemp_c"], d["day"]["condition"]["text"])Rate limits & quotas
Free plan: about 1,000,000 calls/month, with current conditions and a 3-day forecast, plus 7 days of history; longer forecasts, bulk requests and more history are paid. Over the quota you get HTTP 403 with error code 2007/2008.
Key response fields
| current.temp_c / temp_f | Current temperature |
| current.condition.text / .icon | Description and icon URL |
| forecast.forecastday[].day.maxtemp_c / mintemp_c | Daily extremes |
| forecast.forecastday[].astro | Sunrise, sunset, moon phase |
| location.tz_id / localtime | Time zone and local time of the location |
Common errors
| 401 / code 1002 | API key not provided. |
| 403 / code 2006 | API key invalid. |
| 403 / code 2007 | Monthly call quota exceeded. |
| 400 / code 1006 | No location found matching q. |
When to use it (and alternatives)
A great free commercial-friendly all-rounder when the 3-day forecast limit is acceptable — the huge monthly quota suits high-traffic sites. For longer free forecasts and history without a key, Open-Meteo wins; for richer data layers see Tomorrow.io.
FAQ
How many forecast days does the free plan give?
Three. The API accepts days up to 14, but free keys are capped at 3 — asking for more silently returns 3.
What can I put in the q parameter?
City name, "lat,lon", UK/US/Canada postcode, IATA airport code, an IP address, or auto:ip to use the caller’s IP.
Is air quality included for free?
Yes — add aqi=yes to current.json/forecast.json and the response includes an air_quality block.
New to APIs?
Short guides for working with this API — and any other.