Histórico
Finance
Acesse dados passados dos ativos financeiros, essenciais para análises de tendências e comparações de desempenho ao longo do tempo.
Com este método, você pode acessar dados históricos de ações, FIIs, FIAgros, BDRs, moedas, índices e criptomoedas.
Esse método necessita de um de finanças.
Requisição
Os dados históricos são obtidos através do endpoint /v2/finance/historical com os seguintes parâmetros:
Ativos
symbols
string required
Um ou mais tickers separados por vírgula. Por exemplo, você pode consultar:
- Ativos: ações, FIIs, FIAgros, BDRs, ETFs e mais;
- Moedas: USDBRL, EURBRL, GBPBRL, ARSBRL, CADBRL, AUDBRL, JPYBRL, CNYBRL;
- Índices: BVSP, IFIX, IXIC, DJI, FCHI, N225, GSPC.
Granularidade
sample_by
string
Controla a granularidade do histórico retornado. Opções disponíveis:
1m: 1 minuto;5m: 5 minutos;15m: 15 minutos;30m: 30 minutos;1h: 1 hora;2h: 2 horas;1d: 1 dia;1M: 1 mês.
Dependendo do quão antigo é o histórico, algumas amostragens podem não estar disponíveis.
Filtros de data
Somente um dos três tipos de filtros abaixo poderá ser escolhido em cada requisição:
Por intervalo de datas
start_date
string
Data de início 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 específica no formato
yyyy-mm-dd.Por número de dias atrás
days_ago
number
Número de dias atrás. Informe
0 para obter dados de hoje.A data consultada deve estar dentro dos limites de dados históricos de finanças para seu plano.
Exemplos
Múltiplos ativos com granularidade diária
GEThttps://api.hgbrasil.com/v2/finance/historical?symbols=embr3,hglg11,usdbrl,bvsp&days_ago=3&sample_by=1d&key=suachave
curl -X GET "https://api.hgbrasil.com/v2/finance/historical?symbols=embr3%2Chglg11%2Cusdbrl%2Cbvsp&days_ago=3&sample_by=1d&key=suachave"
const url = new URL("/v2/finance/historical", "https://api.hgbrasil.com")
url.searchParams.set("symbols", "embr3,hglg11,usdbrl,bvsp")
url.searchParams.set("days_ago", "3")
url.searchParams.set("sample_by", "1d")
url.searchParams.set("key", "suachave")
const response = await fetch(url.href)
const data = await response.json()
$url = 'https://api.hgbrasil.com/v2/finance/historical';
$queryString = http_build_query([
'symbols' => 'embr3,hglg11,usdbrl,bvsp',
'days_ago' => '3',
'sample_by' => '1d',
'key' => 'suachave'
]);
$response = file_get_contents($url . '?' . $queryString);
$data = json_decode($response, true);
import requests
url = 'https://api.hgbrasil.com/v2/finance/historical'
params = {
'symbols': 'embr3,hglg11,usdbrl,bvsp',
'days_ago': '3',
'sample_by': '1d',
'key': 'suachave'
}
response = requests.get(url, params=params)
data = response.json()
require 'net/http'
require 'uri'
require 'json'
uri = URI('https://api.hgbrasil.com/v2/finance/historical')
uri.query = URI.encode_www_form({
symbols: 'embr3,hglg11,usdbrl,bvsp',
days_ago: '3',
sample_by: '1d',
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/v2/finance/historical?symbols=embr3%2Chglg11%2Cusdbrl%2Cbvsp&days_ago=3&sample_by=1d&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/v2/finance/historical";
var queryParams = HttpUtility.ParseQueryString(string.Empty);
queryParams["symbols"] = "embr3,hglg11,usdbrl,bvsp";
queryParams["days_ago"] = "3";
queryParams["sample_by"] = "1d";
queryParams["key"] = "suachave";
var url = $"{baseUrl}?{queryParams}";
var response = await client.GetStringAsync(url);
var data = JsonSerializer.Deserialize<dynamic>(response);
Resposta
{
"by": "days_ago",
"sample_by": "1d",
"valid_key": true,
"results": {
"BVSP": {
"2025-12-18T13:00:00.000000Z": {
"open": 157326.54,
"close": 157319.98,
"high": 157761.73,
"low": 157262.25,
"volume": 0
},
"2025-12-18T14:00:00.000000Z": {
"open": 157328.88,
"close": 157532.72,
"high": 157713.69,
"low": 157123.58000000002,
"volume": 0
},
"2025-12-18T15:00:00.000000Z": {
"open": 157579.86000000002,
"close": 158318.06,
"high": 158495.48,
"low": 157576.81,
"volume": 0
},
"2025-12-18T16:00:00.000000Z": {
"open": 158301.14,
"close": 158359.81,
"high": 158489.94,
"low": 158152.7,
"volume": 0
},
"2025-12-18T17:00:00.000000Z": {
"open": 158318.51,
"close": 158207.7,
"high": 158454.45,
"low": 157518.72,
"volume": 0
},
"2025-12-18T18:00:00.000000Z": {
"open": 158255.01,
"close": 158253.94,
"high": 158471.39,
"low": 158200.38,
"volume": 0
},
"2025-12-18T19:00:00.000000Z": {
"open": 158263.29,
"close": 157703.45,
"high": 158263.29,
"low": 157630.19,
"volume": 0
},
"2025-12-18T20:00:00.000000Z": {
"open": 157707.11000000002,
"close": 158163.42,
"high": 158255.48,
"low": 157707.11000000002,
"volume": 0
},
"2025-12-19T13:00:00.000000Z": {
"open": 157928.31,
"close": 158835.01,
"high": 158846.51,
"low": 157906.06,
"volume": 0
},
"2025-12-19T14:00:00.000000Z": {
"open": 158918.16,
"close": 159387.78,
"high": 159436.23,
"low": 158541.29,
"volume": 0
},
"2025-12-19T15:00:00.000000Z": {
"open": 159374.01,
"close": 159128.42,
"high": 159551.94,
"low": 158980.13,
"volume": 0
},
"2025-12-19T16:00:00.000000Z": {
"open": 159062.79,
"close": 159112.72,
"high": 159256.64,
"low": 158990.7,
"volume": 0
},
"2025-12-19T17:00:00.000000Z": {
"open": 159132.22,
"close": 158820.22,
"high": 159182.03,
"low": 158705.54,
"volume": 0
},
"2025-12-19T18:00:00.000000Z": {
"open": 158760.11000000002,
"close": 158658.88,
"high": 158850.44,
"low": 158607.91,
"volume": 0
},
"2025-12-19T19:00:00.000000Z": {
"open": 158673.59,
"close": 158687.86000000002,
"high": 158760.86000000002,
"low": 158573.89,
"volume": 0
},
"2025-12-19T20:00:00.000000Z": {
"open": 158694.83000000002,
"close": 158374.17,
"high": 158733.98,
"low": 158231.2,
"volume": 0
},
"2025-12-22T13:00:00.000000Z": {
"open": 158480.44,
"close": 158031.26,
"high": 158633.98,
"low": 157797.13,
"volume": 0
},
"2025-12-22T14:00:00.000000Z": {
"open": 158031.63,
"close": 157593.95,
"high": 158302.56,
"low": 157305.76,
"volume": 0
},
"2025-12-22T15:00:00.000000Z": {
"open": 157626.58000000002,
"close": 157968.91,
"high": 158125.73,
"low": 157568.2,
"volume": 0
},
"2025-12-22T16:00:00.000000Z": {
"open": 157965.16,
"close": 158349.56,
"high": 158414.51,
"low": 157901.95,
"volume": 0
},
"2025-12-22T17:00:00.000000Z": {
"open": 158289.08000000002,
"close": 158224.51,
"high": 158420.23,
"low": 158073.2,
"volume": 0
},
"2025-12-22T18:00:00.000000Z": {
"open": 158231.73,
"close": 158191.79,
"high": 158320.34,
"low": 157855.26,
"volume": 0
},
"2025-12-22T19:00:00.000000Z": {
"open": 158208.91,
"close": 158206.95,
"high": 158253.45,
"low": 157986.89,
"volume": 0
},
"2025-12-22T20:00:00.000000Z": {
"open": 158226.53,
"close": 158179.2,
"high": 158281.89,
"low": 158076.84,
"volume": 0
}
},
"HGLG11": {
"2025-12-18T13:00:00.000000Z": {
"open": 156.3,
"close": 156.29,
"high": 156.43,
"low": 156.14,
"volume": 17419
},
"2025-12-18T14:00:00.000000Z": {
"open": 156.28,
"close": 156.22,
"high": 156.46,
"low": 156.08,
"volume": 11542
},
"2025-12-18T15:00:00.000000Z": {
"open": 156.21,
"close": 156.29,
"high": 156.29,
"low": 156.19,
"volume": 9459
},
"2025-12-18T16:00:00.000000Z": {
"open": 156.28,
"close": 156.19,
"high": 156.28,
"low": 156.11,
"volume": 8123
},
"2025-12-18T17:00:00.000000Z": {
"open": 156.19,
"close": 156.22,
"high": 156.28,
"low": 156.13,
"volume": 12337
},
"2025-12-18T18:00:00.000000Z": {
"open": 156.22,
"close": 156.44,
"high": 156.44,
"low": 156.13,
"volume": 12948
},
"2025-12-18T19:00:00.000000Z": {
"open": 156.49,
"close": 156.18,
"high": 156.81,
"low": 156,
"volume": 20906
},
"2025-12-18T20:00:00.000000Z": {
"open": 156.16,
"close": 156,
"high": 156.22,
"low": 155.81,
"volume": 19031
},
"2025-12-19T13:00:00.000000Z": {
"open": 156.35,
"close": 156.91,
"high": 157.04,
"low": 156.32,
"volume": 12599
},
"2025-12-19T14:00:00.000000Z": {
"open": 156.94,
"close": 156.69,
"high": 157.1,
"low": 156.44,
"volume": 12902
},
"2025-12-19T15:00:00.000000Z": {
"open": 156.66,
"close": 156.92,
"high": 156.97,
"low": 156.59,
"volume": 12017
},
"2025-12-19T16:00:00.000000Z": {
"open": 156.92,
"close": 157.13,
"high": 157.21,
"low": 156.74,
"volume": 11913
},
"2025-12-19T17:00:00.000000Z": {
"open": 157.14,
"close": 157.24,
"high": 157.3,
"low": 156.93,
"volume": 10472
},
"2025-12-19T18:00:00.000000Z": {
"open": 157.24,
"close": 157.38,
"high": 157.41,
"low": 157.15,
"volume": 9535
},
"2025-12-19T19:00:00.000000Z": {
"open": 157.37,
"close": 157.37,
"high": 157.64,
"low": 157.29,
"volume": 13700
},
"2025-12-19T20:00:00.000000Z": {
"open": 157.44,
"close": 157.44,
"high": 157.47,
"low": 157.12,
"volume": 5218
},
"2025-12-22T13:00:00.000000Z": {
"open": 157.9,
"close": 157.97,
"high": 158.24,
"low": 157.53,
"volume": 15363
},
"2025-12-22T14:00:00.000000Z": {
"open": 157.94,
"close": 158.11,
"high": 158.22,
"low": 157.79,
"volume": 11881
},
"2025-12-22T15:00:00.000000Z": {
"open": 158.07,
"close": 158.19,
"high": 158.36,
"low": 158.05,
"volume": 14881
},
"2025-12-22T16:00:00.000000Z": {
"open": 158.19,
"close": 158.19,
"high": 158.25,
"low": 157.91,
"volume": 18966
},
"2025-12-22T17:00:00.000000Z": {
"open": 158.19,
"close": 157.97,
"high": 158.33,
"low": 157.71,
"volume": 14660
},
"2025-12-22T18:00:00.000000Z": {
"open": 157.97,
"close": 157.91,
"high": 158.1,
"low": 157.72,
"volume": 18280
},
"2025-12-22T19:00:00.000000Z": {
"open": 157.92,
"close": 157.91,
"high": 158.26,
"low": 157.55,
"volume": 17398
},
"2025-12-22T20:00:00.000000Z": {
"open": 157.91,
"close": 158.38,
"high": 158.38,
"low": 157.85,
"volume": 8022
}
},
"USDBRL": {
"2025-12-18T00:00:00.000000Z": {
"open": 5.52,
"close": 5.52,
"high": 5.52,
"low": 5.52,
"volume": 0
},
"2025-12-18T03:00:00.000000Z": {
"open": 5.52,
"close": 5.52,
"high": 5.52,
"low": 5.52,
"volume": 0
},
"2025-12-18T04:00:00.000000Z": {
"open": 5.52,
"close": 5.52,
"high": 5.52,
"low": 5.52,
"volume": 0
},
"2025-12-18T06:00:00.000000Z": {
"open": 5.52,
"close": 5.52,
"high": 5.52,
"low": 5.52,
"volume": 0
},
"2025-12-18T07:00:00.000000Z": {
"open": 5.51,
"close": 5.51,
"high": 5.51,
"low": 5.51,
"volume": 0
},
"2025-12-18T10:00:00.000000Z": {
"open": 5.52,
"close": 5.52,
"high": 5.52,
"low": 5.52,
"volume": 0
},
"2025-12-18T11:00:00.000000Z": {
"open": 5.52,
"close": 5.52,
"high": 5.52,
"low": 5.52,
"volume": 0
},
"2025-12-18T12:00:00.000000Z": {
"open": 5.51,
"close": 5.56,
"high": 5.56,
"low": 5.5,
"volume": 0
},
"2025-12-18T13:00:00.000000Z": {
"open": 5.56,
"close": 5.54,
"high": 5.56,
"low": 5.51,
"volume": 0
},
"2025-12-18T14:00:00.000000Z": {
"open": 5.54,
"close": 5.53,
"high": 5.54,
"low": 5.52,
"volume": 0
},
"2025-12-18T15:00:00.000000Z": {
"open": 5.53,
"close": 5.51,
"high": 5.53,
"low": 5.5,
"volume": 0
},
"2025-12-18T16:00:00.000000Z": {
"open": 5.51,
"close": 5.52,
"high": 5.52,
"low": 5.5,
"volume": 0
},
"2025-12-18T17:00:00.000000Z": {
"open": 5.52,
"close": 5.52,
"high": 5.53,
"low": 5.51,
"volume": 0
},
"2025-12-18T18:00:00.000000Z": {
"open": 5.52,
"close": 5.52,
"high": 5.52,
"low": 5.51,
"volume": 0
},
"2025-12-18T19:00:00.000000Z": {
"open": 5.52,
"close": 5.52,
"high": 5.52,
"low": 5.52,
"volume": 0
},
"2025-12-18T20:00:00.000000Z": {
"open": 5.52,
"close": 5.52,
"high": 5.53,
"low": 5.52,
"volume": 0
},
"2025-12-19T01:00:00.000000Z": {
"open": 5.52,
"close": 5.52,
"high": 5.52,
"low": 5.52,
"volume": 0
},
"2025-12-19T02:00:00.000000Z": {
"open": 5.52,
"close": 5.52,
"high": 5.52,
"low": 5.52,
"volume": 0
},
"2025-12-19T03:00:00.000000Z": {
"open": 5.52,
"close": 5.52,
"high": 5.52,
"low": 5.52,
"volume": 0
},
"2025-12-19T06:00:00.000000Z": {
"open": 5.52,
"close": 5.52,
"high": 5.52,
"low": 5.52,
"volume": 0
},
"2025-12-19T07:00:00.000000Z": {
"open": 5.5,
"close": 5.5,
"high": 5.5,
"low": 5.5,
"volume": 0
},
"2025-12-19T10:00:00.000000Z": {
"open": 5.52,
"close": 5.52,
"high": 5.52,
"low": 5.52,
"volume": 0
},
"2025-12-19T11:00:00.000000Z": {
"open": 5.52,
"close": 5.52,
"high": 5.52,
"low": 5.52,
"volume": 0
},
"2025-12-19T12:00:00.000000Z": {
"open": 5.52,
"close": 5.54,
"high": 5.55,
"low": 5.52,
"volume": 0
},
"2025-12-19T13:00:00.000000Z": {
"open": 5.54,
"close": 5.51,
"high": 5.54,
"low": 5.51,
"volume": 0
},
"2025-12-19T14:00:00.000000Z": {
"open": 5.51,
"close": 5.51,
"high": 5.52,
"low": 5.5,
"volume": 0
},
"2025-12-19T15:00:00.000000Z": {
"open": 5.51,
"close": 5.51,
"high": 5.51,
"low": 5.5,
"volume": 0
},
"2025-12-19T16:00:00.000000Z": {
"open": 5.51,
"close": 5.51,
"high": 5.51,
"low": 5.5,
"volume": 0
},
"2025-12-19T17:00:00.000000Z": {
"open": 5.51,
"close": 5.53,
"high": 5.53,
"low": 5.51,
"volume": 0
},
"2025-12-19T18:00:00.000000Z": {
"open": 5.53,
"close": 5.53,
"high": 5.53,
"low": 5.52,
"volume": 0
},
"2025-12-19T19:00:00.000000Z": {
"open": 5.53,
"close": 5.53,
"high": 5.53,
"low": 5.52,
"volume": 0
},
"2025-12-19T20:00:00.000000Z": {
"open": 5.53,
"close": 5.54,
"high": 5.55,
"low": 5.53,
"volume": 0
},
"2025-12-22T02:00:00.000000Z": {
"open": 5.54,
"close": 5.54,
"high": 5.54,
"low": 5.54,
"volume": 0
},
"2025-12-22T03:00:00.000000Z": {
"open": 5.54,
"close": 5.54,
"high": 5.54,
"low": 5.54,
"volume": 0
},
"2025-12-22T06:00:00.000000Z": {
"open": 5.53,
"close": 5.53,
"high": 5.53,
"low": 5.53,
"volume": 0
},
"2025-12-22T10:00:00.000000Z": {
"open": 5.53,
"close": 5.53,
"high": 5.53,
"low": 5.53,
"volume": 0
},
"2025-12-22T12:00:00.000000Z": {
"open": 5.53,
"close": 5.53,
"high": 5.54,
"low": 5.52,
"volume": 0
},
"2025-12-22T13:00:00.000000Z": {
"open": 5.53,
"close": 5.53,
"high": 5.54,
"low": 5.52,
"volume": 0
},
"2025-12-22T14:00:00.000000Z": {
"open": 5.53,
"close": 5.55,
"high": 5.55,
"low": 5.52,
"volume": 0
},
"2025-12-22T15:00:00.000000Z": {
"open": 5.55,
"close": 5.56,
"high": 5.56,
"low": 5.53,
"volume": 0
},
"2025-12-22T16:00:00.000000Z": {
"open": 5.56,
"close": 5.58,
"high": 5.58,
"low": 5.55,
"volume": 0
},
"2025-12-22T17:00:00.000000Z": {
"open": 5.58,
"close": 5.59,
"high": 5.6,
"low": 5.56,
"volume": 0
},
"2025-12-22T18:00:00.000000Z": {
"open": 5.59,
"close": 5.58,
"high": 5.61,
"low": 5.58,
"volume": 0
},
"2025-12-22T19:00:00.000000Z": {
"open": 5.58,
"close": 5.58,
"high": 5.59,
"low": 5.58,
"volume": 0
},
"2025-12-22T20:00:00.000000Z": {
"open": 5.58,
"close": 5.59,
"high": 5.59,
"low": 5.58,
"volume": 0
}
}
},
"execution_time": 0.09,
"from_cache": false
}
Intervalo de datas específico
GEThttps://api.hgbrasil.com/v2/finance/historical?symbols=petr4,vale3&start_date=2024-01-01&end_date=2024-01-31&sample_by=1d&key=suachave
curl -X GET "https://api.hgbrasil.com/v2/finance/historical?symbols=petr4%2Cvale3&start_date=2024-01-01&end_date=2024-01-31&sample_by=1d&key=suachave"
const url = new URL("/v2/finance/historical", "https://api.hgbrasil.com")
url.searchParams.set("symbols", "petr4,vale3")
url.searchParams.set("start_date", "2024-01-01")
url.searchParams.set("end_date", "2024-01-31")
url.searchParams.set("sample_by", "1d")
url.searchParams.set("key", "suachave")
const response = await fetch(url.href)
const data = await response.json()
$url = 'https://api.hgbrasil.com/v2/finance/historical';
$queryString = http_build_query([
'symbols' => 'petr4,vale3',
'start_date' => '2024-01-01',
'end_date' => '2024-01-31',
'sample_by' => '1d',
'key' => 'suachave'
]);
$response = file_get_contents($url . '?' . $queryString);
$data = json_decode($response, true);
import requests
url = 'https://api.hgbrasil.com/v2/finance/historical'
params = {
'symbols': 'petr4,vale3',
'start_date': '2024-01-01',
'end_date': '2024-01-31',
'sample_by': '1d',
'key': 'suachave'
}
response = requests.get(url, params=params)
data = response.json()
require 'net/http'
require 'uri'
require 'json'
uri = URI('https://api.hgbrasil.com/v2/finance/historical')
uri.query = URI.encode_www_form({
symbols: 'petr4,vale3',
start_date: '2024-01-01',
end_date: '2024-01-31',
sample_by: '1d',
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/v2/finance/historical?symbols=petr4%2Cvale3&start_date=2024-01-01&end_date=2024-01-31&sample_by=1d&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/v2/finance/historical";
var queryParams = HttpUtility.ParseQueryString(string.Empty);
queryParams["symbols"] = "petr4,vale3";
queryParams["start_date"] = "2024-01-01";
queryParams["end_date"] = "2024-01-31";
queryParams["sample_by"] = "1d";
queryParams["key"] = "suachave";
var url = $"{baseUrl}?{queryParams}";
var response = await client.GetStringAsync(url);
var data = JsonSerializer.Deserialize<dynamic>(response);
Resposta
{
"by": "days_ago",
"sample_by": "1d",
"valid_key": true,
"results": {
"PETR4": {
"2024-01-02T00:00:00.000000Z": {
"open": 37.44,
"close": 37.78,
"high": 37.89,
"low": 37.4,
"volume": 24043800
},
"2024-01-03T00:00:00.000000Z": {
"open": 37.79,
"close": 38.96,
"high": 39.11,
"low": 37.67,
"volume": 52300200
},
"2024-01-04T00:00:00.000000Z": {
"open": 39.11,
"close": 38.63,
"high": 39.35,
"low": 38.51,
"volume": 45344900
},
"2024-01-05T00:00:00.000000Z": {
"open": 38.86,
"close": 38.72,
"high": 39.14,
"low": 38.41,
"volume": 35783700
},
"2024-01-08T00:00:00.000000Z": {
"open": 38.38,
"close": 38.43,
"high": 38.43,
"low": 37.61,
"volume": 35158100
},
"2024-01-09T00:00:00.000000Z": {
"open": 38.67,
"close": 38.1,
"high": 38.75,
"low": 38.03,
"volume": 27279000
},
"2024-01-10T00:00:00.000000Z": {
"open": 38.1,
"close": 37.75,
"high": 38.27,
"low": 37.51,
"volume": 27382000
},
"2024-01-11T00:00:00.000000Z": {
"open": 37.98,
"close": 38.07,
"high": 38.15,
"low": 37.7,
"volume": 26564400
},
"2024-01-12T00:00:00.000000Z": {
"open": 38.5,
"close": 38.17,
"high": 38.73,
"low": 38.17,
"volume": 24479500
},
"2024-01-15T00:00:00.000000Z": {
"open": 37.99,
"close": 38.58,
"high": 38.61,
"low": 37.86,
"volume": 13818300
},
"2024-01-16T00:00:00.000000Z": {
"open": 38.61,
"close": 38.1,
"high": 38.79,
"low": 38.08,
"volume": 31277700
},
"2024-01-17T00:00:00.000000Z": {
"open": 37.97,
"close": 37.88,
"high": 38.15,
"low": 37.82,
"volume": 27577300
},
"2024-01-18T00:00:00.000000Z": {
"open": 38.14,
"close": 37.73,
"high": 38.14,
"low": 37.56,
"volume": 22987200
},
"2024-01-19T00:00:00.000000Z": {
"open": 37.81,
"close": 37.53,
"high": 37.9,
"low": 37.23,
"volume": 30971400
},
"2024-01-22T00:00:00.000000Z": {
"open": 37.5,
"close": 37.7,
"high": 37.81,
"low": 37.23,
"volume": 22753700
},
"2024-01-23T00:00:00.000000Z": {
"open": 37.84,
"close": 38.17,
"high": 38.36,
"low": 37.43,
"volume": 32498500
},
"2024-01-24T00:00:00.000000Z": {
"open": 38.29,
"close": 37.88,
"high": 38.54,
"low": 37.77,
"volume": 25415300
},
"2024-01-25T00:00:00.000000Z": {
"open": 38.26,
"close": 39.28,
"high": 39.28,
"low": 38.13,
"volume": 48655300
},
"2024-01-26T00:00:00.000000Z": {
"open": 39.1,
"close": 39.96,
"high": 40.09,
"low": 38.91,
"volume": 41378200
},
"2024-01-29T00:00:00.000000Z": {
"open": 40,
"close": 40.57,
"high": 40.59,
"low": 39.83,
"volume": 30547500
},
"2024-01-30T00:00:00.000000Z": {
"open": 40.17,
"close": 40.32,
"high": 40.74,
"low": 40.04,
"volume": 34829000
},
"2024-01-31T00:00:00.000000Z": {
"open": 40.23,
"close": 40.45,
"high": 41.24,
"low": 40.18,
"volume": 58491900
}
},
"VALE3": {
"2024-01-02T00:00:00.000000Z": {
"open": 77.59,
"close": 77.05,
"high": 78.18,
"low": 76.59,
"volume": 18021800
},
"2024-01-03T00:00:00.000000Z": {
"open": 76.71,
"close": 76.65,
"high": 76.9,
"low": 75.84,
"volume": 25315100
},
"2024-01-04T00:00:00.000000Z": {
"open": 76.43,
"close": 75.62,
"high": 76.64,
"low": 75.36,
"volume": 18707000
},
"2024-01-05T00:00:00.000000Z": {
"open": 75.03,
"close": 74.65,
"high": 75.05,
"low": 74.12,
"volume": 21082500
},
"2024-01-08T00:00:00.000000Z": {
"open": 73.94,
"close": 74.27,
"high": 74.56,
"low": 73.51,
"volume": 23013300
},
"2024-01-09T00:00:00.000000Z": {
"open": 74.09,
"close": 73.33,
"high": 74.16,
"low": 73.15,
"volume": 15257400
},
"2024-01-10T00:00:00.000000Z": {
"open": 72.79,
"close": 72.23,
"high": 72.79,
"low": 71.95,
"volume": 21354600
},
"2024-01-11T00:00:00.000000Z": {
"open": 72.45,
"close": 72.61,
"high": 72.91,
"low": 71.84,
"volume": 20289100
},
"2024-01-12T00:00:00.000000Z": {
"open": 72.2,
"close": 71.69,
"high": 72.7,
"low": 71.64,
"volume": 16343400
},
"2024-01-15T00:00:00.000000Z": {
"open": 71.22,
"close": 71.55,
"high": 71.7,
"low": 70.7,
"volume": 12745700
},
"2024-01-16T00:00:00.000000Z": {
"open": 71.59,
"close": 70.62,
"high": 71.79,
"low": 70.26,
"volume": 22620300
},
"2024-01-17T00:00:00.000000Z": {
"open": 70.27,
"close": 69.45,
"high": 70.46,
"low": 69,
"volume": 43086400
},
"2024-01-18T00:00:00.000000Z": {
"open": 70.2,
"close": 69,
"high": 70.4,
"low": 69,
"volume": 30490600
},
"2024-01-19T00:00:00.000000Z": {
"open": 69.5,
"close": 68.09,
"high": 69.51,
"low": 68.05,
"volume": 60243300
},
"2024-01-22T00:00:00.000000Z": {
"open": 67.5,
"close": 67.8,
"high": 67.98,
"low": 67.11,
"volume": 23318900
},
"2024-01-23T00:00:00.000000Z": {
"open": 68.95,
"close": 69.2,
"high": 69.77,
"low": 68.45,
"volume": 33886800
},
"2024-01-24T00:00:00.000000Z": {
"open": 70.3,
"close": 69.9,
"high": 70.83,
"low": 69.75,
"volume": 36922100
},
"2024-01-25T00:00:00.000000Z": {
"open": 70,
"close": 68.36,
"high": 70.41,
"low": 67.36,
"volume": 47639700
},
"2024-01-26T00:00:00.000000Z": {
"open": 67.9,
"close": 69.5,
"high": 69.81,
"low": 67.5,
"volume": 27397200
},
"2024-01-29T00:00:00.000000Z": {
"open": 69.48,
"close": 69.17,
"high": 69.48,
"low": 68.23,
"volume": 15866100
},
"2024-01-30T00:00:00.000000Z": {
"open": 69.4,
"close": 68.78,
"high": 69.59,
"low": 67.89,
"volume": 34371300
},
"2024-01-31T00:00:00.000000Z": {
"open": 68.09,
"close": 67.76,
"high": 68.58,
"low": 67.76,
"volume": 34753400
}
}
},
"execution_time": 0.16,
"from_cache": false
}
Moedas e índices
GEThttps://api.hgbrasil.com/v2/finance/historical?symbols=usdbrl,eurbrl,bvsp&days_ago=7&sample_by=1d&key=suachave
curl -X GET "https://api.hgbrasil.com/v2/finance/historical?symbols=usdbrl%2Ceurbrl%2Cbvsp&days_ago=7&sample_by=1d&key=suachave"
const url = new URL("/v2/finance/historical", "https://api.hgbrasil.com")
url.searchParams.set("symbols", "usdbrl,eurbrl,bvsp")
url.searchParams.set("days_ago", "7")
url.searchParams.set("sample_by", "1d")
url.searchParams.set("key", "suachave")
const response = await fetch(url.href)
const data = await response.json()
$url = 'https://api.hgbrasil.com/v2/finance/historical';
$queryString = http_build_query([
'symbols' => 'usdbrl,eurbrl,bvsp',
'days_ago' => '7',
'sample_by' => '1d',
'key' => 'suachave'
]);
$response = file_get_contents($url . '?' . $queryString);
$data = json_decode($response, true);
import requests
url = 'https://api.hgbrasil.com/v2/finance/historical'
params = {
'symbols': 'usdbrl,eurbrl,bvsp',
'days_ago': '7',
'sample_by': '1d',
'key': 'suachave'
}
response = requests.get(url, params=params)
data = response.json()
require 'net/http'
require 'uri'
require 'json'
uri = URI('https://api.hgbrasil.com/v2/finance/historical')
uri.query = URI.encode_www_form({
symbols: 'usdbrl,eurbrl,bvsp',
days_ago: '7',
sample_by: '1d',
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/v2/finance/historical?symbols=usdbrl%2Ceurbrl%2Cbvsp&days_ago=7&sample_by=1d&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/v2/finance/historical";
var queryParams = HttpUtility.ParseQueryString(string.Empty);
queryParams["symbols"] = "usdbrl,eurbrl,bvsp";
queryParams["days_ago"] = "7";
queryParams["sample_by"] = "1d";
queryParams["key"] = "suachave";
var url = $"{baseUrl}?{queryParams}";
var response = await client.GetStringAsync(url);
var data = JsonSerializer.Deserialize<dynamic>(response);
Resposta
{
"by": "days_ago",
"sample_by": "1d",
"valid_key": true,
"results": {
"BVSP": {
"2025-12-15T00:00:00.000000Z": {
"open": 160766.38,
"close": 162757.79,
"high": 163073.14,
"low": 160766.38,
"volume": 0
},
"2025-12-16T00:00:00.000000Z": {
"open": 162481.73,
"close": 158964.12,
"high": 162481.73,
"low": 158836.66,
"volume": 0
},
"2025-12-17T00:00:00.000000Z": {
"open": 158577.88,
"close": 157304.01,
"high": 158610.63,
"low": 156350.81,
"volume": 0
},
"2025-12-18T00:00:00.000000Z": {
"open": 157326.54,
"close": 158163.42,
"high": 158495.48,
"low": 157123.58000000002,
"volume": 0
},
"2025-12-19T00:00:00.000000Z": {
"open": 157928.31,
"close": 158374.17,
"high": 159551.94,
"low": 157906.06,
"volume": 0
},
"2025-12-22T00:00:00.000000Z": {
"open": 158480.44,
"close": 158179.2,
"high": 158633.98,
"low": 157305.76,
"volume": 0
}
},
"EURBRL": {
"2025-12-15T00:00:00.000000Z": {
"open": 6.36,
"close": 6.37,
"high": 6.37,
"low": 6.33,
"volume": 0
},
"2025-12-16T00:00:00.000000Z": {
"open": 6.37,
"close": 6.43,
"high": 6.45,
"low": 6.36,
"volume": 0
},
"2025-12-17T00:00:00.000000Z": {
"open": 6.47,
"close": 6.47,
"high": 6.49,
"low": 6.4,
"volume": 0
},
"2025-12-18T00:00:00.000000Z": {
"open": 6.48,
"close": 6.47,
"high": 6.51,
"low": 6.46,
"volume": 0
},
"2025-12-19T00:00:00.000000Z": {
"open": 6.47,
"close": 6.49,
"high": 6.49,
"low": 6.44,
"volume": 0
},
"2025-12-22T00:00:00.000000Z": {
"open": 6.49,
"close": 6.57,
"high": 6.59,
"low": 6.48,
"volume": 0
}
},
"USDBRL": {
"2025-12-15T00:00:00.000000Z": {
"open": 5.42,
"close": 5.42,
"high": 5.43,
"low": 5.38,
"volume": 0
},
"2025-12-16T00:00:00.000000Z": {
"open": 5.41,
"close": 5.47,
"high": 5.48,
"low": 5.41,
"volume": 0
},
"2025-12-17T00:00:00.000000Z": {
"open": 5.51,
"close": 5.51,
"high": 5.53,
"low": 5.46,
"volume": 0
},
"2025-12-18T00:00:00.000000Z": {
"open": 5.52,
"close": 5.52,
"high": 5.56,
"low": 5.5,
"volume": 0
},
"2025-12-19T00:00:00.000000Z": {
"open": 5.52,
"close": 5.54,
"high": 5.55,
"low": 5.5,
"volume": 0
},
"2025-12-22T00:00:00.000000Z": {
"open": 5.54,
"close": 5.59,
"high": 5.61,
"low": 5.52,
"volume": 0
}
}
},
"execution_time": 0.1,
"from_cache": false
}