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-06-09": {
"city": "Ribeirão Preto, SP",
"sunrise": "06:44 am",
"sunset": "05:36 pm",
"temp": {
"max": 27,
"min": 15,
"avg": 20.1
},
"humidity": {
"max": 65,
"min": 30,
"avg": 47.8
},
"cloudiness": {
"max": 100,
"min": 62,
"avg": 90.2
},
"rain": {
"max": 0,
"min": 0,
"avg": 0
},
"wind_speedy": {
"max": 2.8,
"min": 0.6,
"avg": 1.4
},
"hourly": {
"00:01": {
"temp": 18,
"humidity": 50,
"cloudiness": 70,
"rain": 0,
"wind_speedy": "1.41 km/h",
"wind_direction": 127,
"condition_code": "28",
"condition_slug": "cloud"
},
"01:01": {
"temp": 18,
"humidity": 52,
"cloudiness": 77,
"rain": 0,
"wind_speedy": "1.38 km/h",
"wind_direction": 103,
"condition_code": "28",
"condition_slug": "cloud"
},
"02:01": {
"temp": 18,
"humidity": 52,
"cloudiness": 82,
"rain": 0,
"wind_speedy": "1.45 km/h",
"wind_direction": 101,
"condition_code": "28",
"condition_slug": "cloud"
},
"03:01": {
"temp": 17,
"humidity": 53,
"cloudiness": 80,
"rain": 0,
"wind_speedy": "1.18 km/h",
"wind_direction": 106,
"condition_code": "28",
"condition_slug": "cloud"
},
"04:01": {
"temp": 16,
"humidity": 55,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "1.1 km/h",
"wind_direction": 104,
"condition_code": "28",
"condition_slug": "cloud"
},
"05:01": {
"temp": 16,
"humidity": 57,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "1.12 km/h",
"wind_direction": 101,
"condition_code": "28",
"condition_slug": "cloud"
},
"06:01": {
"temp": 15,
"humidity": 64,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "1.39 km/h",
"wind_direction": 96,
"condition_code": "28",
"condition_slug": "cloud"
},
"07:01": {
"temp": 15,
"humidity": 61,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "1.21 km/h",
"wind_direction": 94,
"condition_code": "28",
"condition_slug": "cloud"
},
"08:01": {
"temp": 17,
"humidity": 65,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "0.82 km/h",
"wind_direction": 84,
"condition_code": "28",
"condition_slug": "cloud"
},
"09:01": {
"temp": 17,
"humidity": 60,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "0.94 km/h",
"wind_direction": 63,
"condition_code": "28",
"condition_slug": "cloud"
},
"10:01": {
"temp": 19,
"humidity": 55,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "1.09 km/h",
"wind_direction": 32,
"condition_code": "28",
"condition_slug": "cloud"
},
"11:01": {
"temp": 22,
"humidity": 49,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "1.16 km/h",
"wind_direction": 6,
"condition_code": "28",
"condition_slug": "cloud"
},
"12:01": {
"temp": 23,
"humidity": 41,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "1.53 km/h",
"wind_direction": 323,
"condition_code": "28",
"condition_slug": "cloud"
},
"13:01": {
"temp": 25,
"humidity": 35,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "2.13 km/h",
"wind_direction": 296,
"condition_code": "28",
"condition_slug": "cloud"
},
"14:01": {
"temp": 25,
"humidity": 33,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "2.49 km/h",
"wind_direction": 282,
"condition_code": "28",
"condition_slug": "cloud"
},
"15:01": {
"temp": 27,
"humidity": 30,
"cloudiness": 99,
"rain": 0,
"wind_speedy": "2.77 km/h",
"wind_direction": 277,
"condition_code": "28",
"condition_slug": "cloud"
},
"16:01": {
"temp": 26,
"humidity": 31,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "2.75 km/h",
"wind_direction": 265,
"condition_code": "28",
"condition_slug": "cloud"
},
"17:01": {
"temp": 25,
"humidity": 33,
"cloudiness": 94,
"rain": 0,
"wind_speedy": "1.6 km/h",
"wind_direction": 253,
"condition_code": "28",
"condition_slug": "cloud"
},
"18:01": {
"temp": 21,
"humidity": 38,
"cloudiness": 71,
"rain": 0,
"wind_speedy": "0.9 km/h",
"wind_direction": 223,
"condition_code": "28",
"condition_slug": "cloud"
},
"19:01": {
"temp": 19,
"humidity": 42,
"cloudiness": 67,
"rain": 0,
"wind_speedy": "0.61 km/h",
"wind_direction": 144,
"condition_code": "28",
"condition_slug": "cloud"
},
"20:01": {
"temp": 19,
"humidity": 44,
"cloudiness": 62,
"rain": 0,
"wind_speedy": "0.99 km/h",
"wind_direction": 116,
"condition_code": "28",
"condition_slug": "cloud"
},
"21:01": {
"temp": 23,
"humidity": 46,
"cloudiness": 66,
"rain": 0,
"wind_speedy": "0.63 km/h",
"wind_direction": 153,
"condition_code": "28",
"condition_slug": "cloud"
},
"22:01": {
"temp": 21,
"humidity": 50,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "0.96 km/h",
"wind_direction": 162,
"condition_code": "28",
"condition_slug": "cloud"
},
"23:01": {
"temp": 21,
"humidity": 52,
"cloudiness": 97,
"rain": 0,
"wind_speedy": "1.13 km/h",
"wind_direction": 143,
"condition_code": "28",
"condition_slug": "cloud"
}
}
},
"2026-06-08": {
"city": "Ribeirão Preto, SP",
"sunrise": "06:44 am",
"sunset": "05:36 pm",
"temp": {
"max": 26,
"min": 12,
"avg": 18.6
},
"humidity": {
"max": 69,
"min": 29,
"avg": 46.6
},
"cloudiness": {
"max": 93,
"min": 0,
"avg": 54
},
"rain": {
"max": 0,
"min": 0,
"avg": 0
},
"wind_speedy": {
"max": 2.4,
"min": 0.7,
"avg": 1.6
},
"hourly": {
"00:01": {
"temp": 14,
"humidity": 53,
"cloudiness": 93,
"rain": 0,
"wind_speedy": "1.48 km/h",
"wind_direction": 127,
"condition_code": "28",
"condition_slug": "cloud"
},
"01:01": {
"temp": 13,
"humidity": 53,
"cloudiness": 71,
"rain": 0,
"wind_speedy": "1.61 km/h",
"wind_direction": 123,
"condition_code": "28",
"condition_slug": "cloud"
},
"02:01": {
"temp": 13,
"humidity": 57,
"cloudiness": 63,
"rain": 0,
"wind_speedy": "1.69 km/h",
"wind_direction": 110,
"condition_code": "28",
"condition_slug": "cloud"
},
"03:01": {
"temp": 12,
"humidity": 58,
"cloudiness": 60,
"rain": 0,
"wind_speedy": "1.56 km/h",
"wind_direction": 108,
"condition_code": "28",
"condition_slug": "cloud"
},
"04:01": {
"temp": 12,
"humidity": 60,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.61 km/h",
"wind_direction": 114,
"condition_code": "27",
"condition_slug": "clear_night"
},
"05:01": {
"temp": 12,
"humidity": 62,
"cloudiness": 31,
"rain": 0,
"wind_speedy": "1.58 km/h",
"wind_direction": 113,
"condition_code": "29",
"condition_slug": "cloudly_night"
},
"06:01": {
"temp": 13,
"humidity": 63,
"cloudiness": 49,
"rain": 0,
"wind_speedy": "1.44 km/h",
"wind_direction": 103,
"condition_code": "29",
"condition_slug": "cloudly_night"
},
"07:01": {
"temp": 13,
"humidity": 64,
"cloudiness": 53,
"rain": 0,
"wind_speedy": "1.59 km/h",
"wind_direction": 106,
"condition_code": "28",
"condition_slug": "cloud"
},
"08:01": {
"temp": 14,
"humidity": 69,
"cloudiness": 60,
"rain": 0,
"wind_speedy": "1.26 km/h",
"wind_direction": 98,
"condition_code": "28",
"condition_slug": "cloud"
},
"09:01": {
"temp": 16,
"humidity": 66,
"cloudiness": 60,
"rain": 0,
"wind_speedy": "1.47 km/h",
"wind_direction": 75,
"condition_code": "28",
"condition_slug": "cloud"
},
"10:01": {
"temp": 21,
"humidity": 45,
"cloudiness": 21,
"rain": 0,
"wind_speedy": "1.83 km/h",
"wind_direction": 51,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"11:01": {
"temp": 22,
"humidity": 41,
"cloudiness": 61,
"rain": 0,
"wind_speedy": "1.51 km/h",
"wind_direction": 33,
"condition_code": "28",
"condition_slug": "cloud"
},
"12:01": {
"temp": 24,
"humidity": 35,
"cloudiness": 69,
"rain": 0,
"wind_speedy": "1.62 km/h",
"wind_direction": 350,
"condition_code": "28",
"condition_slug": "cloud"
},
"13:01": {
"temp": 25,
"humidity": 29,
"cloudiness": 53,
"rain": 0,
"wind_speedy": "2.28 km/h",
"wind_direction": 311,
"condition_code": "28",
"condition_slug": "cloud"
},
"14:01": {
"temp": 25,
"humidity": 29,
"cloudiness": 63,
"rain": 0,
"wind_speedy": "2.37 km/h",
"wind_direction": 301,
"condition_code": "28",
"condition_slug": "cloud"
},
"15:01": {
"temp": 25,
"humidity": 29,
"cloudiness": 39,
"rain": 0,
"wind_speedy": "2.39 km/h",
"wind_direction": 297,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"16:01": {
"temp": 26,
"humidity": 29,
"cloudiness": 56,
"rain": 0,
"wind_speedy": "2.31 km/h",
"wind_direction": 286,
"condition_code": "28",
"condition_slug": "cloud"
},
"17:01": {
"temp": 25,
"humidity": 29,
"cloudiness": 61,
"rain": 0,
"wind_speedy": "1.77 km/h",
"wind_direction": 270,
"condition_code": "28",
"condition_slug": "cloud"
},
"18:01": {
"temp": 23,
"humidity": 35,
"cloudiness": 66,
"rain": 0,
"wind_speedy": "1.4 km/h",
"wind_direction": 250,
"condition_code": "28",
"condition_slug": "cloud"
},
"19:01": {
"temp": 22,
"humidity": 39,
"cloudiness": 69,
"rain": 0,
"wind_speedy": "0.72 km/h",
"wind_direction": 203,
"condition_code": "28",
"condition_slug": "cloud"
},
"20:01": {
"temp": 17,
"humidity": 40,
"cloudiness": 68,
"rain": 0,
"wind_speedy": "0.99 km/h",
"wind_direction": 91,
"condition_code": "28",
"condition_slug": "cloud"
},
"21:01": {
"temp": 20,
"humidity": 41,
"cloudiness": 43,
"rain": 0,
"wind_speedy": "1.47 km/h",
"wind_direction": 62,
"condition_code": "29",
"condition_slug": "cloudly_night"
},
"22:01": {
"temp": 20,
"humidity": 44,
"cloudiness": 23,
"rain": 0,
"wind_speedy": "1.21 km/h",
"wind_direction": 162,
"condition_code": "29",
"condition_slug": "cloudly_night"
},
"23:01": {
"temp": 19,
"humidity": 48,
"cloudiness": 63,
"rain": 0,
"wind_speedy": "1.55 km/h",
"wind_direction": 179,
"condition_code": "28",
"condition_slug": "cloud"
}
}
},
"2026-06-07": {
"city": "Ribeirão Preto, SP",
"sunrise": "06:43 am",
"sunset": "05:36 pm",
"temp": {
"max": 26,
"min": 10,
"avg": 16.8
},
"humidity": {
"max": 73,
"min": 31,
"avg": 52
},
"cloudiness": {
"max": 100,
"min": 1,
"avg": 13.8
},
"rain": {
"max": 0,
"min": 0,
"avg": 0
},
"wind_speedy": {
"max": 1.6,
"min": 0.7,
"avg": 1.2
},
"hourly": {
"00:01": {
"temp": 13,
"humidity": 62,
"cloudiness": 1,
"rain": 0,
"wind_speedy": "1.44 km/h",
"wind_direction": 120,
"condition_code": "27",
"condition_slug": "clear_night"
},
"01:01": {
"temp": 12,
"humidity": 63,
"cloudiness": 1,
"rain": 0,
"wind_speedy": "1.2 km/h",
"wind_direction": 110,
"condition_code": "27",
"condition_slug": "clear_night"
},
"02:01": {
"temp": 12,
"humidity": 64,
"cloudiness": 1,
"rain": 0,
"wind_speedy": "1.28 km/h",
"wind_direction": 111,
"condition_code": "27",
"condition_slug": "clear_night"
},
"03:01": {
"temp": 11,
"humidity": 65,
"cloudiness": 2,
"rain": 0,
"wind_speedy": "1.35 km/h",
"wind_direction": 112,
"condition_code": "27",
"condition_slug": "clear_night"
},
"04:01": {
"temp": 11,
"humidity": 68,
"cloudiness": 6,
"rain": 0,
"wind_speedy": "1.37 km/h",
"wind_direction": 105,
"condition_code": "27",
"condition_slug": "clear_night"
},
"05:01": {
"temp": 11,
"humidity": 70,
"cloudiness": 6,
"rain": 0,
"wind_speedy": "1.39 km/h",
"wind_direction": 112,
"condition_code": "27",
"condition_slug": "clear_night"
},
"06:01": {
"temp": 10,
"humidity": 72,
"cloudiness": 6,
"rain": 0,
"wind_speedy": "1.36 km/h",
"wind_direction": 102,
"condition_code": "27",
"condition_slug": "clear_night"
},
"07:01": {
"temp": 10,
"humidity": 73,
"cloudiness": 7,
"rain": 0,
"wind_speedy": "1.28 km/h",
"wind_direction": 92,
"condition_code": "27",
"condition_slug": "clear_day"
},
"08:01": {
"temp": 14,
"humidity": 71,
"cloudiness": 8,
"rain": 0,
"wind_speedy": "1.18 km/h",
"wind_direction": 96,
"condition_code": "27",
"condition_slug": "clear_day"
},
"09:01": {
"temp": 15,
"humidity": 71,
"cloudiness": 9,
"rain": 0,
"wind_speedy": "1.13 km/h",
"wind_direction": 93,
"condition_code": "27",
"condition_slug": "clear_day"
},
"10:01": {
"temp": 19,
"humidity": 58,
"cloudiness": 9,
"rain": 0,
"wind_speedy": "1.28 km/h",
"wind_direction": 71,
"condition_code": "27",
"condition_slug": "clear_day"
},
"11:01": {
"temp": 22,
"humidity": 42,
"cloudiness": 8,
"rain": 0,
"wind_speedy": "0.68 km/h",
"wind_direction": 61,
"condition_code": "27",
"condition_slug": "clear_day"
},
"12:01": {
"temp": 24,
"humidity": 37,
"cloudiness": 7,
"rain": 0,
"wind_speedy": "0.7 km/h",
"wind_direction": 351,
"condition_code": "27",
"condition_slug": "clear_day"
},
"13:01": {
"temp": 23,
"humidity": 39,
"cloudiness": 7,
"rain": 0,
"wind_speedy": "1.14 km/h",
"wind_direction": 314,
"condition_code": "27",
"condition_slug": "clear_day"
},
"14:01": {
"temp": 26,
"humidity": 31,
"cloudiness": 7,
"rain": 0,
"wind_speedy": "1.4 km/h",
"wind_direction": 300,
"condition_code": "27",
"condition_slug": "clear_day"
},
"15:01": {
"temp": 25,
"humidity": 34,
"cloudiness": 6,
"rain": 0,
"wind_speedy": "1.25 km/h",
"wind_direction": 292,
"condition_code": "27",
"condition_slug": "clear_day"
},
"16:01": {
"temp": 25,
"humidity": 31,
"cloudiness": 5,
"rain": 0,
"wind_speedy": "1.18 km/h",
"wind_direction": 282,
"condition_code": "27",
"condition_slug": "clear_day"
},
"17:01": {
"temp": 24,
"humidity": 33,
"cloudiness": 5,
"rain": 0,
"wind_speedy": "1.08 km/h",
"wind_direction": 267,
"condition_code": "27",
"condition_slug": "clear_day"
},
"18:01": {
"temp": 19,
"humidity": 37,
"cloudiness": 6,
"rain": 0,
"wind_speedy": "1.06 km/h",
"wind_direction": 234,
"condition_code": "27",
"condition_slug": "clear_night"
},
"19:01": {
"temp": 17,
"humidity": 40,
"cloudiness": 6,
"rain": 0,
"wind_speedy": "1.13 km/h",
"wind_direction": 203,
"condition_code": "27",
"condition_slug": "clear_night"
},
"20:01": {
"temp": 16,
"humidity": 43,
"cloudiness": 3,
"rain": 0,
"wind_speedy": "1.12 km/h",
"wind_direction": 179,
"condition_code": "27",
"condition_slug": "clear_night"
},
"21:01": {
"temp": 15,
"humidity": 46,
"cloudiness": 15,
"rain": 0,
"wind_speedy": "1.33 km/h",
"wind_direction": 136,
"condition_code": "29",
"condition_slug": "cloudly_night"
},
"22:01": {
"temp": 15,
"humidity": 48,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "1.62 km/h",
"wind_direction": 114,
"condition_code": "28",
"condition_slug": "cloud"
},
"23:01": {
"temp": 14,
"humidity": 49,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "1.57 km/h",
"wind_direction": 117,
"condition_code": "28",
"condition_slug": "cloud"
}
}
}
},
"execution_time": 2.69,
"from_cache": false
}