getCryptoHistory API

The getCryptoHistory API provides historical price data for cryptocurrencies.

All APIs

Contact Us to Get Access

Inputs

symbol required

A valid cryptocurrency symbol.

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

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:
ticks, minutes, nearbyMinutes, formTMinutes, daily, weekly, monthly, quarterly, yearly

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
20171120 

endDate optional

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

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

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

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
dateTime
A date and time in the format of YYYY-MM-DD HH:MI:SS<TIMEZONE_OFFSET>.
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
24 hour volume is composed of the exchanges included in our data feed and reflects the notional USD traded in that rolling 24 hour window. Note that historical 24 hour volume is a snapshot of this measure at 5 EST for the day in question.
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://ondemand.websol.barchart.com/getCryptoHistory.json?apikey=<YOUR API KEY>&symbol=%5EBTCUSD&type=minutes&startDate=20171120&endDate=20171121&maxRecords=10&interval=60&order=asc
Host: ondemand.websol.barchart.com

POST

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

apikey=<YOUR API KEY>&symbol=%5EBTCUSD&type=minutes&startDate=20171120&endDate=20171121&maxRecords=10&interval=60&order=asc

Response

{
    "status": {
        "code": 200,
        "message": "Success."
    },
    "results": [
        {
            "symbol": "^BTCUSD",
            "timestamp": "2017-11-19T14:00:00-05:00",
            "tradingDay": "2017-11-20",
            "open": 8038.71,
            "high": 8110.59,
            "low": 8038.71,
            "close": 8045.06,
            "volume": 0
        },
        {
            "symbol": "^BTCUSD",
            "timestamp": "2017-11-19T15:00:00-05:00",
            "tradingDay": "2017-11-20",
            "open": 8045.06,
            "high": 8073.45,
            "low": 8021.89,
            "close": 8023.97,
            "volume": 0
        },
        {
            "symbol": "^BTCUSD",
            "timestamp": "2017-11-19T16:00:00-05:00",
            "tradingDay": "2017-11-20",
            "open": 8023.97,
            "high": 8030.45,
            "low": 7958.01,
            "close": 8022.88,
            "volume": 0
        },
        {
            "symbol": "^BTCUSD",
            "timestamp": "2017-11-19T17:00:00-05:00",
            "tradingDay": "2017-11-20",
            "open": 8022.88,
            "high": 8061.32,
            "low": 7989.16,
            "close": 8044.88,
            "volume": 0
        },
        {
            "symbol": "^BTCUSD",
            "timestamp": "2017-11-19T18:00:00-05:00",
            "tradingDay": "2017-11-20",
            "open": 8044.11,
            "high": 8059.23,
            "low": 8023.58,
            "close": 8039.62,
            "volume": 0
        },
        {
            "symbol": "^BTCUSD",
            "timestamp": "2017-11-19T19:00:00-05:00",
            "tradingDay": "2017-11-20",
            "open": 8039.62,
            "high": 8067.98,
            "low": 8003.09,
            "close": 8021.03,
            "volume": 0
        },
        {
            "symbol": "^BTCUSD",
            "timestamp": "2017-11-19T20:00:00-05:00",
            "tradingDay": "2017-11-20",
            "open": 8021.03,
            "high": 8022.95,
            "low": 7972.36,
            "close": 7978.35,
            "volume": 0
        },
        {
            "symbol": "^BTCUSD",
            "timestamp": "2017-11-19T21:00:00-05:00",
            "tradingDay": "2017-11-20",
            "open": 7978.35,
            "high": 7992.19,
            "low": 7945.17,
            "close": 7961.73,
            "volume": 0
        },
        {
            "symbol": "^BTCUSD",
            "timestamp": "2017-11-19T22:00:00-05:00",
            "tradingDay": "2017-11-20",
            "open": 7961.73,
            "high": 8014.64,
            "low": 7957.3,
            "close": 8011.87,
            "volume": 0
        },
        {
            "symbol": "^BTCUSD",
            "timestamp": "2017-11-19T23:00:00-05:00",
            "tradingDay": "2017-11-20",
            "open": 8011.87,
            "high": 8012.07,
            "low": 7974.2,
            "close": 8000.44,
            "volume": 0
        }
    ]
}

XML

GET

GET https://ondemand.websol.barchart.com/getCryptoHistory.xml?apikey=<YOUR API KEY>&symbol=%5EBTCUSD&type=minutes&startDate=20171120&endDate=20171121&maxRecords=10&interval=60&order=asc
Host: ondemand.websol.barchart.com

POST

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

apikey=<YOUR API KEY>&symbol=%5EBTCUSD&type=minutes&startDate=20171120&endDate=20171121&maxRecords=10&interval=60&order=asc

Response


