All
Filter by:
How do I deposit cash into my account?
I need help with account verification
Why can't I access my account?
Are there any crypto withdrawal fees?
I need help signing into my account
Required Legal Notice: Virtual currencies, real risks. The only guarantee in crypto is risk. Read more
Required Legal Notice: Virtual currencies, real risks. The only guarantee in crypto is risk. Read more
Required Legal Notice: Virtual currencies, real risks. The only guarantee in crypto is risk. Warning: The value of your virtual currencies can rise or fall sharply, and your initial investment may be lost completely; virtual currencies are not covered by the guarantee funds that cover bank deposits; there is no legal mechanism on the virtual currencies market to prevent market manipulation or insider dealing; virtual currencies depend entirely on a specific computer technology and infrastructure, which in certain cases may be very recent and not yet adequately tested; if one loses the identification code or password giving access to the virtual wallet in which the virtual currency is stored, the currency held therein will be irretrievably lost; virtual currencies are currently accepted as a means of payment to a limited extent, and in most countries there is no legal obligation to accept them; for more information about the risks associated with an investment in virtual currencies, we advise you to read the Wikifin page What is a cryptocurrency? | Wikifin.
Required Legal Notice: Virtual currencies, real risks. The only guarantee in crypto is risk. Warning: The value of your virtual currencies can rise or fall sharply, and your initial investment may be lost completely; virtual currencies are not covered by the guarantee funds that cover bank deposits; there is no legal mechanism on the virtual currencies market to prevent market manipulation or insider dealing; virtual currencies depend entirely on a specific computer technology and infrastructure, which in certain cases may be very recent and not yet adequately tested; if one loses the identification code or password giving access to the virtual wallet in which the virtual currency is stored, the currency held therein will be irretrievably lost; virtual currencies are currently accepted as a means of payment to a limited extent, and in most countries there is no legal obligation to accept them; for more information about the risks associated with an investment in virtual currencies, we advise you to read the Wikifin page What is a cryptocurrency? | Wikifin.
Our REST API public endpoints are accessible via a simple HTTP request (just as a web page is requested via a web browser), so an API client to import market data into a Google Sheet can be implemented with just a few lines of Google Script code.
Create a new Google Sheet or open an existing sheet.
Open the script editor via the Extensions -> Apps Script menu.
Delete the default code that is shown (Select All then Delete/Backspace, for example).
Copy/Paste the Google Script API code (shown below) into the script editor.
Optional - Add any additional custom functions that you require (to call different endpoints or return different JSON fields, for example).
Save the Google Script Code via the (Save project) icon.

The KAPI_Public() function is responsible for creating the appropriate URL and making the HTTP request to the API. The KAPI_Public() function can be called directly by entering the following (or similar depending upon the endpoint and the parameters) within a Google Sheet cell:
Bash
=KAPI_Ticker("XBTUSD,ETHEUR,LTCUSD,XDGXBT,XDGUSD")
=KAPI_Depth("XDGUSD", "5")The KAPI_Public() function returns the original JSON response from the API, such as the following for the above Depth endpoint example:
Bash
{"error":[],"result":{"XETHZUSD":{"asks":[["231.74000","4.386",1583402326],["231.75000","27.337",1583402277],["231.76000","5.887",1583402311],["231.79000","36.280",1583402334],["231.80000","50.000",1583402299]],"bids":[["231.70000","18.534",1583402335],["231.67000","22.109",1583402335],["231.61000","7.930",1583402335],["231.60000","33.841",1583402335],["231.54000","115.017",1583402334]]}}}In order to place the individual fields/values into separate cells within the Google Sheet, additional custom functions can be called to parse the JSON response, such as the example KAPI_Ticker() and KAPI_Depth() functions:
Bash
=KAPI_Ticker("XBTUSD,ETHEUR,LTCUSD,XDGXBT,XDGUSD")
=KAPI_Depth("XDGUSD", "5")which would display the results similar to the following, where the data would be accessible to any of the standard Google Sheets functions (SUM, AVERAGE, COUNT, etc.):

General Function to be included for calls to all Public Endpoints:
Bash
function KAPI_Public(endpoint, parameters) {
http_response = UrlFetchApp.fetch(
'https://api.kraken.com/0/public/' + endpoint + '?' + parameters
)
api_data = http_response.getContentText()
return api_data
}Examples of Functions that are specific to a particular Endpoint:
Depth:
Bash
function KAPI_Depth(currency_pair, depth) {
api_data = JSON.parse(
KAPI_Public("Depth", "pair=" + currency_pair + "&count=" + depth)
)
api_results = new Array()
for (count = 0; count < parseInt(depth); count++) {
api_results.push([
api_data['result'][currency_pair]['bids'][count][0],
api_data['result'][currency_pair]['bids'][count][1],
api_data['result'][currency_pair]['asks'][count][0],
api_data['result'][currency_pair]['asks'][count][1]
])
}
return api_results
}Ticker:
Bash
function KAPI_Ticker(currency_pairs) {
api_data = JSON.parse(
KAPI_Public("Ticker", "pair=" + currency_pairs)
)
api_results = new Array()
for (name in api_data['result']) {
api_results.push([
name,
api_data['result'][name]['a'][0],
api_data['result'][name]['a'][2],
api_data['result'][name]['b'][0],
api_data['result'][name]['b'][2],
api_data['result'][name]['c'][0],
api_data['result'][name]['c'][1]
])
}
return api_results
}To use the scripts above, simply append the generic script to the endpoint specific script:
Bash
function KAPI_Public(endpoint, parameters) {
http_response = UrlFetchApp.fetch(
'https://api.kraken.com/0/public/' + endpoint + '?' + parameters
)
api_data = http_response.getContentText()
return api_data
}
function KAPI_Depth(currency_pair, depth) {
api_data = JSON.parse(
KAPI_Public("Depth", "pair=" + currency_pair + "&count=" + depth)
)
api_results = new Array()
for (count = 0; count < parseInt(depth); count++) {
api_results.push([
api_data['result'][currency_pair]['bids'][count][0],
api_data['result'][currency_pair]['bids'][count][1],
api_data['result'][currency_pair]['asks'][count][0],
api_data['result'][currency_pair]['asks'][count][1]
])
}
return api_results
}The decimal and thousands separators shown in this article may differ from the formats displayed on our trading platforms. Review our article on how we use points and commas for more information.