Bitcoin Forum
June 18, 2024, 02:28:31 AM *
News: Voting for pizza day contest
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Kraken API: "ValueError: No JSON object could be decoded"  (Read 661 times)
rothj (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 0


View Profile
July 09, 2017, 12:00:41 AM
 #1

I'm working with the Kraken API to pull OHLC data and am receiving the following error in some of my API requests:

"Traceback (most recent call last):
  File "/Users/someone/anaconda/lib/python2.7/site-packages/krakenex/api.py", line 83, in _query
    return json.loads(ret)
  File "/Users/someone/anaconda/lib/python2.7/json/__init__.py", line 339, in loads
    return _default_decoder.decode(s)
  File "/Users/someone/anaconda/lib/python2.7/json/decoder.py", line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/Users/someone/anaconda/lib/python2.7/json/decoder.py", line 382, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded"

Can anyone advise me on how to avoid this error?

Thanks!
Jake
pooya87
Legendary
*
Offline Offline

Activity: 3486
Merit: 10664



View Profile
July 09, 2017, 03:38:01 AM
 #2

you have to post the code that you used, or at least the value that passed in that code as the JSON data not the exception that was thrown.

my guess is you passing something that is not a JSON as a JSON to your code which is why it can not decode it.

break down your code to where you are passing that JSON in and see what the real value is.

this is what that JSON should look like: https://api.kraken.com/0/public/OHLC?pair=XBTUSD&interval=1440

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
rothj (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 0


View Profile
July 30, 2017, 04:06:39 AM
 #3

Thanks, sorry, I missed seeing your response.

Two things:

(1) error message

```python
Traceback (most recent call last):
.
.
.
  File "/Users/MYUSER/anaconda/envs/python3/lib/python3.5/site-packages/krakenex/api.py", line 148, in query_public
    return self._query(urlpath, req, conn)
  File "/MYUSER/anaconda/envs/python3/lib/python3.5/site-packages/krakenex/api.py", line 131, in _query
    return json.loads(ret)
  File "/Users/MYUSER/anaconda/envs/python3/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/Users/MYUSER/anaconda/envs/python3/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/Users/MYUSER/anaconda/envs/python3/lib/python3.5/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
```

(2) my code (using the krakenex Python3 API: https://github.com/veox/python3-krakenex)
```python
import krakenex
k = krakenex.API()                                                  # instantiate API object
pair = ["DASHEUR", "XETHZCAD"]                            # and some others; these just shown as example
k.query_public(method="Ticker", req={"pair":pair})  # make public queries to Kraken
```
locked_in
Newbie
*
Offline Offline

Activity: 13
Merit: 0


View Profile
July 30, 2017, 04:34:04 AM
 #4

Un-fucking-believable that Kraken would actually return the error to you instead of a regular plain 400 or 500 error.


They actually returned a Python exception to you?
Rannasha
Hero Member
*****
Offline Offline

Activity: 728
Merit: 500


View Profile
July 30, 2017, 07:55:15 AM
 #5

Un-fucking-believable that Kraken would actually return the error to you instead of a regular plain 400 or 500 error.


They actually returned a Python exception to you?

No, the Python errors shown are from the client-side. Kraken typically returns a JSON with the appropriate error message if something goes wrong.

@OP: It seems that something in the response message doesn't parse correctly in the JSON decoder. So take a look at the raw response message, not the Python error message, (or post it here) to see what's going on.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!