1

I've been trying to load the Kraken-api-content for hours now, but it still doesn't work. My problem is the following: In the api-description https://www.kraken.com/help/api#public-market-data there it says something like "input". I.e. for the URL https://api.kraken.com/0/public/AssetPairs it is optional to use "input": "info = leverage", otherwise it works with the default "info = all info". So my python2.7-code

import os
import urllib, json
import time
dir_path_this = os.path.dirname(os.path.realpath(__file__))
os.chdir(dir_path_this)
URL = "https://api.kraken.com/0/public/AssetPairs"
FILENAME_PAIR = "pair"+ ".json"
response = urllib.urlopen(URL)
pairinfo_dict = json.loads(response.read())
with open(FILENAME_PAIR, 'wb') as outfile:
json.dump(pairinfo_dict, outfile)

works just fine, because the "input" is taken by default, I don't have to set it. But with the URL https://api.kraken.com/0/public/Ticker you have to tell Python your "input": "pair = comma delimited list of asset pairs to get info on", as it says in the API-description. So when I run the code from above with the latter URL, I get an error, because "input" isn't set by default and I don't know how to change the code in order to tell Python which input-option to use.

Does anyone know what parameter or argument it is I have to explicitly set?

Studentu
  • 1,375
  • 2
  • 10
  • 11

2 Answers2

1

You can just append the query parameters to URL like this:

URL = "https://api.kraken.com/0/public/Ticker?pair=XXRPZUSD,XXRPXXBT"
Emir Uner
  • 415
  • 2
  • 5
-1

The asset pairs are actually listed on https://api.kraken.com/0/public/AssetPairs it's just convoluted to read. For example XBTUSD is one asset pair, you can search that page for that pair. So if your polling the ticker for the price of bitcoin in usd you would set your pair to XBTUSD which will show you the ask price, bid offers, etc... as shown on FAQ. Good luck.

  • 1
    Thanks for your answer, soulless. The thing is, https://api.kraken.com/0/public/AssetPairs works fine and so does it in the python code, I don't have to make use of the option to tell python wich pair to load in advance, but can just load the whole file as set by default and then search for certain pairs as you described it. But with https://api.kraken.com/0/public/Ticker this is not the case. Neither does the link work nor loading it in the python code, because one has to set the option pair = ..., there's no default. So what I'd like to know is HOW to set this option in the code. – Studentu Jul 29 '17 at 11:46