Updated: 2017-06-26

getHistory

By Barchart

    The getHistory API is used to request historical time series data on stocks, indices, mutual funds, ETFs, futures, indices or forex pairs. Historical data is available as tick, minute or end-of-day data.

    Query Parameters

    Parameter Description Data Type
    dividends 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.
    endDate 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).
    exchange The list of valid exchange codes to limit symbol search.
    interval The number of minutes for a minute query.
    maxRecords 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.
    nearby 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=RSn, where RS is the root symbol and n is the nth front month (i.e. symbol=ES1, symbol=YM*3, etc.). When using this notation on the symbol parameter, the nearby parameter should be omitted.
    order 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.
    sessionFilter 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.
    splits 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.
    startDate 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).
    symbol A symbol or code that identifies a financial instrument.
    type The type of historical data to return, including tick data, minute data, and end-of-day data.
    volume 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.

    Response Fields

    Field Description Data Type
    close The last traded price for the period. double
    high The highest traded price for the period. double
    low The lowest traded price for the period. double
    open The opening (first) price for the period. double
    openInterest The total number of options and/or futures contracts that have not been offset. int
    sessionCode A code used to differentiate between composite market prices, overnight session prices, and day session prices for futures. Not all futures exchanges use session codes. "G" is electronic session and "R" is pit session. string
    symbol A symbol or code that identifies a financial instrument. string
    tickPrice double
    tickSize The volume traded for a single transaction. int
    timestamp The exchange time of the price. Format: HH:MM:SS.FFF dateTime
    tradingDay The date of the trade. Format: YYYY-MM-DD date
    volume The quantity of shares or contracts traded per the period. int

    About the Vendor

    From market data feeds to website content solutions and trading software to our flagship financial portal, Barchart.com, and individual subscription services, Barchart is the definitive source for comprehensive financial data and information.