getQuote API

The getQuote API is used to request price data, either real-time, delayed or end-of-day, by symbol. In addition to Last Price or Settlement, other fields such as Open, High, Low, Close, Bid, Ask, 52-week high and low, and more are available.

All APIs

Contact Us to Get Access


Integrate Data Into Excel

Easily run calculations on delayed BATS data with the simplicity of Microsoft Excel

getQuote into Excel getHistory into Excel

Inputs

symbols required

A symbol or code that identifies a financial instrument. Multiple symbols separated by a comma may be used. For futures, notation such as <root_symbol*0> for the active contract or <root_symbol*1> for the first nearby is supported, as is <root_symbol^F> for all futures contracts for a given root symbol.

Type
list (A comma or semi-colon delimited string.) 
Example
AAPL,GOOG 

fields optional

The fields requested.

Type
list (A comma or semi-colon delimited string.) 
Example
fiftyTwoWkHigh,fiftyTwoWkHighDate,fiftyTwoWkLow,fiftyTwoWkLowDate 

only optional

Returns only specified fields

Type
list (A comma or semi-colon delimited string.) 
Example
symbol,name 

Outputs

Name / Requirement
Description
Type
symbol
always returned
A symbol or code that identifies a financial instrument.
string
A sequence of characters. (example: GOOG)
exchange
always returned
Exchange code for the marketplace where the financial instruments are listed.
string
A sequence of characters. (example: GOOG)
name
always returned
The type of symbol used.
string
A sequence of characters. (example: GOOG)
dayCode
always returned
The day code for the session. Day codes are "1-9" for days 1 through 9, "0" (zero) for the 10th of the month, and "A - U" for days 11 through 31.
string
A sequence of characters. (example: GOOG)
serverTimestamp
always returned
The time the message was generated on the server.
dateTime
A date and time in the format of YYYY-MM-DD HH:MI:SS<TIMEZONE_OFFSET>.
mode
always returned
An indicator representing if the quote is real-time ("R"), delayed ("I") or end-of-day ("D").
string
A sequence of characters. (example: GOOG)
lastPrice
always returned
The last price the instrument traded.
double
A numeric type defining a number with fractional parts. (example: 2.14)
tradeSize
as requested
The size of the last traded price / transaction.
int
A numeric type defining a whole number. (example: 2)
tradeTimestamp
always returned
The exchange timestamp for the last traded price.
dateTime
A date and time in the format of YYYY-MM-DD HH:MI:SS<TIMEZONE_OFFSET>.
netChange
always returned
The difference between the last traded price and the previous close.
double
A numeric type defining a number with fractional parts. (example: 2.14)
percentChange
always returned
The percent difference between the last traded price and the previous close.
double
A numeric type defining a number with fractional parts. (example: 2.14)
tick
as requested
An indicator representing whether the last traded price was up ("+"), the same (".") or below ("-") the previous last price.
string
A sequence of characters. (example: GOOG)
previousLastPrice
as requested
The price previous to the current last price.
double
A numeric type defining a number with fractional parts. (example: 2.14)
previousTimestamp
as requested
The exchange timestamp of the previous last price.
date
A date in the format of YYYY-MM-DD.
bid
as requested
The current bid price.
double
A numeric type defining a number with fractional parts. (example: 2.14)
bidSize
as requested
The size (quantity) of the current bid price.
int
A numeric type defining a whole number. (example: 2)
ask
as requested
The current ask price.
double
A numeric type defining a number with fractional parts. (example: 2.14)
askSize
as requested
The size (quantity) of the current ask price.
int
A numeric type defining a whole number. (example: 2)
unitCode
always returned
string
A sequence of characters. (example: GOOG)
open
always returned
The opening (first) price for the session.
double
A numeric type defining a number with fractional parts. (example: 2.14)
high
always returned
The highest traded price for the session.
double
A numeric type defining a number with fractional parts. (example: 2.14)
low
always returned
The lowest traded price for the session.
double
A numeric type defining a number with fractional parts. (example: 2.14)
close
always returned
The last traded price for the session.
double
A numeric type defining a number with fractional parts. (example: 2.14)
flag
always returned
If present, can be one of the following: "c" meaning that the market is closed for this instrument. "p" meaning that the market is in a pre-open state. This occurs when there are bids and offers being placed, but no trade has occured yet. This is normally seen shortly before the official opening time for busy markets, but can also be seen throughout the day for lightly traded markets. "s" meaning that the instrument has settled, and that this is the final, settlement price.
string
A sequence of characters. (example: GOOG)
previousClose
as requested
The last traded price for the previous session.
double
A numeric type defining a number with fractional parts. (example: 2.14)
settlement
as requested
The settlement price determined the exchange.
double
A numeric type defining a number with fractional parts. (example: 2.14)
previousSettlement
as requested
The settlement price for the previous session.
double
A numeric type defining a number with fractional parts. (example: 2.14)
volume
always returned
The quantity of shares or contracts traded.
int
A numeric type defining a whole number. (example: 2)
openInterest
as requested
The quantity of open interest for futures.
double
A numeric type defining a number with fractional parts. (example: 2.14)
fiftyTwoWkHigh
as requested
The highest price over the past 52 weeks.
double
A numeric type defining a number with fractional parts. (example: 2.14)
fiftyTwoWkHighDate
as requested
The date in which the high price was reached over the past 52 weeks.
date
A date in the format of YYYY-MM-DD.
fiftyTwoWkLow
as requested
The low price over the past 52 weeks.
double
A numeric type defining a number with fractional parts. (example: 2.14)
fiftyTwoWkLowDate
as requested
The date in which the low price was reached over the past 52 weeks.
date
A date in the format of YYYY-MM-DD.
avgVolume
as requested
The average daily volume.
int
A numeric type defining a whole number. (example: 2)
sharesOutstanding
as requested
The total number of shares outstanding.
int
A numeric type defining a whole number. (example: 2)
dividendRateAnnual
as requested
The total dividend payout over one year.
float
A numeric type defining a number with fractional parts. (example: 2.14)
dividendYieldAnnual
as requested
The annual dividend divided by the current share price.
float
A numeric type defining a number with fractional parts. (example: 2.14)
exDividendDate
as requested
The last possible date to have owned shares of a stock and still be entitled to the associated dividend.
date
A date in the format of YYYY-MM-DD.
impliedVolatility
as requested
double
A numeric type defining a number with fractional parts. (example: 2.14)
twentyDayAvgVol
as requested
int
A numeric type defining a whole number. (example: 2)
month
as requested
Contract month returned for futures.
string
A sequence of characters. (example: GOOG)
year
as requested
Contract year returned for futures.
string
A sequence of characters. (example: GOOG)
expirationDate
as requested
The expiration date for the futures contract. Only returns a value for futures.
date
A date in the format of YYYY-MM-DD.
lastTradingDay
as requested
The last trading day of the futures contract. Only returns a value for futures.
string
A sequence of characters. (example: GOOG)
twelveMnthPct
as requested
double
A numeric type defining a number with fractional parts. (example: 2.14)
twelveMnthPctDate
as requested
date
A date in the format of YYYY-MM-DD.

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/getQuote.json?apikey=YOUR_API_KEY&symbols=AAPL%2CGOOG&fields=fiftyTwoWkHigh%2CfiftyTwoWkHighDate%2CfiftyTwoWkLow%2CfiftyTwoWkLowDate
Host: marketdata.websol.barchart.com

