<p>It may be possible to retrieve raw OHLC and VWAP data from bitcoincharts.com in a not-too-difficult manner using JavaScript (as well as jQuery) by extracting the relevant tabular data provided at <a href="http://bitcoincharts.com/charts/krakenEUR#rg60ztgSzm1g10zm2g25zv" rel="nofollow noreferrer">http://bitcoincharts.com/charts/krakenEUR#rg60ztgSzm1g10zm2g25zv</a> and passing it to an external charting application.</p>

<p>Unfortunately, extracting HTML data from an external website using JavaScript can sometimes be a complicated process, due to the presence of content security and <a href="http://en.wikipedia.org/wiki/Same-origin_policy" rel="nofollow noreferrer">same origin policies</a> (these issues apply particularly to Google Chrome).</p>

<p>The following question on StackOverflow explores an easy way to retrieve external HTML using jQuery and AJAX (<a href="https://stackoverflow.com/questions/15005500/loading-cross-domain-html-page-with-jquery-ajax">https://stackoverflow.com/questions/15005500/loading-cross-domain-html-page-with-jquery-ajax</a>).
A simple solution using the aforementioned method could be similar to the following:</p>

<pre><code>$.ajaxSetup({
    scriptCharset: "utf-8", //maybe "ISO-8859-1"
    contentType: "application/json; charset=utf-8"
});

$.getJSON('http://whateverorigin.org/get?url=' + 
  encodeURIComponent('http://bitcoincharts.com/charts/krakenEUR#rg60ztgSzm1g10zm2g25zv') + '&amp;callback=?',
    function(data) {
        console.log("&gt; ", data);
        $("#chart_table" tbody tr).find("td").html(data.contents);
});
</code></pre>

<p>Essentially, this method of extracting data from an API or website would depend on what language you are using, and whether you are implementing a back-end. Perhaps placing a similar question on <a href="https://stackoverflow.com/">StackOverflow</a>, a site dedicated to programming questions would return better suited results.</p>

<p><strong>Edit:</strong> More information regarding bypassing same origin policies can be found at <a href="http://christianheilmann.com/2010/01/10/loading-external-content-with-ajax-using-jquery-and-yql/" rel="nofollow noreferrer">Christian Heilmann's blog</a>, a developer evangelist with the Mozilla Network.
Information regarding utilising GET and POST requests can be found at <a href="http://www.slideshare.net/DonchoMinkov/external-data-access-with-jquery" rel="nofollow noreferrer">Doncho Minkov's SlideShare</a>, however, this may not be the most effective way to access data when restricted by same origin policies.</p>

CC BY-SA 3.0
2014-11-30T07:34:30.847Z
2014-12-01T10:45:58.170Z
2017-05-23T12:34:59.703Z
psgs
<p>I'm interested in the OHLC / VWAP data (both historical and recent) provided via API to be used by external charting application.<br>
I don't want to use <code>trades</code> methods as whole process should be as lightweight as possible, <code>trades</code> method is redundant due to history loading speed.<br>
Combining <a href="http://bitcoincharts.com/about/markets-api/" rel="nofollow">bitcoincharts.com</a> csv historical trades with markets API recent trades would be kind of error prone.</p>

<p>Another option would be to access the following data:</p>

<ol>
<li>visit bitcoincharts chart: <a href="http://bitcoincharts.com/charts/krakenEUR" rel="nofollow">http://bitcoincharts.com/charts/krakenEUR</a></li>
<li>below the chart in the left corner click on <code>Load raw data</code></li>
<li>and just download those data</li>
</ol>

<p>I've checked the page and data appears in <code>tbody</code> in the following <code>div</code> after click on <code>Load raw data</code>:</p>

<pre><code>&lt;div&gt;
  &lt;a href="#" onclick="load_table();return false;"&gt;Load raw data&lt;/a&gt;
  &lt;table class="data" id="chart_table" style="display: none;"&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;Timestamp&lt;/th&gt;&lt;th&gt;Open&lt;/th&gt;&lt;th&gt;High&lt;/th&gt;&lt;th&gt;Low&lt;/th&gt;&lt;th&gt;Close&lt;/th&gt;&lt;th&gt;Volume (BTC)&lt;/th&gt;&lt;th&gt;Volume (Currency)&lt;/th&gt;&lt;th&gt;Weighted Price&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;
&lt;/div&gt;
</code></pre>

<p>Is there any easy way to access those data similarly to API?</p>

<p>Another way is to ask markets for such method, kraken already provide such: <a href="https://api.kraken.com/0/public/OHLC?pair=XBTCZEUR&amp;interval=60&amp;since=1416160800" rel="nofollow">https://api.kraken.com/0/public/OHLC?pair=XBTCZEUR&amp;interval=60&amp;since=1416160800</a><br>
I've just asked for such method on hitbtc market, you can track/contribute here: <a href="https://github.com/hitbtc-com/hitbtc-api/issues/7" rel="nofollow">https://github.com/hitbtc-com/hitbtc-api/issues/7</a></p>

<exchanges><api>
API feed for OHLC / VWAP data in (close to) real-time
jangorecki
# API feed for OHLC / VWAP data in (close to) real-time

(Asked by: username_0 on 2014-11-16)

I'm interested in the OHLC / VWAP data (both historical and recent) provided via API to be used by external charting application.  
I don't want to use `trades` methods as whole process should be as lightweight as possible, `trades` method is redundant due to history loading speed.  
Combining [bitcoincharts.com](http://bitcoincharts.com/about/markets-api/) csv historical trades with markets API recent trades would be kind of error prone.

Another option would be to access the following data:

1. visit bitcoincharts chart: <http://bitcoincharts.com/charts/krakenEUR>
2. below the chart in the left corner click on `Load raw data`
3. and just download those data

I've checked the page and data appears in `tbody` in the following `div` after click on `Load raw data`:

```
<div>
  <a href="#" onclick="load_table();return false;">Load raw data</a>
  <table class="data" id="chart_table" style="display: none;">
    <thead>
      <tr>
        <th>Timestamp</th><th>Open</th><th>High</th><th>Low</th><th>Close</th><th>Volume (BTC)</th><th>Volume (Currency)</th><th>Weighted Price</th>
      </tr>
    </thead>
    <tbody>
    </tbody>
  </table>
</div>

```

Is there any easy way to access those data similarly to API?

Another way is to ask markets for such method, kraken already provide such: <https://api.kraken.com/0/public/OHLC?pair=XBTCZEUR&interval=60&since=1416160800>  
I've just asked for such method on hitbtc market, you can track/contribute here: <https://github.com/hitbtc-com/hitbtc-api/issues/7>

**Tags:** exchanges, api


---

## 1 answers

### Answer by username_1 on 2014-11-30. Score: 2

It may be possible to retrieve raw OHLC and VWAP data from bitcoincharts.com in a not-too-difficult manner using JavaScript (as well as jQuery) by extracting the relevant tabular data provided at <http://bitcoincharts.com/charts/krakenEUR#rg60ztgSzm1g10zm2g25zv> and passing it to an external charting application.

Unfortunately, extracting HTML data from an external website using JavaScript can sometimes be a complicated process, due to the presence of content security and [same origin policies](http://en.wikipedia.org/wiki/Same-origin_policy) (these issues apply particularly to Google Chrome).

The following question on StackOverflow explores an easy way to retrieve external HTML using jQuery and AJAX (<https://stackoverflow.com/questions/15005500/loading-cross-domain-html-page-with-jquery-ajax>).
A simple solution using the aforementioned method could be similar to the following:

```
$.ajaxSetup({
    scriptCharset: "utf-8", //maybe "ISO-8859-1"
    contentType: "application/json; charset=utf-8"
});

$.getJSON('http://whateverorigin.org/get?url=' + 
  encodeURIComponent('http://bitcoincharts.com/charts/krakenEUR#rg60ztgSzm1g10zm2g25zv') + '&callback=?',
    function(data) {
        console.log("> ", data);
        $("#chart_table" tbody tr).find("td").html(data.contents);
});

```

Essentially, this method of extracting data from an API or website would depend on what language you are using, and whether you are implementing a back-end. Perhaps placing a similar question on [StackOverflow](https://stackoverflow.com/), a site dedicated to programming questions would return better suited results.

**Edit:** More information regarding bypassing same origin policies can be found at [Christian Heilmann's blog](http://christianheilmann.com/2010/01/10/loading-external-content-with-ajax-using-jquery-and-yql/), a developer evangelist with the Mozilla Network.
Information regarding utilising GET and POST requests can be found at [Doncho Minkov's SlideShare](http://www.slideshare.net/DonchoMinkov/external-data-access-with-jquery), however, this may not be the most effective way to access data when restricted by same origin policies.


---

