Historical Data API
getHistory
The getHistory API is used to request historical time series data on stocks, indexes, mutual funds, ETFs, futures, foreign exchange, cash commodities or cryptocurrencies. Historical data is available as tick, minute bars or end-of-day data.
View All APIssymbolrequired
A symbol or code that identifies a financial instrument.
AAPL
typerequired
The type of historical data to return, including tick data, minute data, and end-of-day data.
minutes
startDateoptional
The start date of the historical data query. This parameter should be set to the desired start date/time for the query (the result set will include records back to, and including, this value). If not set, the value will default to the beginning of the day specified in the end parameter, if end is specified, or to the beginning of the current day, if end is not specified. The value should conform to the format yyyymmdd[hhmm[ss]], where fields in brackets are optional (Do not include the brackets themselves). Any optional fields that are not explicitly set will default to 0 (i.e. 20090203 will default to 20090203000000 or February 3, 2009 at 00:00:00).
20100101
endDateoptional
The end data of the historical data query. This parameter should be set to the desired end date/time for the query (the result set will include records up to, but not including, this value). If not set, the value will default to the end of the day specified in the start parameter, if specified, or to the end of the current day, if start is not specified. The value should conform to the format yyyymmdd[hhmm[ss]], where fields in brackets are optional (Do not include the brackets themselves). Any optional fields that are not explicitly set will default to 0 (i.e. 20090203 will default to 20090203000000 or February 3, 2009 at 00:00:00).
20130101
maxRecordsoptional
The maximum amount of records returned. This parameter should be set to the maximum number of records desired. If not specified, there number of records returned will be determined by the date/time parameters specified as well as any defaults that apply to the query.
10
intervaloptional
The number of minutes for a minute query.
60
orderoptional
An arrangement of fields within a particular record (ascending or descending). This parameter can be set to one of two values ("asc" and "desc") in order to specify the chronological order of the result set returned. If this parameter is not specified, the order results is not guaranteed.
asc
sessionFilteroptional
This parameter modifies the default session codes/sale conditions used to return ticks for each exchange. For NYSE and AMEX, the default session filter is "@EFKX56V9" (meaning all ticks with sale conditions corresponding to one of the characters in the filter are included in the results), for NASDAQ the default is "@ABDEFKOSXY156", and for everything else all session codes/sale conditions are returned except the settle (session code '*'). If the session filter is set to a string of valid session codes (i.e. "EFK"), only ticks with the specified session codes are included in the results. If the string is prefixed with character '!' (i.e."!EFK"), all session codes except those in the string are included in the results. If the string is prefixed with character '+' (i.e. "+T"), then all the default session codes in addition to the ones specified in the string are included in the results. And if the string is prefixed with character '-' (i.e. "-EF") then all default session codes except the ones specified are included in the results. Please note that the '+' character should be escaped (to %2B) when entering the URL in a web browser or executing the query in an API that does not escape it by default.
EFK
splitsoptional
An adjustment of stock value due to corporate action. This parameter only applies to stocks and specifies whether the data returned should be adjusted for splits or not. Set to true to query for adjusted the data, or to false for non-adjusted data. If not specified, the default is true. In order to guarantee the same adjustment settings in the future, this parameter should be specified.
true
dividendsoptional
A distribution of a portion of a company's earnings. This parameter only applies to stocks and specifies whether the data returned should be adjusted for dividends or not. Set to true to query for adjusted the data, or to false for non-adjusted data. If not specified, the default is true. In order to guarantee the same adjustment settings in the future, this parameter should be specified.
true
volumeoptional
The quantity of shares or contracts traded. For futures, this parameter can be set to one of two values (contract and total) in order to specify whether the volume returned should be the contract volume or the total volume. For aggregates (such as weekly, monthly or yearly), this returns the average volume for the period specified. If the value is preceded by 'sum' (sumcontract and sumtotal), then it returns the sum of the volumes in each daily bar during the period specified. If not specified, the value will default to contract. For aggregate equities queries (such as weekly, monthly or yearly), this parameter can be set to sum to return the sum of the volumes in each daily bar during the period specified. If not specified, then the average volume is returned.
sum
nearbyoptional
This parameter specifies the offset from the front month for 'nearest' queries (data parameter set to dailynearest, weeklynearest, monthlynearest, quarterlynearest and yearlynearest). The default value for this parameter is 1, which sets nearest queries to the most current front month. If set to a value greater than 1, then the nth front month is used (for example, in August of 2010, ESU10 would be the current front month, so nearby=2 would use ESZ10, nearby=3 would use ESH11, etc.) This parameter is ignored for all other queries. Alternatively, the same functionality provided by the nearby parameter can be achieved using the symbol notation symbol=RS*n, where RS is the root symbol and n is the nth front month (i.e. symbol=ES*1, symbol=YM*3, etc.). When using this notation on the symbol parameter, the nearby parameter should be omitted.
1
jerqoptional
Whether to merge with JERQ data.
true
exchangeoptional
The list of valid exchange codes to limit symbol search.
NYSE,AMEX,NASDAQ
backAdjustoptional
This parameter specifies whether the contracts in the series will be adjusted based on the roll-gap between the closing prices of the current contract and the previous contract on the day of the switch. Valid values are true and false. If not specified, the default value is false resulting in a non-adjusted query. This parameter only applies to multi-contract futures queries and is ignored for all other queries.
false
daysToExpirationoptional
This parameter specifies the number of calendar days prior to a contract expiration when the series of contracts will be switched to the next contract in the series. Valid values are 0 through 60. A value of 0 will tell the system to use the day of expiration. If not specified, the default value (1) is used, resulting in each contract in the series to run until (and including) the day prior to its expiration. This parameter only applies to multi-contract futures queries and is ignored for all other queries.
1
contractRolloptional
For futures, multi-contract nearest queries (data parameter set to dailynearest, weeklynearest, monthlynearest, quarterlynearest or yearlynearest), this parameter can be set to one of two values (expiration, combined), and determines how the switch from one contract to the next in the series is calculated. When the value specified is 'expiration', the switch from one contract to the next in the series will be based on the expiration date (and the value of the 'daysToExpiration' parameter if specified). When the value specified is 'combined', a combination of volume and openinterest will be used to determine when to switch from one contract to the next in the series (when using this value, the 'daysToExpiration' parameter is ignored).
expiration
always returned
A sequence of characters. (example: GOOG)
always returned
A date and time in the format of YYYY-MM-DD HH:MI:SS<TIMEZONE_OFFSET>.
always returned
A date in the format of YYYY-MM-DD.
as requested
A sequence of characters. (example: GOOG)
as requested
A numeric type defining a number with fractional parts. (example: 2.14)
as requested
A numeric type defining a whole number. (example: 2)
as requested
A numeric type defining a number with fractional parts. (example: 2.14)
as requested
A numeric type defining a number with fractional parts. (example: 2.14)
as requested
A numeric type defining a number with fractional parts. (example: 2.14)
as requested
A numeric type defining a number with fractional parts. (example: 2.14)
as requested
A numeric type defining a whole number. (example: 2)
as requested
A numeric type defining a whole number. (example: 2)
GET
GET https://ondemand.websol.barchart.com/getHistory.json?apikey=YOUR_API_KEY&symbol=AAPL&type=minutes&startDate=20100101&endDate=20130101&maxRecords=10&interval=60&order=asc&sessionFilter=EFK&splits=true÷nds=true&volume=sum&nearby=1&jerq=true&exchange=NYSE%2CAMEX%2CNASDAQ&backAdjust=false&daysToExpiration=1&contractRoll=expiration
Host: ondemand.websol.barchart.com
POST
POST https://ondemand.websol.barchart.com/getHistory.json
Host: ondemand.websol.barchart.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length
apikey=YOUR_API_KEY&symbol=AAPL&type=minutes&startDate=20100101&endDate=20130101&maxRecords=10&interval=60&order=asc&sessionFilter=EFK&splits=true÷nds=true&volume=sum&nearby=1&jerq=true&exchange=NYSE%2CAMEX%2CNASDAQ&backAdjust=false&daysToExpiration=1&contractRoll=expiration
Response
{
"status": {
"code": 200,
"message": "Success."
},
"results": [
{
"symbol": "AAPL",
"timestamp": "2012-12-28T13:00:00-05:00",
"tradingDay": "2012-12-28",
"open": 15.5684,
"high": 15.5796,
"low": 15.5417,
"close": 15.5511,
"volume": 30703841
},
{
"symbol": "AAPL",
"timestamp": "2012-12-28T14:00:00-05:00",
"tradingDay": "2012-12-28",
"open": 15.5506,
"high": 15.5578,
"low": 15.5185,
"close": 15.5399,
"volume": 38267196
},
{
"symbol": "AAPL",
"timestamp": "2012-12-28T15:00:00-05:00",
"tradingDay": "2012-12-28",
"open": 15.5396,
"high": 15.6319,
"low": 15.4452,
"close": 15.4851,
"volume": 119477650
},
{
"symbol": "AAPL",
"timestamp": "2012-12-31T09:00:00-05:00",
"tradingDay": "2012-12-31",
"open": 15.5185,
"high": 15.9402,
"low": 15.472,
"close": 15.9259,
"volume": 112346242
},
{
"symbol": "AAPL",
"timestamp": "2012-12-31T10:00:00-05:00",
"tradingDay": "2012-12-31",
"open": 15.9259,
"high": 16.0259,
"low": 15.8566,
"close": 15.963,
"volume": 125474043
},
{
"symbol": "AAPL",
"timestamp": "2012-12-31T11:00:00-05:00",
"tradingDay": "2012-12-31",
"open": 15.9644,
"high": 16.0009,
"low": 15.8705,
"close": 15.9626,
"volume": 71536725
},
{
"symbol": "AAPL",
"timestamp": "2012-12-31T12:00:00-05:00",
"tradingDay": "2012-12-31",
"open": 15.9659,
"high": 16.0663,
"low": 15.8636,
"close": 15.9955,
"volume": 88102238
},
{
"symbol": "AAPL",
"timestamp": "2012-12-31T13:00:00-05:00",
"tradingDay": "2012-12-31",
"open": 15.9945,
"high": 16.0951,
"low": 15.9383,
"close": 15.9742,
"volume": 79041853
},
{
"symbol": "AAPL",
"timestamp": "2012-12-31T14:00:00-05:00",
"tradingDay": "2012-12-31",
"open": 15.9766,
"high": 16.2715,
"low": 15.9736,
"close": 16.2388,
"volume": 101194136
},
{
"symbol": "AAPL",
"timestamp": "2012-12-31T15:00:00-05:00",
"tradingDay": "2012-12-31",
"open": 16.234,
"high": 16.2745,
"low": 16.1323,
"close": 16.2009,
"volume": 133472167
}
]
}
GET
GET https://ondemand.websol.barchart.com/getHistory.xml?apikey=YOUR_API_KEY&symbol=AAPL&type=minutes&startDate=20100101&endDate=20130101&maxRecords=10&interval=60&order=asc&sessionFilter=EFK&splits=true÷nds=true&volume=sum&nearby=1&jerq=true&exchange=NYSE%2CAMEX%2CNASDAQ&backAdjust=false&daysToExpiration=1&contractRoll=expiration
Host: ondemand.websol.barchart.com
POST
POST https://ondemand.websol.barchart.com/getHistory.xml
Host: ondemand.websol.barchart.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length
apikey=YOUR_API_KEY&symbol=AAPL&type=minutes&startDate=20100101&endDate=20130101&maxRecords=10&interval=60&order=asc&sessionFilter=EFK&splits=true÷nds=true&volume=sum&nearby=1&jerq=true&exchange=NYSE%2CAMEX%2CNASDAQ&backAdjust=false&daysToExpiration=1&contractRoll=expiration
Response
<?xml version="1.0" encoding="utf-8"?>
<getHistory>
<status>
<code>200</code>
<message>Success.</message>
</status>
<item>
<symbol>AAPL</symbol>
<timestamp>2012-12-28T13:00:00-05:00</timestamp>
<tradingDay>2012-12-28</tradingDay>
<open>15.5684</open>
<high>15.5796</high>
<low>15.5417</low>
<close>15.5511</close>
<volume>30703841</volume>
</item>
<item>
<symbol>AAPL</symbol>
<timestamp>2012-12-28T14:00:00-05:00</timestamp>
<tradingDay>2012-12-28</tradingDay>
<open>15.5506</open>
<high>15.5578</high>
<low>15.5185</low>
<close>15.5399</close>
<volume>38267196</volume>
</item>
<item>
<symbol>AAPL</symbol>
<timestamp>2012-12-28T15:00:00-05:00</timestamp>
<tradingDay>2012-12-28</tradingDay>
<open>15.5396</open>
<high>15.6319</high>
<low>15.4452</low>
<close>15.4851</close>
<volume>119477650</volume>
</item>
<item>
<symbol>AAPL</symbol>
<timestamp>2012-12-31T09:00:00-05:00</timestamp>
<tradingDay>2012-12-31</tradingDay>
<open>15.5185</open>
<high>15.9402</high>
<low>15.472</low>
<close>15.9259</close>
<volume>112346242</volume>
</item>
<item>
<symbol>AAPL</symbol>
<timestamp>2012-12-31T10:00:00-05:00</timestamp>
<tradingDay>2012-12-31</tradingDay>
<open>15.9259</open>
<high>16.0259</high>
<low>15.8566</low>
<close>15.963</close>
<volume>125474043</volume>
</item>
<item>
<symbol>AAPL</symbol>
<timestamp>2012-12-31T11:00:00-05:00</timestamp>
<tradingDay>2012-12-31</tradingDay>
<open>15.9644</open>
<high>16.0009</high>
<low>15.8705</low>
<close>15.9626</close>
<volume>71536725</volume>
</item>
<item>
<symbol>AAPL</symbol>
<timestamp>2012-12-31T12:00:00-05:00</timestamp>
<tradingDay>2012-12-31</tradingDay>
<open>15.9659</open>
<high>16.0663</high>
<low>15.8636</low>
<close>15.9955</close>
<volume>88102238</volume>
</item>
<item>
<symbol>AAPL</symbol>
<timestamp>2012-12-31T13:00:00-05:00</timestamp>
<tradingDay>2012-12-31</tradingDay>
<open>15.9945</open>
<high>16.0951</high>
<low>15.9383</low>
<close>15.9742</close>
<volume>79041853</volume>
</item>
<item>
<symbol>AAPL</symbol>
<timestamp>2012-12-31T14:00:00-05:00</timestamp>
<tradingDay>2012-12-31</tradingDay>
<open>15.9766</open>
<high>16.2715</high>
<low>15.9736</low>
<close>16.2388</close>
<volume>101194136</volume>
</item>
<item>
<symbol>AAPL</symbol>
<timestamp>2012-12-31T15:00:00-05:00</timestamp>
<tradingDay>2012-12-31</tradingDay>
<open>16.234</open>
<high>16.2745</high>
<low>16.1323</low>
<close>16.2009</close>
<volume>133472167</volume>
</item>
</getHistory>
GET
GET https://ondemand.websol.barchart.com/getHistory.csv?apikey=YOUR_API_KEY&symbol=AAPL&type=minutes&startDate=20100101&endDate=20130101&maxRecords=10&interval=60&order=asc&sessionFilter=EFK&splits=true÷nds=true&volume=sum&nearby=1&jerq=true&exchange=NYSE%2CAMEX%2CNASDAQ&backAdjust=false&daysToExpiration=1&contractRoll=expiration
Host: ondemand.websol.barchart.com
POST
POST https://ondemand.websol.barchart.com/getHistory.csv
Host: ondemand.websol.barchart.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length
apikey=YOUR_API_KEY&symbol=AAPL&type=minutes&startDate=20100101&endDate=20130101&maxRecords=10&interval=60&order=asc&sessionFilter=EFK&splits=true÷nds=true&volume=sum&nearby=1&jerq=true&exchange=NYSE%2CAMEX%2CNASDAQ&backAdjust=false&daysToExpiration=1&contractRoll=expiration
Response
symbol,timestamp,tradingDay,open,high,low,close,volume
"AAPL","2012-12-28T13:00:00-05:00","2012-12-28","15.5684","15.5796","15.5417","15.5511","30703760"
"AAPL","2012-12-28T14:00:00-05:00","2012-12-28","15.5506","15.5578","15.5185","15.5399","38267123"
"AAPL","2012-12-28T15:00:00-05:00","2012-12-28","15.5396","15.6319","15.4452","15.4851","119477694"
"AAPL","2012-12-31T09:00:00-05:00","2012-12-31","15.5185","15.9402","15.472","15.9259","112346298"
"AAPL","2012-12-31T10:00:00-05:00","2012-12-31","15.9259","16.0259","15.8566","15.963","125473994"
"AAPL","2012-12-31T11:00:00-05:00","2012-12-31","15.9644","16.0009","15.8705","15.9626","71536641"
"AAPL","2012-12-31T12:00:00-05:00","2012-12-31","15.9659","16.0663","15.8636","15.9955","88102062"
"AAPL","2012-12-31T13:00:00-05:00","2012-12-31","15.9945","16.0951","15.9383","15.9742","79041680"
"AAPL","2012-12-31T14:00:00-05:00","2012-12-31","15.9766","16.2715","15.9736","16.2388","101194003"
"AAPL","2012-12-31T15:00:00-05:00","2012-12-31","16.234","16.2745","16.1323","16.2009","133471872"
<?php
$ondemand = new SoapClient('https://ondemand.websol.barchart.com/service?wsdl');
$params = [
'apikey' => 'YOUR_API_KEY',
'symbol' => 'AAPL',
'type' => 'minutes',
'startDate' => '20100101',
'endDate' => '20130101',
'maxRecords' => '10',
'interval' => '60',
'order' => 'asc',
'sessionFilter' => 'EFK',
'splits' => 'true',
'dividends' => 'true',
'volume' => 'sum',
'nearby' => '1',
'jerq' => 'true',
'exchange' => 'NYSE,AMEX,NASDAQ',
'backAdjust' => 'false',
'daysToExpiration' => '1',
'contractRoll' => 'expiration',
];
$result = $ondemand->getHistory($params);
var_dump($result);
Dim ondemand
Dim result
Set ondemand = Server.CreateObject("MSSOAP.SoapClient30")
ondemand.ClientProperty("ServerHTTPRequest") = True
ondemand.MSSoapInit("https://ondemand.websol.barchart.com/service?wsdl")
Set result = ondemand.getHistory("YOUR_API_KEY", "AAPL", "minutes", "20100101", "20130101", "10", "60", "asc", "EFK", "true", "true", "sum", "1", "true", "NYSE,AMEX,NASDAQ", "false", "1", "expiration")
use SOAP::Lite;
use SOAP::WSDL;
my $ondemand = SOAP::Lite
-> service('https://ondemand.websol.barchart.com/service?wsdl');
my $result = $ondemand->getHistory('YOUR_API_KEY', 'AAPL', 'minutes', '20100101', '20130101', '10', '60', 'asc', 'EFK', 'true', 'true', 'sum', '1', 'true', 'NYSE,AMEX,NASDAQ', 'false', '1', 'expiration');
print $result;
from suds.client import Client
ondemand = Client('https://ondemand.websol.barchart.com/service?wsdl')
result = ondemand.service.getHistory('YOUR_API_KEY', 'AAPL', 'minutes', '20100101', '20130101', '10', '60', 'asc', 'EFK', 'true', 'true', 'sum', '1', 'true', 'NYSE,AMEX,NASDAQ', 'false', '1', 'expiration')
print(result)
require 'savon'
ondemand = Savon.client(wsdl: 'https://ondemand.websol.barchart.com/service?wsdl')
response = ondemand.call(
:getHistory,
message: {
apikey: 'YOUR_API_KEY',
symbol: 'AAPL',
type: 'minutes',
startDate: '20100101',
endDate: '20130101',
maxRecords: '10',
interval: '60',
order: 'asc',
sessionFilter: 'EFK',
splits: 'true',
dividends: 'true',
volume: 'sum',
nearby: '1',
jerq: 'true',
exchange: 'NYSE,AMEX,NASDAQ',
backAdjust: 'false',
daysToExpiration: '1',
contractRoll: 'expiration',
}
)
response.body