Visual Crossing Weather API
weather.visualcrossing.com · Science
Current, forecast, and 65+ years of historical weather data — JSON and CSV output. Free tier: 1,000 records/day, commercial use permitted with attribution.
Authentication
API Key
Free API key at visualcrossing.com. Pass as ?key= query parameter.
Sample Requests
GET
Weather timeline
Get current weather and 15-day forecast for London.
https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/London?key=YOUR_KEY&include=current&unitGroup=metric&contentType=json
Hover any highlighted part to learn what it does
curl -X GET "https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/London?key=YOUR_KEY&include=current&unitGroup=metric&contentType=json"
import requests
params = {
"key": "YOUR_KEY",
"include": "current",
"unitGroup": "metric",
"contentType": "json"
}
response = requests.get(
"https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/London",
params=params,
)
print(response.json())const url = new URL('https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/London');
url.searchParams.set('key', 'YOUR_KEY');
url.searchParams.set('include', 'current');
url.searchParams.set('unitGroup', 'metric');
url.searchParams.set('contentType', 'json');
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://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/London")
q := baseURL.Query()
q.Set("key", "YOUR_KEY")
q.Set("include", "current")
q.Set("unitGroup", "metric")
q.Set("contentType", "json")
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://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/London")
uri.query = URI.encode_www_form({
"key" => "YOUR_KEY",
"include" => "current",
"unitGroup" => "metric",
"contentType" => "json"
})
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://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/London?" . http_build_query([
"key" => "YOUR_KEY",
"include" => "current",
"unitGroup" => "metric",
"contentType" => "json"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));
GET
Historical weather
Get a week of historical weather data for New York.
https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/New York/2024-01-01/2024-01-07?key=YOUR_KEY&unitGroup=us&contentType=json
Hover any highlighted part to learn what it does
curl -X GET "https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/New York/2024-01-01/2024-01-07?key=YOUR_KEY&unitGroup=us&contentType=json"
import requests
params = {
"key": "YOUR_KEY",
"unitGroup": "us",
"contentType": "json"
}
response = requests.get(
"https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/New York/2024-01-01/2024-01-07",
params=params,
)
print(response.json())const url = new URL('https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/New York/2024-01-01/2024-01-07');
url.searchParams.set('key', 'YOUR_KEY');
url.searchParams.set('unitGroup', 'us');
url.searchParams.set('contentType', 'json');
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://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/New York/2024-01-01/2024-01-07")
q := baseURL.Query()
q.Set("key", "YOUR_KEY")
q.Set("unitGroup", "us")
q.Set("contentType", "json")
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://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/New York/2024-01-01/2024-01-07")
uri.query = URI.encode_www_form({
"key" => "YOUR_KEY",
"unitGroup" => "us",
"contentType" => "json"
})
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://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/New York/2024-01-01/2024-01-07?" . http_build_query([
"key" => "YOUR_KEY",
"unitGroup" => "us",
"contentType" => "json"
]);
$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 visualcrossing.com (1,000 records/day)
- Pass key=YOUR_KEY on every request
- Current + forecast: GET /timeline/{location}?key=KEY&contentType=json
- Historical: GET /timeline/{location}/{startDate}/{endDate}?key=KEY&contentType=json
- unitGroup: us (°F, mph), metric (°C, km/h), uk (°C, mph)