# **Quick Start**
---

The Barchart OnDemand API can be used to programmatically retrieve and analyze data.

The Barchart OnDemand API uses API key to authenticate requests. Your API key carry many privileges, so be sure to keep them secure! Do not share your secret API key in publicly accessible areas such as GitHub, client-side code, and so forth.

All API requests must be made over HTTPS. Calls made over plain HTTP will fail. API requests without authentication will also fail.

## Using APIs

Barchart's Event-Based API provides developers REST API and/or Socket.IO endpoints for implementing market data and news based real-time alerts when their user-defined conditions occur.

This API provides access to a variety of different resources including the following:
- *getQuote*: The getQuote API is used to request price data, either real-time, delayed or end-of-day, by symbol on stocks, indexes, mutual funds, ETFs, futures, foreign exchange, or cryptocurrencies.
- *getHistory*: The getHistory API is used to request historical time series data on stocks, indexes, mutual funds, ETFs, futures, foreign exchange, or cryptocurrencies. Historical data is available as tick, minute bars or end-of-day data.
- *getQuoteEod*: The getQuoteEod API is used to request end-of-day price data, by combined exchange and symbol, on stocks, indexes, mutual funds, ETFs, futures, foreign exchange, or cryptocurrencies. Historical data is available as tick, minute bars or end-of-day data.
- *getFuturesOptions*: The getFuturesOptions API provides intraday or end-of-day options data such as strike price, closing price, expiration date, volume, volatility etc on futures contracts.
- *getFuturesSpreads*: The getFuturesSpreads API returns all active futures spread for the requested commodity.
- ...

## Get an API key

Head over to the [Barchart OnDemand website](https://www.barchart.com/ondemand/contact) and fill out the 'Contact Us' form. The Barchart team will quickly set up your very own API key.

Save your API key and keep them secure. You will be provided an API Key (also known as Customer or Client Key).

## Clients

[Java](https://github.com/barchart/barchart-ondemand-client-java) / [JavaScript](https://github.com/barchart/barchart-ondemand-client-js) / [PHP](https://github.com/barchart/barchart-ondemand-client-php) / [Python](https://github.com/barchart/barchart-ondemand-client-python) / [MATLAB](https://www.mathworks.com/matlabcentral/fileexchange/68211-barchart-ondemand-for-matlab?s_tid=prof_contriblnk)

## Resource URL

```https://ondemand.websol.barchart.com```

## Make your first request

Once you have an API key, you’re ready to get started using the Barchart OnDemand API! We have quick start guides for many of our endpoints, useful tools and libraries and sample code, and tutorials that describe how to build solutions around different use cases.

In general, the Barchart OnDemand API uses HTTP requests with query arguments and JSON responses. Request authentication is via API Key parameter (apikey=YOUR_API_KEY).

As an example, let's retrieve price data by symbol:

- Open your favorite web browser
- Enter your API key into the url template: ```https://ondemand.websol.barchart.com/getQuote.json?apikey=[YOUR_API_KEY]&symbols=AAPL```
- Copy and paste the url into the browser, and hit enter

Voila! The API will returned data to your browser, similar to below:
```
{
    "status": {
        "code": 200,
        "message": "Success."
    },
    "results": [
        {
            "symbol": "AAPL",
            "name": "Apple Inc",
            "dayCode": "S",
            "serverTimestamp": "2021-01-29T21:22:00-06:00",
            "mode": "i",
            "lastPrice": 131.96,
            "tradeTimestamp": "2021-01-29T16:00:00-06:00",
            "netChange": -5.1299999999999955,
            "percentChange": -3.74,
            "unitCode": "2",
            "open": 135.83,
            "high": 136.74,
            "low": 130.21,
            "close": 131.96,
            "numTrades": 1695248,
            "dollarVolume": 24151076273.1492,
            "flag": "s",
            "volume": 177523800,
            "previousVolume": 142621109
        }
    ]
}
```

Congrats! You've made your first query. Feel free to check detailed API documentation in our API Reference Section.