POST

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

apikey=YOUR_API_KEY&symbols=AAPL%2CGOOG&fields=fiftyTwoWkHigh%2CfiftyTwoWkHighDate%2CfiftyTwoWkLow%2CfiftyTwoWkLowDate

Response

{
    "status": {
        "code": 200,
        "message": "Success."
    },
    "results": [
        {
            "symbol": "AAPL",
            "name": "Apple Inc",
            "dayCode": "O",
            "serverTimestamp": "2018-05-25T13:07:11-05:00",
            "mode": "i",
            "lastPrice": 189.15,
            "tradeTimestamp": "2018-05-25T13:52:08-05:00",
            "netChange": 1,
            "percentChange": 0.53,
            "unitCode": "2",
            "open": 188.23,
            "high": 189.65,
            "low": 187.65,
            "close": 0,
            "numTrades": 52385,
            "dollarVolume": 1858177099.457,
            "flag": "",
            "volume": 11072000,
            "previousVolume": 23230301,
            "fiftyTwoWkHigh": 190.37,
            "fiftyTwoWkHighDate": "2018-05-10",
            "fiftyTwoWkLow": 142.2,
            "fiftyTwoWkLowDate": "2017-06-16"
        },
        {
            "symbol": "GOOG",
            "name": "Alphabet Class C",
            "dayCode": "O",
            "serverTimestamp": "2018-05-25T13:07:08-05:00",
            "mode": "i",
            "lastPrice": 1076.92,
            "tradeTimestamp": "2018-05-25T13:52:04-05:00",
            "netChange": -2.3199999999999,
            "percentChange": -0.21,
            "unitCode": "2",
            "open": 1079.02,
            "high": 1082.56,
            "low": 1075.93,
            "close": 0,
            "numTrades": 1967,
            "dollarVolume": 292532711.9219,
            "flag": "",
            "volume": 474987,
            "previousVolume": 766400,
            "fiftyTwoWkHigh": 1186.89,
            "fiftyTwoWkHighDate": "2018-01-29",
            "fiftyTwoWkLow": 894.79,
            "fiftyTwoWkLowDate": "2017-07-03"
        }
    ]
}

