getHistory API

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.

All APIs

Contact Us to Get Access

Integrate Data Into Excel

Easily run calculations on delayed Cboe BZX Exchange data with the simplicity of Microsoft Excel

getQuote into Excel getHistory into Excel

Inputs

symbol required

A symbol or code that identifies a financial instrument.

Type
string (A sequence of characters. (example: GOOG)) 
Example
AAPL 

type required

The type of historical data to return, including tick data, minute data, and end-of-day data.

Type
enum (A type which includes a list of valid possible values.) 
Example
minutes 

Valid Values:
minutes, nearbyMinutes, formTMinutes, daily, dailyNearest, dailyContinue, weekly, weeklyNearest, weeklyContinue, monthly, monthlyNearest, monthlyContinue, quarterly, quarterlyNearest, quarterlyContinue, yearly, yearlyNearest, yearlyContinue

startDate optional

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).

Type
dateTime (A date and time in the format of YYYY-MM-DD HH:MI:SS<TIMEZONE_OFFSET>.) 
Example
20100101 

maxRecords optional

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.

Type
int (A numeric type defining a whole number. (example: 2)) 
Example
10 

interval optional

The number of minutes for a minute query.

Type
int (A numeric type defining a whole number. (example: 2)) 
Example
60 
Default

order optional

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.

Type
enum (A type which includes a list of valid possible values.) 
Example
asc 
Default
asc 

Valid Values:
asc, desc

sessionFilter optional

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.

Type
string (A sequence of characters. (example: GOOG)) 
Example
EFK 

splits optional

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.

Type
boolean (A logical type representing the truth of a value as 'true' or 'false'.) 
Example
true 
Default

dividends optional

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.

Type
boolean (A logical type representing the truth of a value as 'true' or 'false'.) 
Example
true 
Default

volume optional

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.

Type
enum (A type which includes a list of valid possible values.) 
Example
sum 

Valid Values:
total, sum, contract, sumcontract, sumtotal

nearby optional

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.

Type
int (A numeric type defining a whole number. (example: 2)) 
Example

jerq optional

Whether to merge with JERQ data.

Type
boolean (A logical type representing the truth of a value as 'true' or 'false'.) 
Example
true 
Default

Outputs

Name / Requirement
Description
Type
symbol
always returned
A symbol or code that identifies a financial instrument.
string
A sequence of characters. (example: GOOG)
timestamp
always returned
The exchange time of the price. Format: HH:MM:SS.FFF
string
A sequence of characters. (example: GOOG)
tradingDay
always returned
The date of the trade. Format: YYYY-MM-DD
date
A date in the format of YYYY-MM-DD.
sessionCode
as requested
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
A sequence of characters. (example: GOOG)
tickPrice
as requested
double
A numeric type defining a number with fractional parts. (example: 2.14)
tickSize
as requested
The volume traded for a single transaction.
int
A numeric type defining a whole number. (example: 2)
open
as requested
The opening (first) price for the period.
double
A numeric type defining a number with fractional parts. (example: 2.14)
high
as requested
The highest traded price for the period.
double
A numeric type defining a number with fractional parts. (example: 2.14)
low
as requested
The lowest traded price for the period.
double
A numeric type defining a number with fractional parts. (example: 2.14)
close
as requested
The last traded price for the period.
double
A numeric type defining a number with fractional parts. (example: 2.14)
volume
as requested
The quantity of shares or contracts traded per the period.
int
A numeric type defining a whole number. (example: 2)
openInterest
as requested
The total number of options and/or futures contracts that have not been offset.
int
A numeric type defining a whole number. (example: 2)

Status Code Responses

200
OK
Success
400
Bad Request
The request was invalid, please see the message for more information.
500
Internal Server Error
Something is not working correctly, please contact support.


JSON

GET

GET https://marketdata.websol.barchart.com/getHistory.json?apikey=YOUR_API_KEY&symbol=AAPL&type=minutes&startDate=20100101&maxRecords=10&interval=60&order=asc&sessionFilter=EFK&splits=true&dividends=true&volume=sum&nearby=1&jerq=true
Host: marketdata.websol.barchart.com

POST

POST https://marketdata.websol.barchart.com/getHistory.json
Host: marketdata.websol.barchart.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length

