Histórico
Weather
Acesse dados passados de previsão do tempo, essenciais para análises de tendências e comparações de desempenho ao longo do tempo.
Você pode obter dados históricos de previsão do tempo utilizando parâmetros que filtram por data.
Esse método necessita de um plano que tenha suporte à dados históricos.
Requisição
As requisições tem como base o seguinte endpoint:
GEThttps://api.hgbrasil.com/weather/historical?key=suachave
Você pode obter dados históricos de previsão do tempo para uma localizadade através de um dos seguintes métodos:
; ; ; .
Para definir o intervalo de dados a serem consultados, você pode utilizar um dos seguintes métodos:
Por intervalo de datas
start_date
string
Data de inicio no formato
yyyy-mm-dd.end_date
string
Data de término no formato
yyyy-mm-dd.Por uma data específica
date
string
Data no formato
yyyy-mm-dd.Por número de dias atrás
days_ago
number
Número de dias atrás.
Modos
Juntamente com uma das datas, é possível definir o modo de retorno dos dados:
mode
string
As opções são
all, hourly (apenas os registros por hora) ou summary (apenas o resumo).Exemplo
Logo, você provavelmente irá utilizar um endpoint como o seguinte:
GEThttps://api.hgbrasil.com/weather/historical?woeid=455903&days_ago=3&mode=all&key=suachave
curl -X GET "https://api.hgbrasil.com/weather/historical?woeid=455903&days_ago=3&mode=all&key=suachave"
const url = new URL("/weather/historical", "https://api.hgbrasil.com")
url.searchParams.set("woeid", "455903")
url.searchParams.set("days_ago", "3")
url.searchParams.set("mode", "all")
url.searchParams.set("key", "suachave")
const response = await fetch(url.href)
const data = await response.json()
$url = 'https://api.hgbrasil.com/weather/historical';
$queryString = http_build_query([
'woeid' => '455903',
'days_ago' => '3',
'mode' => 'all',
'key' => 'suachave'
]);
$response = file_get_contents($url . '?' . $queryString);
$data = json_decode($response, true);
import requests
url = 'https://api.hgbrasil.com/weather/historical'
params = {
'woeid': '455903',
'days_ago': '3',
'mode': 'all',
'key': 'suachave'
}
response = requests.get(url, params=params)
data = response.json()
require 'net/http'
require 'uri'
require 'json'
uri = URI('https://api.hgbrasil.com/weather/historical')
uri.query = URI.encode_www_form({
woeid: '455903',
days_ago: '3',
mode: 'all',
key: 'suachave'
})
response = Net::HTTP.get(uri)
data = JSON.parse(response, symbolize_names: true)
import java.net.URI;
import java.net.http.*;
var url = "https://api.hgbrasil.com/weather/historical?woeid=455903&days_ago=3&mode=all&key=suachave";
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder()
.uri(URI.create(url))
.GET()
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
var data = response.body();
using System.Net.Http;
using System.Text.Json;
using System.Web;
var client = new HttpClient();
var baseUrl = "https://api.hgbrasil.com/weather/historical";
var queryParams = HttpUtility.ParseQueryString(string.Empty);
queryParams["woeid"] = "455903";
queryParams["days_ago"] = "3";
queryParams["mode"] = "all";
queryParams["key"] = "suachave";
var url = $"{baseUrl}?{queryParams}";
var response = await client.GetStringAsync(url);
var data = JsonSerializer.Deserialize<dynamic>(response);
Resposta
{
"by": "days_ago",
"mode": "all",
"valid_key": true,
"city_woeid": 455903,
"results": {
"2026-02-18": {
"city": "Ribeirão Preto, SP",
"sunrise": "06:03 am",
"sunset": "06:47 pm",
"temp": {
"max": 31,
"min": 21,
"avg": 24.8
},
"humidity": {
"max": 94,
"min": 48,
"avg": 73.6
},
"cloudiness": {
"max": 100,
"min": 0,
"avg": 23.8
},
"rain": {
"max": 1.1,
"min": 0,
"avg": 0.1
},
"wind_speedy": {
"max": 6.2,
"min": 0,
"avg": 2.7
},
"hourly": {
"00:01": {
"temp": 23,
"humidity": 78,
"cloudiness": 75,
"rain": 0.21,
"wind_speedy": "5.66 km/h",
"wind_direction": 170,
"condition_code": "4",
"condition_slug": "storm"
},
"01:01": {
"temp": 23,
"humidity": 78,
"cloudiness": 75,
"rain": 0,
"wind_speedy": "6.17 km/h",
"wind_direction": 180,
"condition_code": "28",
"condition_slug": "cloud"
},
"02:01": {
"temp": 21,
"humidity": 88,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "3.6 km/h",
"wind_direction": 80,
"condition_code": "28",
"condition_slug": "cloud"
},
"03:01": {
"temp": 21,
"humidity": 88,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "3.6 km/h",
"wind_direction": 70,
"condition_code": "28",
"condition_slug": "cloud"
},
"04:01": {
"temp": 21,
"humidity": 88,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 0,
"condition_code": "27",
"condition_slug": "clear_night"
},
"05:01": {
"temp": 21,
"humidity": 94,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 140,
"condition_code": "27",
"condition_slug": "clear_night"
},
"06:01": {
"temp": 21,
"humidity": 88,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.6 km/h",
"wind_direction": 140,
"condition_code": "27",
"condition_slug": "clear_night"
},
"07:01": {
"temp": 21,
"humidity": 88,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 100,
"condition_code": "27",
"condition_slug": "clear_day"
},
"08:01": {
"temp": 21,
"humidity": 94,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 100,
"condition_code": "27",
"condition_slug": "clear_day"
},
"09:01": {
"temp": 23,
"humidity": 83,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 70,
"condition_code": "27",
"condition_slug": "clear_day"
},
"10:01": {
"temp": 25,
"humidity": 73,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 320,
"condition_code": "27",
"condition_slug": "clear_day"
},
"11:01": {
"temp": 29,
"humidity": 59,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 310,
"condition_code": "27",
"condition_slug": "clear_day"
},
"12:01": {
"temp": 31,
"humidity": 48,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 280,
"condition_code": "27",
"condition_slug": "clear_day"
},
"13:01": {
"temp": 29,
"humidity": 58,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.09 km/h",
"wind_direction": 290,
"condition_code": "27",
"condition_slug": "clear_day"
},
"14:01": {
"temp": 30,
"humidity": 54,
"cloudiness": 20,
"rain": 0,
"wind_speedy": "3.6 km/h",
"wind_direction": 300,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"15:01": {
"temp": 30,
"humidity": 48,
"cloudiness": 20,
"rain": 0,
"wind_speedy": "3.09 km/h",
"wind_direction": 310,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"16:01": {
"temp": 31,
"humidity": 51,
"cloudiness": 40,
"rain": 0,
"wind_speedy": "3.6 km/h",
"wind_direction": 290,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"17:01": {
"temp": 27,
"humidity": 62,
"cloudiness": 40,
"rain": 0.25,
"wind_speedy": "4.12 km/h",
"wind_direction": 230,
"condition_code": "40",
"condition_slug": "rain"
},
"18:01": {
"temp": 27,
"humidity": 66,
"cloudiness": 40,
"rain": 0.15,
"wind_speedy": "3.6 km/h",
"wind_direction": 210,
"condition_code": "40",
"condition_slug": "rain"
},
"19:01": {
"temp": 25,
"humidity": 73,
"cloudiness": 40,
"rain": 0.7,
"wind_speedy": "4.12 km/h",
"wind_direction": 200,
"condition_code": "40",
"condition_slug": "rain"
},
"20:01": {
"temp": 24,
"humidity": 73,
"cloudiness": 20,
"rain": 1.08,
"wind_speedy": "0.51 km/h",
"wind_direction": 0,
"condition_code": "45",
"condition_slug": "rain"
},
"21:01": {
"temp": 24,
"humidity": 78,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 40,
"condition_code": "27",
"condition_slug": "clear_night"
},
"22:01": {
"temp": 24,
"humidity": 78,
"cloudiness": 0,
"rain": 0.45,
"wind_speedy": "0 km/h",
"wind_direction": 0,
"condition_code": "40",
"condition_slug": "rain"
},
"23:01": {
"temp": 24,
"humidity": 78,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 0,
"condition_code": "27",
"condition_slug": "clear_night"
}
}
},
"2026-02-17": {
"city": "Ribeirão Preto, SP",
"sunrise": "06:02 am",
"sunset": "06:47 pm",
"temp": {
"max": 34,
"min": 21,
"avg": 27.5
},
"humidity": {
"max": 88,
"min": 29,
"avg": 58.3
},
"cloudiness": {
"max": 75,
"min": 0,
"avg": 21.7
},
"rain": {
"max": 2.1,
"min": 0,
"avg": 0.1
},
"wind_speedy": {
"max": 5.7,
"min": 1,
"avg": 2.7
},
"hourly": {
"00:01": {
"temp": 25,
"humidity": 69,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 70,
"condition_code": "27",
"condition_slug": "clear_night"
},
"01:01": {
"temp": 24,
"humidity": 73,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.09 km/h",
"wind_direction": 110,
"condition_code": "27",
"condition_slug": "clear_night"
},
"02:01": {
"temp": 23,
"humidity": 78,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 100,
"condition_code": "27",
"condition_slug": "clear_night"
},
"03:01": {
"temp": 23,
"humidity": 78,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 110,
"condition_code": "27",
"condition_slug": "clear_night"
},
"04:01": {
"temp": 22,
"humidity": 83,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 100,
"condition_code": "27",
"condition_slug": "clear_night"
},
"05:01": {
"temp": 22,
"humidity": 78,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 120,
"condition_code": "27",
"condition_slug": "clear_night"
},
"06:01": {
"temp": 21,
"humidity": 88,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 140,
"condition_code": "27",
"condition_slug": "clear_night"
},
"07:01": {
"temp": 21,
"humidity": 88,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 70,
"condition_code": "27",
"condition_slug": "clear_day"
},
"08:01": {
"temp": 26,
"humidity": 65,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 100,
"condition_code": "27",
"condition_slug": "clear_day"
},
"09:01": {
"temp": 28,
"humidity": 57,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.09 km/h",
"wind_direction": 110,
"condition_code": "27",
"condition_slug": "clear_day"
},
"10:01": {
"temp": 30,
"humidity": 45,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 90,
"condition_code": "27",
"condition_slug": "clear_day"
},
"11:01": {
"temp": 30,
"humidity": 48,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 0,
"condition_code": "27",
"condition_slug": "clear_day"
},
"12:01": {
"temp": 32,
"humidity": 45,
"cloudiness": 20,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 360,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"13:01": {
"temp": 33,
"humidity": 35,
"cloudiness": 20,
"rain": 0,
"wind_speedy": "3.09 km/h",
"wind_direction": 320,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"14:01": {
"temp": 34,
"humidity": 36,
"cloudiness": 40,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 300,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"15:01": {
"temp": 34,
"humidity": 31,
"cloudiness": 40,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 250,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"16:01": {
"temp": 34,
"humidity": 31,
"cloudiness": 40,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 250,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"17:01": {
"temp": 34,
"humidity": 31,
"cloudiness": 20,
"rain": 0,
"wind_speedy": "4.12 km/h",
"wind_direction": 310,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"18:01": {
"temp": 34,
"humidity": 29,
"cloudiness": 20,
"rain": 0,
"wind_speedy": "3.6 km/h",
"wind_direction": 290,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"19:01": {
"temp": 33,
"humidity": 35,
"cloudiness": 20,
"rain": 0,
"wind_speedy": "3.09 km/h",
"wind_direction": 230,
"condition_code": "29",
"condition_slug": "cloudly_night"
},
"20:01": {
"temp": 26,
"humidity": 61,
"cloudiness": 75,
"rain": 0,
"wind_speedy": "5.14 km/h",
"wind_direction": 20,
"condition_code": "4",
"condition_slug": "storm"
},
"21:01": {
"temp": 23,
"humidity": 78,
"cloudiness": 75,
"rain": 0,
"wind_speedy": "5.66 km/h",
"wind_direction": 60,
"condition_code": "28",
"condition_slug": "cloud"
},
"22:01": {
"temp": 24,
"humidity": 69,
"cloudiness": 75,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 30,
"condition_code": "28",
"condition_slug": "cloud"
},
"23:01": {
"temp": 24,
"humidity": 69,
"cloudiness": 75,
"rain": 2.11,
"wind_speedy": "1.03 km/h",
"wind_direction": 230,
"condition_code": "45",
"condition_slug": "rain"
}
}
},
"2026-02-16": {
"city": "Ribeirão Preto, SP",
"sunrise": "06:02 am",
"sunset": "06:48 pm",
"temp": {
"max": 35,
"min": 21,
"avg": 27.8
},
"humidity": {
"max": 83,
"min": 29,
"avg": 56.4
},
"cloudiness": {
"max": 40,
"min": 0,
"avg": 14.2
},
"rain": {
"max": 0,
"min": 0,
"avg": 0
},
"wind_speedy": {
"max": 4.1,
"min": 1,
"avg": 2.4
},
"hourly": {
"00:01": {
"temp": 26,
"humidity": 57,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 100,
"condition_code": "27",
"condition_slug": "clear_night"
},
"01:01": {
"temp": 25,
"humidity": 61,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 130,
"condition_code": "27",
"condition_slug": "clear_night"
},
"02:01": {
"temp": 24,
"humidity": 69,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 110,
"condition_code": "27",
"condition_slug": "clear_night"
},
"03:01": {
"temp": 22,
"humidity": 78,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 0,
"condition_code": "27",
"condition_slug": "clear_night"
},
"04:01": {
"temp": 22,
"humidity": 78,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 130,
"condition_code": "27",
"condition_slug": "clear_night"
},
"05:01": {
"temp": 21,
"humidity": 83,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 100,
"condition_code": "27",
"condition_slug": "clear_night"
},
"06:01": {
"temp": 21,
"humidity": 83,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 90,
"condition_code": "27",
"condition_slug": "clear_night"
},
"07:01": {
"temp": 21,
"humidity": 83,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 110,
"condition_code": "27",
"condition_slug": "clear_day"
},
"08:01": {
"temp": 22,
"humidity": 78,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 100,
"condition_code": "27",
"condition_slug": "clear_day"
},
"09:01": {
"temp": 29,
"humidity": 54,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 90,
"condition_code": "27",
"condition_slug": "clear_day"
},
"10:01": {
"temp": 30,
"humidity": 50,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.6 km/h",
"wind_direction": 110,
"condition_code": "27",
"condition_slug": "clear_day"
},
"11:01": {
"temp": 32,
"humidity": 47,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "4.12 km/h",
"wind_direction": 80,
"condition_code": "27",
"condition_slug": "clear_day"
},
"12:01": {
"temp": 33,
"humidity": 40,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.6 km/h",
"wind_direction": 90,
"condition_code": "27",
"condition_slug": "clear_day"
},
"13:01": {
"temp": 33,
"humidity": 37,
"cloudiness": 40,
"rain": 0,
"wind_speedy": "3.6 km/h",
"wind_direction": 50,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"14:01": {
"temp": 34,
"humidity": 33,
"cloudiness": 40,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 0,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"15:01": {
"temp": 34,
"humidity": 36,
"cloudiness": 40,
"rain": 0,
"wind_speedy": "3.09 km/h",
"wind_direction": 110,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"16:01": {
"temp": 35,
"humidity": 29,
"cloudiness": 40,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 120,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"17:01": {
"temp": 33,
"humidity": 33,
"cloudiness": 40,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 0,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"18:01": {
"temp": 33,
"humidity": 35,
"cloudiness": 40,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 50,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"19:01": {
"temp": 31,
"humidity": 45,
"cloudiness": 40,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 230,
"condition_code": "29",
"condition_slug": "cloudly_night"
},
"20:01": {
"temp": 29,
"humidity": 54,
"cloudiness": 40,
"rain": 0,
"wind_speedy": "3.6 km/h",
"wind_direction": 30,
"condition_code": "29",
"condition_slug": "cloudly_night"
},
"21:01": {
"temp": 26,
"humidity": 61,
"cloudiness": 20,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 10,
"condition_code": "29",
"condition_slug": "cloudly_night"
},
"22:01": {
"temp": 26,
"humidity": 61,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 120,
"condition_code": "27",
"condition_slug": "clear_night"
},
"23:01": {
"temp": 25,
"humidity": 69,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 100,
"condition_code": "27",
"condition_slug": "clear_night"
}
}
}
},
"execution_time": 2.18,
"from_cache": false
}