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": {
"2025-12-29": {
"city": "Ribeirão Preto, SP",
"sunrise": "05:31 am",
"sunset": "06:55 pm",
"temp": {
"max": 37,
"min": 21,
"avg": 28.3
},
"humidity": {
"max": 94,
"min": 34,
"avg": 61.6
},
"cloudiness": {
"max": 100,
"min": 0,
"avg": 17.9
},
"rain": {
"max": 0,
"min": 0,
"avg": 0
},
"wind_speedy": {
"max": 7.7,
"min": 0,
"avg": 2.8
},
"hourly": {
"00:01": {
"temp": 25,
"humidity": 73,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "0.51 km/h",
"wind_direction": 40,
"condition_code": "27",
"condition_slug": "clear_night"
},
"01:01": {
"temp": 24,
"humidity": 78,
"cloudiness": 40,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 30,
"condition_code": "4",
"condition_slug": "storm"
},
"02:01": {
"temp": 22,
"humidity": 94,
"cloudiness": 100,
"rain": 0,
"wind_speedy": "3.6 km/h",
"wind_direction": 340,
"condition_code": "28",
"condition_slug": "cloud"
},
"03:01": {
"temp": 23,
"humidity": 88,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 240,
"condition_code": "27",
"condition_slug": "clear_night"
},
"04:01": {
"temp": 22,
"humidity": 94,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 0,
"condition_code": "27",
"condition_slug": "clear_night"
},
"05:01": {
"temp": 22,
"humidity": 88,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "0 km/h",
"wind_direction": 0,
"condition_code": "27",
"condition_slug": "clear_night"
},
"06:01": {
"temp": 21,
"humidity": 94,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 130,
"condition_code": "27",
"condition_slug": "clear_day"
},
"07:01": {
"temp": 25,
"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": 27,
"humidity": 62,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.6 km/h",
"wind_direction": 100,
"condition_code": "27",
"condition_slug": "clear_day"
},
"09:01": {
"temp": 29,
"humidity": 58,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.09 km/h",
"wind_direction": 90,
"condition_code": "27",
"condition_slug": "clear_day"
},
"10:01": {
"temp": 29,
"humidity": 53,
"cloudiness": 20,
"rain": 0,
"wind_speedy": "4.12 km/h",
"wind_direction": 110,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"11:01": {
"temp": 32,
"humidity": 48,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.09 km/h",
"wind_direction": 100,
"condition_code": "27",
"condition_slug": "clear_day"
},
"12:01": {
"temp": 34,
"humidity": 42,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 0,
"condition_code": "27",
"condition_slug": "clear_day"
},
"13:01": {
"temp": 36,
"humidity": 37,
"cloudiness": 20,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 150,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"14:01": {
"temp": 34,
"humidity": 43,
"cloudiness": 20,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 60,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"15:01": {
"temp": 37,
"humidity": 34,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.09 km/h",
"wind_direction": 50,
"condition_code": "27",
"condition_slug": "clear_day"
},
"16:01": {
"temp": 36,
"humidity": 36,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "4.63 km/h",
"wind_direction": 300,
"condition_code": "27",
"condition_slug": "clear_day"
},
"17:01": {
"temp": 34,
"humidity": 37,
"cloudiness": 40,
"rain": 0,
"wind_speedy": "4.12 km/h",
"wind_direction": 300,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"18:01": {
"temp": 33,
"humidity": 42,
"cloudiness": 75,
"rain": 0,
"wind_speedy": "7.72 km/h",
"wind_direction": 120,
"condition_code": "4",
"condition_slug": "storm"
},
"19:01": {
"temp": 29,
"humidity": 58,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "4.12 km/h",
"wind_direction": 90,
"condition_code": "27",
"condition_slug": "clear_night"
},
"20:01": {
"temp": 27,
"humidity": 57,
"cloudiness": 40,
"rain": 0,
"wind_speedy": "3.6 km/h",
"wind_direction": 110,
"condition_code": "29",
"condition_slug": "cloudly_night"
},
"21:01": {
"temp": 27,
"humidity": 61,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 90,
"condition_code": "27",
"condition_slug": "clear_night"
},
"22:01": {
"temp": 26,
"humidity": 65,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 140,
"condition_code": "27",
"condition_slug": "clear_night"
},
"23:01": {
"temp": 26,
"humidity": 65,
"cloudiness": 75,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 360,
"condition_code": "28",
"condition_slug": "cloud"
}
}
},
"2025-12-28": {
"city": "Ribeirão Preto, SP",
"sunrise": "05:30 am",
"sunset": "06:55 pm",
"temp": {
"max": 35,
"min": 21,
"avg": 27.2
},
"humidity": {
"max": 88,
"min": 34,
"avg": 64.7
},
"cloudiness": {
"max": 75,
"min": 0,
"avg": 20.8
},
"rain": {
"max": 0,
"min": 0,
"avg": 0
},
"wind_speedy": {
"max": 5.1,
"min": 0,
"avg": 2.2
},
"hourly": {
"00:01": {
"temp": 23,
"humidity": 83,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 30,
"condition_code": "27",
"condition_slug": "clear_night"
},
"01:01": {
"temp": 23,
"humidity": 83,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 110,
"condition_code": "27",
"condition_slug": "clear_night"
},
"02:01": {
"temp": 22,
"humidity": 88,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 80,
"condition_code": "27",
"condition_slug": "clear_night"
},
"03:01": {
"temp": 22,
"humidity": 83,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 140,
"condition_code": "27",
"condition_slug": "clear_night"
},
"04:01": {
"temp": 22,
"humidity": 83,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "0 km/h",
"wind_direction": 0,
"condition_code": "27",
"condition_slug": "clear_night"
},
"05:01": {
"temp": 21,
"humidity": 88,
"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": "2.06 km/h",
"wind_direction": 60,
"condition_code": "27",
"condition_slug": "clear_day"
},
"07:01": {
"temp": 21,
"humidity": 88,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "0.51 km/h",
"wind_direction": 290,
"condition_code": "27",
"condition_slug": "clear_day"
},
"08:01": {
"temp": 24,
"humidity": 73,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 0,
"condition_code": "27",
"condition_slug": "clear_day"
},
"09:01": {
"temp": 30,
"humidity": 50,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 0,
"condition_code": "27",
"condition_slug": "clear_day"
},
"10:01": {
"temp": 29,
"humidity": 58,
"cloudiness": 20,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 0,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"11:01": {
"temp": 32,
"humidity": 48,
"cloudiness": 20,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 0,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"12:01": {
"temp": 33,
"humidity": 46,
"cloudiness": 20,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 110,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"13:01": {
"temp": 33,
"humidity": 46,
"cloudiness": 40,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 0,
"condition_code": "4",
"condition_slug": "storm"
},
"14:01": {
"temp": 30,
"humidity": 58,
"cloudiness": 75,
"rain": 0,
"wind_speedy": "3.6 km/h",
"wind_direction": 30,
"condition_code": "28",
"condition_slug": "cloud"
},
"15:01": {
"temp": 35,
"humidity": 34,
"cloudiness": 75,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 0,
"condition_code": "28",
"condition_slug": "cloud"
},
"16:01": {
"temp": 32,
"humidity": 48,
"cloudiness": 40,
"rain": 0,
"wind_speedy": "3.09 km/h",
"wind_direction": 30,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"17:01": {
"temp": 34,
"humidity": 41,
"cloudiness": 75,
"rain": 0,
"wind_speedy": "5.14 km/h",
"wind_direction": 350,
"condition_code": "28",
"condition_slug": "cloud"
},
"18:01": {
"temp": 30,
"humidity": 49,
"cloudiness": 40,
"rain": 0,
"wind_speedy": "5.14 km/h",
"wind_direction": 360,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"19:01": {
"temp": 30,
"humidity": 49,
"cloudiness": 20,
"rain": 0,
"wind_speedy": "3.09 km/h",
"wind_direction": 350,
"condition_code": "29",
"condition_slug": "cloudly_night"
},
"20:01": {
"temp": 27,
"humidity": 65,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.09 km/h",
"wind_direction": 350,
"condition_code": "27",
"condition_slug": "clear_night"
},
"21:01": {
"temp": 27,
"humidity": 65,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 250,
"condition_code": "27",
"condition_slug": "clear_night"
},
"22:01": {
"temp": 27,
"humidity": 65,
"cloudiness": 75,
"rain": 0,
"wind_speedy": "3.09 km/h",
"wind_direction": 330,
"condition_code": "28",
"condition_slug": "cloud"
},
"23:01": {
"temp": 25,
"humidity": 73,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 350,
"condition_code": "27",
"condition_slug": "clear_night"
}
}
},
"2025-12-27": {
"city": "Ribeirão Preto, SP",
"sunrise": "05:29 am",
"sunset": "06:54 pm",
"temp": {
"max": 34,
"min": 24,
"avg": 28.1
},
"humidity": {
"max": 78,
"min": 40,
"avg": 60
},
"cloudiness": {
"max": 75,
"min": 0,
"avg": 12.9
},
"rain": {
"max": 0,
"min": 0,
"avg": 0
},
"wind_speedy": {
"max": 7.7,
"min": 1,
"avg": 3.3
},
"hourly": {
"00:01": {
"temp": 28,
"humidity": 57,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 240,
"condition_code": "27",
"condition_slug": "clear_night"
},
"01:01": {
"temp": 27,
"humidity": 65,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.03 km/h",
"wind_direction": 0,
"condition_code": "27",
"condition_slug": "clear_night"
},
"02:01": {
"temp": 26,
"humidity": 65,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 270,
"condition_code": "27",
"condition_slug": "clear_night"
},
"03:01": {
"temp": 26,
"humidity": 65,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 310,
"condition_code": "27",
"condition_slug": "clear_night"
},
"04:01": {
"temp": 25,
"humidity": 69,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 270,
"condition_code": "27",
"condition_slug": "clear_night"
},
"05:01": {
"temp": 24,
"humidity": 73,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 310,
"condition_code": "27",
"condition_slug": "clear_night"
},
"06:01": {
"temp": 24,
"humidity": 78,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "4.12 km/h",
"wind_direction": 150,
"condition_code": "27",
"condition_slug": "clear_day"
},
"07:01": {
"temp": 24,
"humidity": 78,
"cloudiness": 40,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 110,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"08:01": {
"temp": 29,
"humidity": 54,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.6 km/h",
"wind_direction": 110,
"condition_code": "27",
"condition_slug": "clear_day"
},
"09:01": {
"temp": 27,
"humidity": 69,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.6 km/h",
"wind_direction": 100,
"condition_code": "27",
"condition_slug": "clear_day"
},
"10:01": {
"temp": 29,
"humidity": 58,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "4.12 km/h",
"wind_direction": 100,
"condition_code": "27",
"condition_slug": "clear_day"
},
"11:01": {
"temp": 31,
"humidity": 55,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "4.12 km/h",
"wind_direction": 100,
"condition_code": "27",
"condition_slug": "clear_day"
},
"12:01": {
"temp": 31,
"humidity": 55,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "4.12 km/h",
"wind_direction": 120,
"condition_code": "27",
"condition_slug": "clear_day"
},
"13:01": {
"temp": 33,
"humidity": 45,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "4.12 km/h",
"wind_direction": 120,
"condition_code": "27",
"condition_slug": "clear_day"
},
"14:01": {
"temp": 34,
"humidity": 43,
"cloudiness": 40,
"rain": 0,
"wind_speedy": "3.09 km/h",
"wind_direction": 70,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"15:01": {
"temp": 32,
"humidity": 48,
"cloudiness": 40,
"rain": 0,
"wind_speedy": "3.6 km/h",
"wind_direction": 360,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"16:01": {
"temp": 34,
"humidity": 40,
"cloudiness": 40,
"rain": 0,
"wind_speedy": "4.12 km/h",
"wind_direction": 360,
"condition_code": "29",
"condition_slug": "cloudly_day"
},
"17:01": {
"temp": 31,
"humidity": 45,
"cloudiness": 75,
"rain": 0,
"wind_speedy": "7.72 km/h",
"wind_direction": 170,
"condition_code": "21",
"condition_slug": "fog"
},
"18:01": {
"temp": 28,
"humidity": 54,
"cloudiness": 75,
"rain": 0,
"wind_speedy": "6.69 km/h",
"wind_direction": 200,
"condition_code": "21",
"condition_slug": "fog"
},
"19:01": {
"temp": 28,
"humidity": 57,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.57 km/h",
"wind_direction": 190,
"condition_code": "27",
"condition_slug": "clear_night"
},
"20:01": {
"temp": 27,
"humidity": 65,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "3.6 km/h",
"wind_direction": 350,
"condition_code": "27",
"condition_slug": "clear_night"
},
"21:01": {
"temp": 27,
"humidity": 65,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "2.06 km/h",
"wind_direction": 270,
"condition_code": "27",
"condition_slug": "clear_night"
},
"22:01": {
"temp": 25,
"humidity": 69,
"cloudiness": 0,
"rain": 0,
"wind_speedy": "1.54 km/h",
"wind_direction": 270,
"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": 270,
"condition_code": "27",
"condition_slug": "clear_night"
}
}
}
},
"execution_time": 1.54,
"from_cache": false
}