apikey=YOUR_API_KEY&symbol=AAPL&type=minutes&startDate=20100101&maxRecords=10&interval=60&order=asc&sessionFilter=EFK&splits=true÷nds=true&volume=sum&nearby=1&jerq=true

Response

{
    "status": {
        "code": 200,
        "message": "Success."
    },
    "results": [
        {
            "symbol": "AAPL",
            "timestamp": "2012-12-28T13:00:00-05:00",
            "tradingDay": "2012-12-28",
            "open": 65.19316,
            "high": 65.24026,
            "low": 65.08115,
            "close": 65.12086,
            "volume": 7332198
        },
        {
            "symbol": "AAPL",
            "timestamp": "2012-12-28T14:00:00-05:00",
            "tradingDay": "2012-12-28",
            "open": 65.1187,
            "high": 65.14861,
            "low": 64.98441,
            "close": 65.07364,
            "volume": 9138361
        },
        {
            "symbol": "AAPL",
            "timestamp": "2012-12-28T15:00:00-05:00",
            "tradingDay": "2012-12-28",
            "open": 65.07289,
            "high": 65.4592,
            "low": 64.67764,
            "close": 64.84439,
            "volume": 28531756
        },
        {
            "symbol": "AAPL",
            "timestamp": "2012-12-31T09:00:00-05:00",
            "tradingDay": "2012-12-31",
            "open": 64.98441,
            "high": 66.7499,
            "low": 64.78966,
            "close": 66.69007,
            "volume": 26828738
        },
        {
            "symbol": "AAPL",
            "timestamp": "2012-12-31T10:00:00-05:00",
            "tradingDay": "2012-12-31",
            "open": 66.69007,
            "high": 67.10885,
            "low": 66.39986,
            "close": 66.84537,
            "volume": 29963697
        },
        {
            "symbol": "AAPL",
            "timestamp": "2012-12-31T11:00:00-05:00",
            "tradingDay": "2012-12-31",
            "open": 66.85173,
            "high": 67.00448,
            "low": 66.45853,
            "close": 66.84409,
            "volume": 17083250
        },
        {
            "symbol": "AAPL",
            "timestamp": "2012-12-31T12:00:00-05:00",
            "tradingDay": "2012-12-31",
            "open": 66.85808,
            "high": 67.27814,
            "low": 66.42913,
            "close": 66.98156,
            "volume": 21039141
        },
        {
            "symbol": "AAPL",
            "timestamp": "2012-12-31T13:00:00-05:00",
            "tradingDay": "2012-12-31",
            "open": 66.97775,
            "high": 67.39906,
            "low": 66.74227,
            "close": 66.89246,
            "volume": 18875483
        },
        {
            "symbol": "AAPL",
            "timestamp": "2012-12-31T14:00:00-05:00",
            "tradingDay": "2012-12-31",
            "open": 66.90264,
            "high": 68.13734,
            "low": 66.88992,
            "close": 68.00063,
            "volume": 24165536
        },
        {
            "symbol": "AAPL",
            "timestamp": "2012-12-31T15:00:00-05:00",
            "tradingDay": "2012-12-31",
            "open": 67.98077,
            "high": 68.15007,
            "low": 67.55435,
            "close": 67.84203,
            "volume": 31873624
        }
    ]
}

XML

GET

GET https://marketdata.websol.barchart.com/getHistory.xml?apikey=YOUR_API_KEY&symbol=AAPL&type=minutes&startDate=20100101&maxRecords=10&interval=60&order=asc&sessionFilter=EFK&splits=true&dividends=true&volume=sum&nearby=1&jerq=true
Host: marketdata.websol.barchart.com

POST

POST https://marketdata.websol.barchart.com/getHistory.xml
Host: marketdata.websol.barchart.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length