XML

GET

GET https://marketdata.websol.barchart.com/getQuote.xml?apikey=YOUR_API_KEY&symbols=AAPL%2CGOOG&fields=fiftyTwoWkHigh%2CfiftyTwoWkHighDate%2CfiftyTwoWkLow%2CfiftyTwoWkLowDate
Host: marketdata.websol.barchart.com

POST

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

apikey=YOUR_API_KEY&symbols=AAPL%2CGOOG&fields=fiftyTwoWkHigh%2CfiftyTwoWkHighDate%2CfiftyTwoWkLow%2CfiftyTwoWkLowDate

Response


<?xml version="1.0" encoding="utf-8"?>
 <getQuote>
  <status>
   <code>200</code>
   <message>Success.</message>
  </status>
  <item>
   <symbol>
AAPL</symbol>
   <name>
Apple Inc</name>
   <dayCode>
O</dayCode>
   <serverTimestamp>
2018-05-25T13:07:11-05:00</serverTimestamp>
   <mode>
i</mode>
   <lastPrice>
189.15</lastPrice>
   <tradeTimestamp>
2018-05-25T13:52:08-05:00</tradeTimestamp>
   <netChange>
1</netChange>
   <percentChange>
0.53</percentChange>
   <unitCode>
2</unitCode>
   <open>
188.23</open>
   <high>
189.65</high>
   <low>
187.65</low>
   <close>
0</close>
   <numTrades>
52385</numTrades>
   <dollarVolume>
1858177099.457</dollarVolume>
   <flag></flag>
   <volume>
11072000</volume>
   <previousVolume>
23230301</previousVolume>
   <fiftyTwoWkHigh>
190.37</fiftyTwoWkHigh>
   <fiftyTwoWkHighDate>
2018-05-10</fiftyTwoWkHighDate>
   <fiftyTwoWkLow>
142.2</fiftyTwoWkLow>
   <fiftyTwoWkLowDate>
2017-06-16</fiftyTwoWkLowDate>
  </item>
  <item>
   <symbol>
GOOG</symbol>
   <name>
Alphabet Class C</name>
   <dayCode>
O</dayCode>
   <serverTimestamp>
2018-05-25T13:07:08-05:00</serverTimestamp>
   <mode>
i</mode>
   <lastPrice>
1076.92</lastPrice>
   <tradeTimestamp>
