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:
- Obter pelo nome da cidade;
- Obter pelo código WOEID da cidade;
- Obter por coordenadas de latitude e longitude;
- Obter por geolocalização IP.
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-07-08": {
"city": "Ribeirão Preto, SP",
"sunrise": "06:49 am",
"sunset": "05:43 pm",
"temp": {
"max": 26,
"min": 13,
"avg": 20.4
},
"humidity": {
"max": 100,
"min": 42,
"avg": 68.8
},
"cloudiness": {
"max": 100,
"min": 2,
"avg": 36.3
},
"rain": {
"max": 0,
"min": 0,
"avg": 0
},
"wind_speedy": {
"max": 1.4,
"min": 0.6,
"avg": 1
},
"hourly": {
"00:13": {
"temp": 20,
"humidity": 74,
"cloudiness": 9,
"rain": 0,
"wind_speedy": "0.73 km/h",
"wind_direction": 234,
"condition_code": "27",
"condition_slug": "clear_night"
},
"01:02": {
"temp": 20,
"humidity": 80,
"cloudiness": 8,
"rain": 0,
"wind_speedy": "0.71 km/h",
"wind_direction": 212,
"condition_code": "27",
"condition_slug": "clear_night"
},
"02:01": {
"temp": 18,
"humidity": 81,
"cloudiness": 11,
"rain": 0,
"wind_speedy": "0.56 km/h",
"wind_direction": 182,
"condition_code": "29",
"condition_slug": "cloudly_night"
},
"03:01": {
"temp": 18,
"humidity": 83,
"cloudiness": 27,
"rain": 0,
"wind_speedy": "0.83 km/h",
"wind_direction": 158,
"condition_code": "29",
"condition_slug": "cloudly_night"
},
"04:01": {
"temp": 17,
"humidity": 84,
"cloudiness": 29,
"rain": 0,
"wind_speedy": "1.22 km/h",
"wind_direction": 147,
"condition_code": "29",
"condition_slug": "cloudly_night"
},
"05:01": {
"temp": 14,
"humidity": 87,
"cloudiness": 17,
"rain": 0,
"wind_speedy": "1.15 km/h",
"wind_direction": 130,
"condition_code": "29",
"condition_slug": "cloudly_night"
},
"06:01": {
"temp": 13,
"humidity": 88,
"cloudiness": 27,
"rain": 0,
"wind_speedy": "1.18 km/h",
"wind_direction": 126,
"condition_code": "29",
"condition_slug": "cloudly_night"
},
"07:01": {
"temp": 15,
"humidity": 89,
"cloudiness": 22,
"rain": 0,
"wind_speedy": "1.1 km/h",
"wind_direction": 126,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"08:01": {
"temp": 18,
"humidity": 100,
"cloudiness": 23,
"rain": 0,
"wind_speedy": "1.15 km/h",
"wind_direction": 126,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"09:01": {
"temp": 19,
"humidity": 100,
"cloudiness": 32,
"rain": 0,
"wind_speedy": "1.16 km/h",
"wind_direction": 108,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"10:01": {
"temp": 20,
"humidity": 92,
"cloudiness": 68,
"rain": 0,
"wind_speedy": "1.17 km/h",
"wind_direction": 102,
"condition_code": "28",
"condition_slug": "cloud"
},
"11:01": {
"temp": 22,
"humidity": 75,
"cloudiness": 41,
"rain": 0,
"wind_speedy": "0.67 km/h",
"wind_direction": 78,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"12:40": {
"temp": 24,
"humidity": 49,
"cloudiness": 38,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 303,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"13:05": {
"temp": 24,
"humidity": 50,
"cloudiness": 38,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 303,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"14:01": {
"temp": 25,
"humidity": 46,
"cloudiness": 40,
"rain": 0,
"wind_speedy": "1.38 km/h",
"wind_direction": 295,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"15:01": {
"temp": 26,
"humidity": 43,
"cloudiness": 46,
"rain": 0,
"wind_speedy": "1.25 km/h",
"wind_direction": 296,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"16:01": {
"temp": 26,
"humidity": 42,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "1.25 km/h",
"wind_direction": 305,
"condition_code": "28",
"condition_slug": "cloud"
},
"17:01": {
"temp": 24,
"humidity": 42,
"cloudiness": 82,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 297,
"condition_code": "28",
"condition_slug": "cloud"
},
"18:01": {
"temp": 23,
"humidity": 48,
"cloudiness": 51,
"rain": 0,
"wind_speedy": "0.92 km/h",
"wind_direction": 291,
"condition_code": "28",
"condition_slug": "cloud"
},
"19:01": {
"temp": 22,
"humidity": 51,
"cloudiness": 57,
"rain": 0,
"wind_speedy": "0.87 km/h",
"wind_direction": 244,
"condition_code": "28",
"condition_slug": "cloud"
},
"20:01": {
"temp": 20,
"humidity": 55,
"cloudiness": 46,
"rain": 0,
"wind_speedy": "1.11 km/h",
"wind_direction": 213,
"condition_code": "29",
"condition_slug": "cloudly_night"
},
"21:02": {
"temp": 21,
"humidity": 62,
"cloudiness": 56,
"rain": 0,
"wind_speedy": "1.32 km/h",
"wind_direction": 193,
"condition_code": "28",
"condition_slug": "cloud"
},
"22:02": {
"temp": 20,
"humidity": 63,
"cloudiness": 2,
"rain": 0,
"wind_speedy": "1.19 km/h",
"wind_direction": 165,
"condition_code": "27",
"condition_slug": "clear_night"
},
"23:01": {
"temp": 20,
"humidity": 66,
"cloudiness": 2,
"rain": 0,
"wind_speedy": "1.1 km/h",
"wind_direction": 145,
"condition_code": "27",
"condition_slug": "clear_night"
}
}
},
"2026-07-07": {
"city": "Ribeirão Preto, SP",
"sunrise": "06:49 am",
"sunset": "05:42 pm",
"temp": {
"max": 27,
"min": 15,
"avg": 21.4
},
"humidity": {
"max": 93,
"min": 48,
"avg": 64.5
},
"cloudiness": {
"max": 72,
"min": 0,
"avg": 16.2
},
"rain": {
"max": 0,
"min": 0,
"avg": 0
},
"wind_speedy": {
"max": 4.1,
"min": 0.3,
"avg": 1.6
},
"hourly": {
"00:01": {
"temp": 17,
"humidity": 65,
"cloudiness": 4,
"rain": 0,
"wind_speedy": "0.32 km/h",
"wind_direction": 194,
"condition_code": "27",
"condition_slug": "clear_night"
},
"01:01": {
"temp": 20,
"humidity": 67,
"cloudiness": 3,
"rain": 0,
"wind_speedy": "0.33 km/h",
"wind_direction": 142,
"condition_code": "27",
"condition_slug": "clear_night"
},
"02:01": {
"temp": 16,
"humidity": 69,
"cloudiness": 2,
"rain": 0,
"wind_speedy": "0.63 km/h",
"wind_direction": 76,
"condition_code": "27",
"condition_slug": "clear_night"
},
"03:01": {
"temp": 15,
"humidity": 73,
"cloudiness": 2,
"rain": 0,
"wind_speedy": "0.77 km/h",
"wind_direction": 65,
"condition_code": "27",
"condition_slug": "clear_night"
},
"04:01": {
"temp": 17,
"humidity": 66,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "0.7 km/h",
"wind_direction": 74,
"condition_code": "27",
"condition_slug": "clear_night"
},
"05:01": {
"temp": 15,
"humidity": 76,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "0.7 km/h",
"wind_direction": 64,
"condition_code": "27",
"condition_slug": "clear_night"
},
"06:01": {
"temp": 18,
"humidity": 71,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "0.44 km/h",
"wind_direction": 87,
"condition_code": "27",
"condition_slug": "clear_night"
},
"07:01": {
"temp": 16,
"humidity": 66,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "0.68 km/h",
"wind_direction": 182,
"condition_code": "27",
"condition_slug": "clear_day"
},
"08:01": {
"temp": 18,
"humidity": 93,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "0.47 km/h",
"wind_direction": 138,
"condition_code": "27",
"condition_slug": "clear_day"
},
"09:01": {
"temp": 19,
"humidity": 83,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "0.37 km/h",
"wind_direction": 262,
"condition_code": "27",
"condition_slug": "clear_day"
},
"10:01": {
"temp": 20,
"humidity": 76,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.55 km/h",
"wind_direction": 245,
"condition_code": "27",
"condition_slug": "clear_day"
},
"11:01": {
"temp": 23,
"humidity": 73,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.5 km/h",
"wind_direction": 242,
"condition_code": "27",
"condition_slug": "clear_day"
},
"12:01": {
"temp": 24,
"humidity": 59,
"cloudiness": 1,
"rain": 0,
"wind_speedy": "2.68 km/h",
"wind_direction": 251,
"condition_code": "27",
"condition_slug": "clear_day"
},
"13:01": {
"temp": 24,
"humidity": 55,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.85 km/h",
"wind_direction": 270,
"condition_code": "27",
"condition_slug": "clear_day"
},
"14:01": {
"temp": 25,
"humidity": 54,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.73 km/h",
"wind_direction": 266,
"condition_code": "27",
"condition_slug": "clear_day"
},
"15:01": {
"temp": 27,
"humidity": 49,
"cloudiness": 6,
"rain": 0,
"wind_speedy": "4.13 km/h",
"wind_direction": 265,
"condition_code": "27",
"condition_slug": "clear_day"
},
"16:01": {
"temp": 26,
"humidity": 48,
"cloudiness": 42,
"rain": 0,
"wind_speedy": "3.71 km/h",
"wind_direction": 271,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"17:01": {
"temp": 25,
"humidity": 50,
"cloudiness": 48,
"rain": 0,
"wind_speedy": "2.89 km/h",
"wind_direction": 268,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"18:01": {
"temp": 26,
"humidity": 51,
"cloudiness": 58,
"rain": 0,
"wind_speedy": "2.02 km/h",
"wind_direction": 263,
"condition_code": "28",
"condition_slug": "cloud"
},
"19:01": {
"temp": 26,
"humidity": 54,
"cloudiness": 64,
"rain": 0,
"wind_speedy": "1.27 km/h",
"wind_direction": 269,
"condition_code": "28",
"condition_slug": "cloud"
},
"20:01": {
"temp": 26,
"humidity": 57,
"cloudiness": 69,
"rain": 0,
"wind_speedy": "1.15 km/h",
"wind_direction": 273,
"condition_code": "28",
"condition_slug": "cloud"
},
"21:01": {
"temp": 25,
"humidity": 59,
"cloudiness": 72,
"rain": 0,
"wind_speedy": "1.41 km/h",
"wind_direction": 280,
"condition_code": "28",
"condition_slug": "cloud"
},
"22:01": {
"temp": 25,
"humidity": 61,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.01 km/h",
"wind_direction": 258,
"condition_code": "27",
"condition_slug": "clear_night"
},
"23:01": {
"temp": 21,
"humidity": 72,
"cloudiness": 17,
"rain": 0,
"wind_speedy": "0.9 km/h",
"wind_direction": 245,
"condition_code": "29",
"condition_slug": "cloudly_night"
}
}
},
"2026-07-06": {
"city": "Ribeirão Preto, SP",
"sunrise": "06:49 am",
"sunset": "05:42 pm",
"temp": {
"max": 28,
"min": 14,
"avg": 20.5
},
"humidity": {
"max": 100,
"min": 35,
"avg": 63.5
},
"cloudiness": {
"max": 25,
"min": 1,
"avg": 8.6
},
"rain": {
"max": 0,
"min": 0,
"avg": 0
},
"wind_speedy": {
"max": 3.3,
"min": 0.4,
"avg": 1.5
},
"hourly": {
"00:01": {
"temp": 16,
"humidity": 71,
"cloudiness": 23,
"rain": 0,
"wind_speedy": "1.59 km/h",
"wind_direction": 141,
"condition_code": "29",
"condition_slug": "cloudly_night"
},
"01:01": {
"temp": 16,
"humidity": 74,
"cloudiness": 17,
"rain": 0,
"wind_speedy": "1.45 km/h",
"wind_direction": 130,
"condition_code": "29",
"condition_slug": "cloudly_night"
},
"02:01": {
"temp": 16,
"humidity": 75,
"cloudiness": 15,
"rain": 0,
"wind_speedy": "1.56 km/h",
"wind_direction": 115,
"condition_code": "29",
"condition_slug": "cloudly_night"
},
"03:01": {
"temp": 15,
"humidity": 79,
"cloudiness": 11,
"rain": 0,
"wind_speedy": "1.42 km/h",
"wind_direction": 115,
"condition_code": "29",
"condition_slug": "cloudly_night"
},
"04:01": {
"temp": 15,
"humidity": 81,
"cloudiness": 9,
"rain": 0,
"wind_speedy": "1.31 km/h",
"wind_direction": 125,
"condition_code": "27",
"condition_slug": "clear_night"
},
"05:01": {
"temp": 15,
"humidity": 84,
"cloudiness": 7,
"rain": 0,
"wind_speedy": "1.22 km/h",
"wind_direction": 127,
"condition_code": "27",
"condition_slug": "clear_night"
},
"06:01": {
"temp": 14,
"humidity": 85,
"cloudiness": 5,
"rain": 0,
"wind_speedy": "1.22 km/h",
"wind_direction": 106,
"condition_code": "27",
"condition_slug": "clear_night"
},
"07:01": {
"temp": 14,
"humidity": 87,
"cloudiness": 6,
"rain": 0,
"wind_speedy": "1.25 km/h",
"wind_direction": 109,
"condition_code": "27",
"condition_slug": "clear_day"
},
"08:01": {
"temp": 18,
"humidity": 71,
"cloudiness": 4,
"rain": 0,
"wind_speedy": "1.15 km/h",
"wind_direction": 112,
"condition_code": "27",
"condition_slug": "clear_day"
},
"09:01": {
"temp": 20,
"humidity": 100,
"cloudiness": 5,
"rain": 0,
"wind_speedy": "1.35 km/h",
"wind_direction": 112,
"condition_code": "27",
"condition_slug": "clear_day"
},
"10:01": {
"temp": 22,
"humidity": 94,
"cloudiness": 2,
"rain": 0,
"wind_speedy": "1.25 km/h",
"wind_direction": 108,
"condition_code": "27",
"condition_slug": "clear_day"
},
"11:01": {
"temp": 24,
"humidity": 70,
"cloudiness": 1,
"rain": 0,
"wind_speedy": "0.77 km/h",
"wind_direction": 78,
"condition_code": "27",
"condition_slug": "clear_day"
},
"12:01": {
"temp": 26,
"humidity": 47,
"cloudiness": 2,
"rain": 0,
"wind_speedy": "1.21 km/h",
"wind_direction": 310,
"condition_code": "27",
"condition_slug": "clear_day"
},
"13:01": {
"temp": 26,
"humidity": 40,
"cloudiness": 9,
"rain": 0,
"wind_speedy": "2.34 km/h",
"wind_direction": 297,
"condition_code": "27",
"condition_slug": "clear_day"
},
"14:01": {
"temp": 27,
"humidity": 37,
"cloudiness": 18,
"rain": 0,
"wind_speedy": "2.79 km/h",
"wind_direction": 296,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"15:01": {
"temp": 27,
"humidity": 35,
"cloudiness": 25,
"rain": 0,
"wind_speedy": "3.15 km/h",
"wind_direction": 288,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"16:01": {
"temp": 28,
"humidity": 35,
"cloudiness": 6,
"rain": 0,
"wind_speedy": "3.29 km/h",
"wind_direction": 281,
"condition_code": "27",
"condition_slug": "clear_day"
},
"17:01": {
"temp": 25,
"humidity": 38,
"cloudiness": 5,
"rain": 0,
"wind_speedy": "2.33 km/h",
"wind_direction": 277,
"condition_code": "27",
"condition_slug": "clear_day"
},
"18:01": {
"temp": 24,
"humidity": 44,
"cloudiness": 4,
"rain": 0,
"wind_speedy": "1.66 km/h",
"wind_direction": 271,
"condition_code": "27",
"condition_slug": "clear_night"
},
"19:01": {
"temp": 23,
"humidity": 48,
"cloudiness": 4,
"rain": 0,
"wind_speedy": "1.42 km/h",
"wind_direction": 252,
"condition_code": "27",
"condition_slug": "clear_night"
},
"20:01": {
"temp": 22,
"humidity": 50,
"cloudiness": 5,
"rain": 0,
"wind_speedy": "0.98 km/h",
"wind_direction": 250,
"condition_code": "27",
"condition_slug": "clear_night"
},
"21:02": {
"temp": 21,
"humidity": 54,
"cloudiness": 13,
"rain": 0,
"wind_speedy": "0.61 km/h",
"wind_direction": 247,
"condition_code": "29",
"condition_slug": "cloudly_night"
},
"22:02": {
"temp": 21,
"humidity": 61,
"cloudiness": 6,
"rain": 0,
"wind_speedy": "0.82 km/h",
"wind_direction": 208,
"condition_code": "27",
"condition_slug": "clear_night"
},
"23:01": {
"temp": 17,
"humidity": 63,
"cloudiness": 5,
"rain": 0,
"wind_speedy": "0.44 km/h",
"wind_direction": 184,
"condition_code": "27",
"condition_slug": "clear_night"
}
}
}
},
"execution_time": 3.21,
"from_cache": false
}