apikey=YOUR_API_KEY&symbol=AAPL&type=minutes&startDate=20100101&maxRecords=10&interval=60&order=asc&sessionFilter=EFK&splits=true÷nds=true&volume=sum&nearby=1&jerq=true

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>65.19316</open>
   <high>65.24026</high>
   <low>65.08115</low>
   <close>65.12086</close>
   <volume>7332198</volume>
  </item>
  <item>
   <symbol>AAPL</symbol>
   <timestamp>2012-12-28T14:00:00-05:00</timestamp>
   <tradingDay>2012-12-28</tradingDay>
   <open>65.1187</open>
   <high>65.14861</high>
   <low>64.98441</low>
   <close>65.07364</close>
   <volume>9138361</volume>
  </item>
  <item>
   <symbol>AAPL</symbol>
   <timestamp>2012-12-28T15:00:00-05:00</timestamp>
   <tradingDay>2012-12-28</tradingDay>
   <open>65.07289</open>
   <high>65.4592</high>
   <low>64.67764</low>
   <close>64.84439</close>
   <volume>28531756</volume>
  </item>
  <item>
   <symbol>AAPL</symbol>
   <timestamp>2012-12-31T09:00:00-05:00</timestamp>
   <tradingDay>2012-12-31</tradingDay>
   <open>64.98441</open>
   <high>66.7499</high>
   <low>64.78966</low>
   <close>66.69007</close>
   <volume>26828738</volume>
  </item>
  <item>
   <symbol>AAPL</symbol>
   <timestamp>2012-12-31T10:00:00-05:00</timestamp>
   <tradingDay>2012-12-31</tradingDay>
   <open>66.69007</open>
   <high>67.10885</high>
   <low>66.39986</low>
   <close>66.84537</close>
   <volume>29963697</volume>
  </item>
  <item>
   <symbol>AAPL</symbol>
   <timestamp>2012-12-31T11:00:00-05:00</timestamp>
   <tradingDay>2012-12-31</tradingDay>
   <open>66.85173</open>
   <high>67.00448</high>
   <low>66.45853</low>
   <close>66.84409</close>
   <volume>17083250</volume>
  </item>
  <item>
   <symbol>AAPL</symbol>
   <timestamp>2012-12-31T12:00:00-05:00</timestamp>
   <tradingDay>2012-12-31</tradingDay>
   <open>66.85808</open>
   <high>67.27814</high>
   <low>66.42913</low>
   <close>66.98156</close>
   <volume>21039141</volume>
  </item>
  <item>
   <symbol>AAPL</symbol>
   <timestamp>2012-12-31T13:00:00-05:00</timestamp>
   <tradingDay>2012-12-31</tradingDay>
   <open>66.97775</open>
   <high>67.39906</high>
   <low>66.74227</low>
   <close>66.89246</close>
   <volume>18875483</volume>
  </item>
  <item>
   <symbol>AAPL</symbol>
   <timestamp>2012-12-31T14:00:00-05:00</timestamp>
   <tradingDay>2012-12-31</tradingDay>
   <open>66.90264</open>
   <high>68.13734</high>
   <low>66.88992</low>
   <close>68.00063</close>
   <volume>24165536</volume>
  </item>
  <item>
   <symbol>AAPL</symbol>
   <timestamp>2012-12-31T15:00:00-05:00</timestamp>
   <tradingDay>2012-12-31</tradingDay>
   <open>67.98077</open>
   <high>68.15007</high>
   <low>67.55435</low>
   <close>67.84203</close>
   <volume>31873624</volume>
  </item>
 </getHistory>

CSV

GET

GET https://marketdata.websol.barchart.com/getHistory.csv?apikey=YOUR_API_KEY&symbol=AAPL&type=minutes&startDate=20100101&maxRecords=10&interval=60&order=asc&sessionFilter=EFK&splits=true&dividends=true&volume=sum&nearby=1&jerq=true
Host: marketdata.websol.barchart.com

POST

POST https://marketdata.websol.barchart.com/getHistory.csv
Host: marketdata.websol.barchart.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length

apikey=YOUR_API_KEY&symbol=AAPL&type=minutes&startDate=20100101&maxRecords=10&interval=60&order=asc&sessionFilter=EFK&splits=true÷nds=true&volume=sum&nearby=1&jerq=true

Response

