How to refresh API requests in Python? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

How to refresh API requests in Python?

Ok, I'm playing with requests and I have an infinite while loop with this simple API request from Binance for ETH-BTC price, with 2 sec time sleep, but it will never update the price, instead it's the same price every 2 seconds, so what am I doing wrong? import requests import time def pricee(): r = requests.get('https://api.binance.com/api/v3/ticker/price') while True: time.sleep(2) print((r.json()[0]['symbol']) + " " + (r.json()[0]['price'])) pricee()

6th Nov 2019, 6:20 PM
edward šŸ‡·šŸ‡“
edward šŸ‡·šŸ‡“ - avatar
1 Resposta
0
MiriellešŸ¶ [Inactive] it's from their docs, and the whole script it's working fine in pycharm, the only issue i have is that the price is not updating, even if i set a 2 sec time sleep, it keeps printing the same result without updateing it
6th Nov 2019, 8:23 PM
edward šŸ‡·šŸ‡“
edward šŸ‡·šŸ‡“ - avatar