Reputation: 1
So, I'm trying to learn Python and wanted to request some cryptocurrency pair data from Poloniex API by using this code below, and as I understood correctly I referred to the legacy code that isn't supported anymore, so I'm kinda stuck with undefined URL that I have to find out myself in order to practically replace this old version of it and to make it work as it intended to.
Here is my code:
import requests
import json
req = requests.get("https://poloniex.com/public?command=returnChartData¤cyPair=BTC_XMR&start=1546300800&end=1546646400&period=14400")
json_obj = json.loads(req.text)
for day in json_obj:
print(day["close"])
It returns me these errors:
JSONDecodeError Traceback (most recent call last)
<ipython-input-87-3354a61008d7> in <cell line: 5>()
3 import json
4 req = requests.get("https://poloniex.com/public?command=returnChartData¤cyPair=BTC_XMR&start=1546300800&end=1546646400&period=14400")
----> 5 json_obj = json.loads(req.text)
6 for day in json_obj:
7 print(day["close"])
2 frames
/usr/lib/python3.10/json/decoder.py in raw_decode(self, s, idx)
353 obj, end = self.scan_once(s, idx)
354 except StopIteration as err:
--> 355 raise JSONDecodeError("Expecting value", s, err.value) from None
356 return obj, end
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Upvotes: 0
Views: 38