symbol,timestamp,tradingDay,open,high,low,close,volume
"AAPL","2012-12-28T13:00:00-05:00","2012-12-28","65.19316","65.24026","65.08115","65.12086","7332198"
"AAPL","2012-12-28T14:00:00-05:00","2012-12-28","65.1187","65.14861","64.98441","65.07364","9138361"
"AAPL","2012-12-28T15:00:00-05:00","2012-12-28","65.07289","65.4592","64.67764","64.84439","28531756"
"AAPL","2012-12-31T09:00:00-05:00","2012-12-31","64.98441","66.7499","64.78966","66.69007","26828738"
"AAPL","2012-12-31T10:00:00-05:00","2012-12-31","66.69007","67.10885","66.39986","66.84537","29963697"
"AAPL","2012-12-31T11:00:00-05:00","2012-12-31","66.85173","67.00448","66.45853","66.84409","17083250"
"AAPL","2012-12-31T12:00:00-05:00","2012-12-31","66.85808","67.27814","66.42913","66.98156","21039141"
"AAPL","2012-12-31T13:00:00-05:00","2012-12-31","66.97775","67.39906","66.74227","66.89246","18875483"
"AAPL","2012-12-31T14:00:00-05:00","2012-12-31","66.90264","68.13734","66.88992","68.00063","24165536"
"AAPL","2012-12-31T15:00:00-05:00","2012-12-31","67.98077","68.15007","67.55435","67.84203","31873624"


PHP

<?php

$ondemand = new SoapClient('https://marketdata.websol.barchart.com/service?wsdl');

$params = [
    'apikey' => 'YOUR_API_KEY',
    'symbol' => 'AAPL',
    'type' => 'minutes',
    'startDate' => '20100101',
    'maxRecords' => '10',
    'interval' => '60',
    'order' => 'asc',
    'sessionFilter' => 'EFK',
    'splits' => 'true',
    'dividends' => 'true',
    'volume' => 'sum',
    'nearby' => '1',
    'jerq' => 'true',
];

$result = $ondemand->getHistory($params);
var_dump($result);

Classic ASP

Dim ondemand
Dim result

Set ondemand = Server.CreateObject("MSSOAP.SoapClient30")
ondemand.ClientProperty("ServerHTTPRequest") = True
ondemand.MSSoapInit("https://marketdata.websol.barchart.com/service?wsdl")

Set result = ondemand.getHistory("YOUR_API_KEY", "AAPL", "minutes", "20100101", "10", "60", "asc", "EFK", "true", "true", "sum", "1", "true")

Perl

use SOAP::Lite;
use SOAP::WSDL;

my $ondemand = SOAP::Lite
    -> service('https://marketdata.websol.barchart.com/service?wsdl');

my $result = $ondemand->getHistory('YOUR_API_KEY', 'AAPL', 'minutes', '20100101', '10', '60', 'asc', 'EFK', 'true', 'true', 'sum', '1', 'true');

print $result;

Python

from suds.client import Client
ondemand = Client('https://marketdata.websol.barchart.com/service?wsdl')

result = client.service.getHistory('YOUR_API_KEY', 'AAPL', 'minutes', '20100101', '10', '60', 'asc', 'EFK', 'true', 'true', 'sum', '1', 'true')

print result

Ruby

require 'savon'

ondemand = Savon.client(wsdl: 'https://marketdata.websol.barchart.com/service?wsdl')

response = ondemand.call(
    :getHistory,
    message: {
        apikey: 'YOUR_API_KEY',
        symbol: 'AAPL',
        type: 'minutes',
        startDate: '20100101',
        maxRecords: '10',
        interval: '60',
        order: 'asc',
        sessionFilter: 'EFK',
        splits: 'true',
        dividends: 'true',
        volume: 'sum',
        nearby: '1',
        jerq: 'true',
    }
)

response.body


1. What is an API?
2. What Barchart APIs are included in my subscription?
3. What exchange data is included in my free API data feed?
4. Can I pull indices with the free market data API?
5. Can I pull mutual funds with the free market data API?
6. Can I receive options on futures and equity options with the free market data API?
7. How many queries am I allowed to make?
8. How do I request XML, JSON or CSV data?
9. When is end of day data updated?
10. Where can I find coding examples in Python, PHP, ASP, PERL, and Ruby?
11. I am getting the message “API key is missing or not valid.” What does this mean?
12. How can I avoid CORS issues?
13. Is data adjusted and corrected for historical splits and dividends?



1. What is an API?