<?xml version="1.0" encoding="utf-8"?>
 <getCryptoHistory>
  <status>
   <code>200</code>
   <message>Success.</message>
  </status>
  <item>
   <symbol>^BTCUSD</symbol>
   <timestamp>2017-11-19T14:00:00-05:00</timestamp>
   <tradingDay>2017-11-20</tradingDay>
   <open>8038.71</open>
   <high>8110.59</high>
   <low>8038.71</low>
   <close>8045.06</close>
   <volume>0</volume>
  </item>
  <item>
   <symbol>^BTCUSD</symbol>
   <timestamp>2017-11-19T15:00:00-05:00</timestamp>
   <tradingDay>2017-11-20</tradingDay>
   <open>8045.06</open>
   <high>8073.45</high>
   <low>8021.89</low>
   <close>8023.97</close>
   <volume>0</volume>
  </item>
  <item>
   <symbol>^BTCUSD</symbol>
   <timestamp>2017-11-19T16:00:00-05:00</timestamp>
   <tradingDay>2017-11-20</tradingDay>
   <open>8023.97</open>
   <high>8030.45</high>
   <low>7958.01</low>
   <close>8022.88</close>
   <volume>0</volume>
  </item>
  <item>
   <symbol>^BTCUSD</symbol>
   <timestamp>2017-11-19T17:00:00-05:00</timestamp>
   <tradingDay>2017-11-20</tradingDay>
   <open>8022.88</open>
   <high>8061.32</high>
   <low>7989.16</low>
   <close>8044.88</close>
   <volume>0</volume>
  </item>
  <item>
   <symbol>^BTCUSD</symbol>
   <timestamp>2017-11-19T18:00:00-05:00</timestamp>
   <tradingDay>2017-11-20</tradingDay>
   <open>8044.11</open>
   <high>8059.23</high>
   <low>8023.58</low>
   <close>8039.62</close>
   <volume>0</volume>
  </item>
  <item>
   <symbol>^BTCUSD</symbol>
   <timestamp>2017-11-19T19:00:00-05:00</timestamp>
   <tradingDay>2017-11-20</tradingDay>
   <open>8039.62</open>
   <high>8067.98</high>
   <low>8003.09</low>
   <close>8021.03</close>
   <volume>0</volume>
  </item>
  <item>
   <symbol>^BTCUSD</symbol>
   <timestamp>2017-11-19T20:00:00-05:00</timestamp>
   <tradingDay>2017-11-20</tradingDay>
   <open>8021.03</open>
   <high>8022.95</high>
   <low>7972.36</low>
   <close>7978.35</close>
   <volume>0</volume>
  </item>
  <item>
   <symbol>^BTCUSD</symbol>
   <timestamp>2017-11-19T21:00:00-05:00</timestamp>
   <tradingDay>2017-11-20</tradingDay>
   <open>7978.35</open>
   <high>7992.19</high>
   <low>7945.17</low>
   <close>7961.73</close>
   <volume>0</volume>
  </item>
  <item>
   <symbol>^BTCUSD</symbol>
   <timestamp>2017-11-19T22:00:00-05:00</timestamp>
   <tradingDay>2017-11-20</tradingDay>
   <open>7961.73</open>
   <high>8014.64</high>
   <low>7957.3</low>
   <close>8011.87</close>
   <volume>0</volume>
  </item>
  <item>
   <symbol>^BTCUSD</symbol>
   <timestamp>2017-11-19T23:00:00-05:00</timestamp>
   <tradingDay>2017-11-20</tradingDay>
   <open>8011.87</open>
   <high>8012.07</high>
   <low>7974.2</low>
   <close>8000.44</close>
   <volume>0</volume>
  </item>
 </getCryptoHistory>

CSV

GET

GET https://ondemand.websol.barchart.com/getCryptoHistory.csv?apikey=<YOUR API KEY>&symbol=%5EBTCUSD&type=minutes&startDate=20171120&endDate=20171121&maxRecords=10&interval=60&order=asc
Host: ondemand.websol.barchart.com

POST

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

apikey=<YOUR API KEY>&symbol=%5EBTCUSD&type=minutes&startDate=20171120&endDate=20171121&maxRecords=10&interval=60&order=asc

Response

symbol,timestamp,tradingDay,open,high,low,close,volume
"^BTCUSD","2017-11-19T14:00:00-05:00","2017-11-20","8038.71","8110.59","8038.71","8045.06","0"
"^BTCUSD","2017-11-19T15:00:00-05:00","2017-11-20","8045.06","8073.45","8021.89","8023.97","0"
"^BTCUSD","2017-11-19T16:00:00-05:00","2017-11-20","8023.97","8030.45","7958.01","8022.88","0"
"^BTCUSD","2017-11-19T17:00:00-05:00","2017-11-20","8022.88","8061.32","7989.16","8044.88","0"
"^BTCUSD","2017-11-19T18:00:00-05:00","2017-11-20","8044.11","8059.23","8023.58","8039.62","0"
"^BTCUSD","2017-11-19T19:00:00-05:00","2017-11-20","8039.62","8067.98","8003.09","8021.03","0"
"^BTCUSD","2017-11-19T20:00:00-05:00","2017-11-20","8021.03","8022.95","7972.36","7978.35","0"
"^BTCUSD","2017-11-19T21:00:00-05:00","2017-11-20","7978.35","7992.19","7945.17","7961.73","0"
"^BTCUSD","2017-11-19T22:00:00-05:00","2017-11-20","7961.73","8014.64","7957.3","8011.87","0"
"^BTCUSD","2017-11-19T23:00:00-05:00","2017-11-20","8011.87","8012.07","7974.2","8000.44","0"


PHP

<?php

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

$params = [
    'symbol' => '^BTCUSD',
    'type' => 'minutes',
    'startDate' => '20171120',
    'endDate' => '20171121',
    'maxRecords' => '10',
    'interval' => '60',
    'order' => 'asc',
];

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

Classic ASP

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.getCryptoHistory("^BTCUSD", "minutes", "20171120", "20171121", "10", "60", "asc")

Perl

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

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

my $result = $ondemand->getCryptoHistory('^BTCUSD', 'minutes', '20171120', '20171121', '10', '60', 'asc');

print $result;

Python

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

result = client.service.getCryptoHistory('^BTCUSD', 'minutes', '20171120', '20171121', '10', '60', 'asc')

print result

Ruby

require 'savon'

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

response = ondemand.call(
    :getCryptoHistory,
    message: {
        symbol: '^BTCUSD',
        type: 'minutes',
        startDate: '20171120',
        endDate: '20171121',
        maxRecords: '10',
        interval: '60',
        order: 'asc',
    }
)

response.body