有人知道如何从Binance的API打印JSON结果吗?我一直在get_all_tickers
使用它来返回所有符号和价格。我希望能够选择某个交易品种和价格并将其实时显示在终端中,或者直到用户退出为止。我正在使用this library。
我的代码:
url = 'https://api.binance.com/api/v3/ticker/price'
response = reqs.get(url) # To execute get request
print(response.status_code) # To print http response code
print(response.content)
print(response.json) # To print formatted JSON response
输出:
200
{
"userId": 1,
"id": 1,
"title": "market data",
"completed": False
}