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-05-16": {
"city": "Ribeirão Preto, SP",
"sunrise": "06:34 am",
"sunset": "05:40 pm",
"temp": {
"max": 28,
"min": 16,
"avg": 21.5
},
"humidity": {
"max": 99,
"min": 53,
"avg": 78.1
},
"cloudiness": {
"max": 0,
"min": 0,
"avg": 0
},
"rain": {
"max": 0,
"min": 0,
"avg": 0
},
"wind_speedy": {
"max": 3.1,
"min": 0,
"avg": 2.1
},
"hourly": {
"00:01": {
"temp": 18,
"humidity": 88,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 100,
"condition_code": "27",
"condition_slug": "clear_night"
},
"01:01": {
"temp": 18,
"humidity": 88,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 120,
"condition_code": "27",
"condition_slug": "clear_night"
},
"02:01": {
"temp": 18,
"humidity": 88,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 130,
"condition_code": "27",
"condition_slug": "clear_night"
},
"03:01": {
"temp": 17,
"humidity": 94,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.09 km/h",
"wind_direction": 130,
"condition_code": "27",
"condition_slug": "clear_night"
},
"04:01": {
"temp": 16,
"humidity": 94,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 110,
"condition_code": "27",
"condition_slug": "clear_night"
},
"05:01": {
"temp": 16,
"humidity": 94,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 110,
"condition_code": "27",
"condition_slug": "clear_night"
},
"06:01": {
"temp": 16,
"humidity": 94,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 110,
"condition_code": "27",
"condition_slug": "clear_night"
},
"07:01": {
"temp": 16,
"humidity": 94,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 100,
"condition_code": "27",
"condition_slug": "clear_day"
},
"08:01": {
"temp": 19,
"humidity": 99,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 110,
"condition_code": "27",
"condition_slug": "clear_day"
},
"09:01": {
"temp": 20,
"humidity": 94,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 120,
"condition_code": "27",
"condition_slug": "clear_day"
},
"10:01": {
"temp": 20,
"humidity": 77,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.09 km/h",
"wind_direction": 110,
"condition_code": "27",
"condition_slug": "clear_day"
},
"11:01": {
"temp": 22,
"humidity": 73,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 140,
"condition_code": "27",
"condition_slug": "clear_day"
},
"12:01": {
"temp": 24,
"humidity": 69,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 140,
"condition_code": "27",
"condition_slug": "clear_day"
},
"13:01": {
"temp": 27,
"humidity": 54,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 270,
"condition_code": "27",
"condition_slug": "clear_day"
},
"14:01": {
"temp": 28,
"humidity": 54,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.09 km/h",
"wind_direction": 280,
"condition_code": "27",
"condition_slug": "clear_day"
},
"15:01": {
"temp": 28,
"humidity": 53,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 270,
"condition_code": "27",
"condition_slug": "clear_day"
},
"16:01": {
"temp": 27,
"humidity": 56,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.09 km/h",
"wind_direction": 300,
"condition_code": "27",
"condition_slug": "clear_day"
},
"17:01": {
"temp": 27,
"humidity": 60,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 310,
"condition_code": "27",
"condition_slug": "clear_day"
},
"18:01": {
"temp": 27,
"humidity": 54,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 290,
"condition_code": "27",
"condition_slug": "clear_night"
},
"19:01": {
"temp": 25,
"humidity": 65,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 310,
"condition_code": "27",
"condition_slug": "clear_night"
},
"20:01": {
"temp": 23,
"humidity": 78,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "0 km/h",
"wind_direction": 0,
"condition_code": "27",
"condition_slug": "clear_night"
},
"21:01": {
"temp": 23,
"humidity": 78,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "0 km/h",
"wind_direction": 0,
"condition_code": "27",
"condition_slug": "clear_night"
},
"22:01": {
"temp": 21,
"humidity": 88,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 50,
"condition_code": "27",
"condition_slug": "clear_night"
},
"23:01": {
"temp": 21,
"humidity": 88,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 120,
"condition_code": "27",
"condition_slug": "clear_night"
}
}
},
"2026-05-15": {
"city": "Ribeirão Preto, SP",
"sunrise": "06:34 am",
"sunset": "05:41 pm",
"temp": {
"max": 27,
"min": 18,
"avg": 21.4
},
"humidity": {
"max": 98,
"min": 39,
"avg": 73.7
},
"cloudiness": {
"max": 100,
"min": 0,
"avg": 29.2
},
"rain": {
"max": 0,
"min": 0,
"avg": 0
},
"wind_speedy": {
"max": 5.7,
"min": 0.9,
"avg": 2.4
},
"hourly": {
"00:01": {
"temp": 22,
"humidity": 69,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 60,
"condition_code": "27",
"condition_slug": "clear_night"
},
"01:01": {
"temp": 18,
"humidity": 82,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 40,
"condition_code": "27",
"condition_slug": "clear_night"
},
"02:01": {
"temp": 22,
"humidity": 69,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 120,
"condition_code": "27",
"condition_slug": "clear_night"
},
"03:01": {
"temp": 18,
"humidity": 82,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 100,
"condition_code": "27",
"condition_slug": "clear_night"
},
"04:01": {
"temp": 21,
"humidity": 73,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "1.26 km/h",
"wind_direction": 108,
"condition_code": "28",
"condition_slug": "cloud"
},
"05:01": {
"temp": 18,
"humidity": 82,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 130,
"condition_code": "27",
"condition_slug": "clear_night"
},
"06:01": {
"temp": 20,
"humidity": 72,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 150,
"condition_code": "27",
"condition_slug": "clear_night"
},
"07:01": {
"temp": 20,
"humidity": 71,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 100,
"condition_code": "27",
"condition_slug": "clear_day"
},
"08:01": {
"temp": 20,
"humidity": 74,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "1.2 km/h",
"wind_direction": 137,
"condition_code": "28",
"condition_slug": "cloud"
},
"09:01": {
"temp": 22,
"humidity": 67,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 115,
"condition_code": "28",
"condition_slug": "cloud"
},
"10:01": {
"temp": 24,
"humidity": 55,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "0.88 km/h",
"wind_direction": 99,
"condition_code": "28",
"condition_slug": "cloud"
},
"11:01": {
"temp": 24,
"humidity": 57,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 100,
"condition_code": "27",
"condition_slug": "clear_day"
},
"12:01": {
"temp": 25,
"humidity": 53,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 120,
"condition_code": "27",
"condition_slug": "clear_day"
},
"13:01": {
"temp": 26,
"humidity": 44,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.6 km/h",
"wind_direction": 120,
"condition_code": "27",
"condition_slug": "clear_day"
},
"14:01": {
"temp": 27,
"humidity": 39,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.6 km/h",
"wind_direction": 170,
"condition_code": "27",
"condition_slug": "clear_day"
},
"15:01": {
"temp": 27,
"humidity": 39,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.6 km/h",
"wind_direction": 170,
"condition_code": "27",
"condition_slug": "clear_day"
},
"16:01": {
"temp": 20,
"humidity": 83,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "5.66 km/h",
"wind_direction": 220,
"condition_code": "28",
"condition_slug": "cloud"
},
"17:01": {
"temp": 22,
"humidity": 90,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "2.71 km/h",
"wind_direction": 195,
"condition_code": "28",
"condition_slug": "cloud"
},
"18:01": {
"temp": 20,
"humidity": 96,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 170,
"condition_code": "28",
"condition_slug": "cloud"
},
"19:01": {
"temp": 20,
"humidity": 96,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.09 km/h",
"wind_direction": 110,
"condition_code": "27",
"condition_slug": "clear_night"
},
"20:01": {
"temp": 20,
"humidity": 96,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "4.12 km/h",
"wind_direction": 100,
"condition_code": "27",
"condition_slug": "clear_night"
},
"21:01": {
"temp": 20,
"humidity": 98,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.6 km/h",
"wind_direction": 110,
"condition_code": "27",
"condition_slug": "clear_night"
},
"22:01": {
"temp": 18,
"humidity": 94,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.09 km/h",
"wind_direction": 110,
"condition_code": "27",
"condition_slug": "clear_night"
},
"23:01": {
"temp": 19,
"humidity": 88,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.09 km/h",
"wind_direction": 120,
"condition_code": "27",
"condition_slug": "clear_night"
}
}
},
"2026-05-14": {
"city": "Ribeirão Preto, SP",
"sunrise": "06:33 am",
"sunset": "05:41 pm",
"temp": {
"max": 28,
"min": 14,
"avg": 21.4
},
"humidity": {
"max": 88,
"min": 33,
"avg": 57.9
},
"cloudiness": {
"max": 100,
"min": 0,
"avg": 16.6
},
"rain": {
"max": 0,
"min": 0,
"avg": 0
},
"wind_speedy": {
"max": 3.1,
"min": 0,
"avg": 1.6
},
"hourly": {
"00:01": {
"temp": 19,
"humidity": 55,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 130,
"condition_code": "27",
"condition_slug": "clear_night"
},
"01:01": {
"temp": 17,
"humidity": 67,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 100,
"condition_code": "27",
"condition_slug": "clear_night"
},
"02:01": {
"temp": 17,
"humidity": 67,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 110,
"condition_code": "27",
"condition_slug": "clear_night"
},
"03:01": {
"temp": 16,
"humidity": 72,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 160,
"condition_code": "27",
"condition_slug": "clear_night"
},
"04:01": {
"temp": 15,
"humidity": 77,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 70,
"condition_code": "27",
"condition_slug": "clear_night"
},
"05:01": {
"temp": 14,
"humidity": 82,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 50,
"condition_code": "27",
"condition_slug": "clear_night"
},
"06:01": {
"temp": 14,
"humidity": 88,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 110,
"condition_code": "27",
"condition_slug": "clear_night"
},
"07:01": {
"temp": 19,
"humidity": 63,
"cloudiness": 99,
"rain": 0,
"wind_speedy": "1.67 km/h",
"wind_direction": 87,
"condition_code": "28",
"condition_slug": "cloud"
},
"08:01": {
"temp": 19,
"humidity": 63,
"cloudiness": 99,
"rain": 0,
"wind_speedy": "1.06 km/h",
"wind_direction": 101,
"condition_code": "28",
"condition_slug": "cloud"
},
"09:01": {
"temp": 20,
"humidity": 60,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "1 km/h",
"wind_direction": 91,
"condition_code": "28",
"condition_slug": "cloud"
},
"10:01": {
"temp": 18,
"humidity": 68,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 100,
"condition_code": "28",
"condition_slug": "cloud"
},
"11:01": {
"temp": 20,
"humidity": 64,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 100,
"condition_code": "27",
"condition_slug": "clear_day"
},
"12:01": {
"temp": 25,
"humidity": 43,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 50,
"condition_code": "27",
"condition_slug": "clear_day"
},
"13:01": {
"temp": 27,
"humidity": 36,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 70,
"condition_code": "27",
"condition_slug": "clear_day"
},
"14:01": {
"temp": 28,
"humidity": 33,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 30,
"condition_code": "27",
"condition_slug": "clear_day"
},
"15:01": {
"temp": 28,
"humidity": 34,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 290,
"condition_code": "27",
"condition_slug": "clear_day"
},
"16:01": {
"temp": 28,
"humidity": 35,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.09 km/h",
"wind_direction": 300,
"condition_code": "27",
"condition_slug": "clear_day"
},
"17:01": {
"temp": 27,
"humidity": 37,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.09 km/h",
"wind_direction": 250,
"condition_code": "27",
"condition_slug": "clear_day"
},
"18:01": {
"temp": 28,
"humidity": 34,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 210,
"condition_code": "27",
"condition_slug": "clear_night"
},
"19:01": {
"temp": 26,
"humidity": 41,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 0,
"condition_code": "27",
"condition_slug": "clear_night"
},
"20:01": {
"temp": 24,
"humidity": 57,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 0,
"condition_code": "27",
"condition_slug": "clear_night"
},
"21:01": {
"temp": 23,
"humidity": 64,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "0 km/h",
"wind_direction": 0,
"condition_code": "27",
"condition_slug": "clear_night"
},
"22:01": {
"temp": 21,
"humidity": 73,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 50,
"condition_code": "27",
"condition_slug": "clear_night"
},
"23:01": {
"temp": 20,
"humidity": 77,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "0 km/h",
"wind_direction": 0,
"condition_code": "27",
"condition_slug": "clear_night"
}
}
}
},
"execution_time": 2.13,
"from_cache": false
}