WeatherAPI
api.weatherapi.com · Science
Current weather, forecasts, historical weather, marine, astronomy, and air quality for any location. Great documentation. Free tier: 1M calls/month.
Authentication
API Key
Free API key at weatherapi.com. Pass as ?key= query parameter.
Sample Requests
GET
Current weather
Get current weather and air quality for London.
https://api.weatherapi.com/v1/current.json?q=London&aqi=yes&key=YOUR_KEY
Hover any highlighted part to learn what it does
curl -X GET "https://api.weatherapi.com/v1/current.json?q=London&aqi=yes&key=YOUR_KEY"
import requests
params = {
"q": "London",
"aqi": "yes",
"key": "YOUR_KEY"
}
response = requests.get(
"https://api.weatherapi.com/v1/current.json",
params=params,
)
print(response.json())const url = new URL('https://api.weatherapi.com/v1/current.json');
url.searchParams.set('q', 'London');
url.searchParams.set('aqi', 'yes');
url.searchParams.set('key', 'YOUR_KEY');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.weatherapi.com/v1/current.json")
q := baseURL.Query()
q.Set("q", "London")
q.Set("aqi", "yes")
q.Set("key", "YOUR_KEY")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.weatherapi.com/v1/current.json")
uri.query = URI.encode_www_form({
"q" => "London",
"aqi" => "yes",
"key" => "YOUR_KEY"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.weatherapi.com/v1/current.json?" . http_build_query([
"q" => "London",
"aqi" => "yes",
"key" => "YOUR_KEY"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));
GET
3-day forecast
Get 3-day forecast for New York.
https://api.weatherapi.com/v1/forecast.json?q=New York&key=YOUR_KEY&days=3
Hover any highlighted part to learn what it does
curl -X GET "https://api.weatherapi.com/v1/forecast.json?q=New%20York&key=YOUR_KEY&days=3"
import requests
params = {
"q": "New York",
"key": "YOUR_KEY",
"days": "3"
}
response = requests.get(
"https://api.weatherapi.com/v1/forecast.json",
params=params,
)
print(response.json())const url = new URL('https://api.weatherapi.com/v1/forecast.json');
url.searchParams.set('q', 'New York');
url.searchParams.set('key', 'YOUR_KEY');
url.searchParams.set('days', '3');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.weatherapi.com/v1/forecast.json")
q := baseURL.Query()
q.Set("q", "New York")
q.Set("key", "YOUR_KEY")
q.Set("days", "3")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.weatherapi.com/v1/forecast.json")
uri.query = URI.encode_www_form({
"q" => "New York",
"key" => "YOUR_KEY",
"days" => "3"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.weatherapi.com/v1/forecast.json?" . http_build_query([
"q" => "New York",
"key" => "YOUR_KEY",
"days" => "3"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Postman Setup Guide
- Get a free API key at weatherapi.com
- Pass key=YOUR_KEY on all requests
- Location can be city name, lat/lon, zip code, or IP address
- Current: GET /current.json?key=KEY&q=Tokyo
- Forecast: GET /forecast.json?key=KEY&q=Paris&days=7
- History: GET /history.json?key=KEY&q=Rome&dt=2026-01-01