2018-05-25T13:52:04-05:00</tradeTimestamp>
   <netChange>
-2.3199999999999</netChange>
   <percentChange>
-0.21</percentChange>
   <unitCode>
2</unitCode>
   <open>
1079.02</open>
   <high>
1082.56</high>
   <low>
1075.93</low>
   <close>
0</close>
   <numTrades>
1967</numTrades>
   <dollarVolume>
292532711.9219</dollarVolume>
   <flag></flag>
   <volume>
474987</volume>
   <previousVolume>
766400</previousVolume>
   <fiftyTwoWkHigh>
1186.89</fiftyTwoWkHigh>
   <fiftyTwoWkHighDate>
2018-01-29</fiftyTwoWkHighDate>
   <fiftyTwoWkLow>
894.79</fiftyTwoWkLow>
   <fiftyTwoWkLowDate>
2017-07-03</fiftyTwoWkLowDate>
  </item>
 </getQuote>

CSV

GET

GET https://marketdata.websol.barchart.com/getQuote.csv?apikey=YOUR_API_KEY&symbols=AAPL%2CGOOG&fields=fiftyTwoWkHigh%2CfiftyTwoWkHighDate%2CfiftyTwoWkLow%2CfiftyTwoWkLowDate
Host: marketdata.websol.barchart.com

POST

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

apikey=YOUR_API_KEY&symbols=AAPL%2CGOOG&fields=fiftyTwoWkHigh%2CfiftyTwoWkHighDate%2CfiftyTwoWkLow%2CfiftyTwoWkLowDate

Response

symbol,name,dayCode,serverTimestamp,mode,lastPrice,tradeTimestamp,netChange,percentChange,unitCode,open,high,low,close,numTrades,dollarVolume,flag,volume,previousVolume,fiftyTwoWkHigh,fiftyTwoWkHighDate,fiftyTwoWkLow,fiftyTwoWkLowDate
"AAPL","Apple Inc","O","2018-05-25T13:07:11-05:00","i","189.15","2018-05-25T13:52:08-05:00","1","0.53","2","188.23","189.65","187.65","0","52385","1858177099.457","","11072000","23230301","190.37","2018-05-10","142.2","2017-06-16"
"GOOG","Alphabet Class C","O","2018-05-25T13:07:08-05:00","i","1076.92","2018-05-25T13:52:04-05:00","-2.3199999999999","-0.21","2","1079.02","1082.56","1075.93","0","1967","292532711.9219","","474987","766400","1186.89","2018-01-29","894.79","2017-07-03"


PHP

<?php

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

$params = [
    'apikey' => 'YOUR_API_KEY',
    'symbols' => 'AAPL,GOOG',
    'fields' => 'fiftyTwoWkHigh,fiftyTwoWkHighDate,fiftyTwoWkLow,fiftyTwoWkLowDate',
];

$result = $ondemand->getQuote($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.getQuote("YOUR_API_KEY", "AAPL,GOOG", "fiftyTwoWkHigh,fiftyTwoWkHighDate,fiftyTwoWkLow,fiftyTwoWkLowDate")

Perl

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

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

my $result = $ondemand->getQuote('YOUR_API_KEY', 'AAPL,GOOG', 'fiftyTwoWkHigh,fiftyTwoWkHighDate,fiftyTwoWkLow,fiftyTwoWkLowDate');

print $result;

Python

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

result = client.service.getQuote('YOUR_API_KEY', 'AAPL,GOOG', 'fiftyTwoWkHigh,fiftyTwoWkHighDate,fiftyTwoWkLow,fiftyTwoWkLowDate')

print result

Ruby

require 'savon'

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

response = ondemand.call(
    :getQuote,
    message: {
        apikey: 'YOUR_API_KEY',
        symbols: 'AAPL,GOOG',
        fields: 'fiftyTwoWkHigh,fiftyTwoWkHighDate,fiftyTwoWkLow,fiftyTwoWkLowDate',
    }
)

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. BATS 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 2,500 getQuote queries and 1,000 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.