API stands for application program interface and is a set of routines, protocols, and tools for building software applications. An API specifies how different pieces of software should interact with one another. Typically, APIs are used when programming graphical user interface components. A good API makes it easier for a developer to program by providing specific building blocks, in Barchart’s case - financial market data.




2. What Barchart APIs are included in my subscription?

Barchart’s free market data API only allows for both getQuote and getHistory APIs. Any additional APIs require a paid subscription to Barchart OnDemand. For pricing, please contact solutions@barchart.com




3. What exchange data is included in my free API data feed?

The free market data API includes data from AMEX, NYSE, NASDAQ in end of day frequency. Cboe BZX Exchange equity and Forex data is included on a 15-minute delay.




4. Can I pull indices with the free market data API?

No. You are limited to end of day US stocks and futures with the free market data API. To upgrade, please contact solutions@barchart.com.




5. Can I pull mutual funds with the free market data API?

No. You are limited to end of day US stocks and futures with the free market data API. To upgrade, please contact solutions@barchart.com.




6. Can I receive options on futures and equity options with the free market data API?

No. You will need to upgrade to Barchart OnDemand in order to receive futures or equity options data. Please contact solutions@barchart.com.




7. How many queries am I allowed to make?

Every user is able to make 400 getQuote queries and 150 getHistory queries per day.




8. How do I request XML, JSON or CSV data?

You can query for XML, JSON, or CSV by changing the extension of the API. See the highlighted section in the API query below.

https://marketdata.websol.barchart.com/getHistory.xml?apikey=YOUR_API_KEY&symbol=IBM&type=daily&startDate=20160608000000
https://marketdata.websol.barchart.com/getHistory.json?apikey=YOUR_API_KEY&symbol=IBM&type=daily&startDate=20160608000000
https://marketdata.websol.barchart.com/getHistory.csv?apikey=YOUR_API_KEY&symbol=IBM&type=daily&startDate=20160608000000




9. When is end of day data updated?

End of day data is updated by 16:45 Central Standard Time.




10. Where can I find coding examples in Python, PHP, ASP, PERL, and Ruby?

See: https://www.barchart.com/ondemand/api/getQuote/free. Click on the “Sample Code” button.




11. I am getting the message “API key is missing or not valid.” What does this mean?

First, check to make sure you are using your supplied API key and it is correct. If you are still getting this message it could mean you're connecting to the wrong endpoint.

With the free service, you need to request data from marketdata.websol.barchart.com as opposed to ondemand.websol.barchart.com.

INCORRECT: https://ondemand.websol.barchart.com/getQuote.json?apikey=YOUR_API_KEY&symbols=AAPL
CORRECT: https://marketdata.websol.barchart.com/getQuote.json?apikey=YOUR_API_KEY&symbols=AAPL




12. How can I avoid Cross-Origin Resource Sharing (CORS) issues?

Our APIs can be used without us enabling CORS by using JSONP, which can be used to overcome the CORS issue.

Below is sample code of this:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script>
    var apiResult = document.getElementById("quoteData"),
    getQuoteURL = "https://marketdata.websol.barchart.com/getQuote.jsonp";
    $.ajax({
        method: "POST",
        crossDomain: true,
        dataType: "jsonp",
        url: getQuoteURL,
        data: {
            "apikey": "YOUR_API_KEY",
            "symbols": "IBM"
        },
        success: function(data) {
            var html = "";
            for (var k in data.results) {
                html += "Symbol: " + data.results[k]['symbol'] + "<br />";
                html += "Last: " + data.results[k]['lastPrice'] + "<br />";
                html += "Change: " + data.results[k]['netChange'] + "<br />";
                html += "Pct. Chg.: " + data.results[k]['percentChange'] + "<br />";
                html += "Volume: " + data.results[k]['volume'] + "<br />";
                html += "Trade Time: " + data.results[k]['tradeTimestamp'] + "<br /><br />";
            }
            apiResult.innerHTML = html;
        },
        error: function() {
            console.log('Something went wrong!');
        }
    });
</script>



13. Is data adjusted and corrected for historical splits and dividends?

With getHistory splits and dividends are automatically adjusted into the historical data set. If you would like to remove historical splits and dividends, include the parameters &dividends=false and &splits=false to the historical data query.