Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Getting a single Json value in python

I have this API response, I want to take some values and store them as variables for a python BOT for example ‘floor_price’ (I want the integer after it ofc) but for some reason, it’s not working it keeps giving me errors but when I try it with ‘stats’ it works and gives everything.

The API https://api.opensea.io/api/v1/collection/ogcats-harvest-galaxy/stats

url = "https://api.opensea.io/api/v1/collection/ogcats-harvest-galaxy/stats"

 headers = {"Accept": "application/json"}

response = requests.request("GET", url)
json_response = response.json()
 floor= json_response['floor_price']

pls help 🙂

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

url = "https://api.opensea.io/api/v1/collection/ogcats-harvest-galaxy/stats"

headers = {"Accept": "application/json"}

response = requests.request("GET", url)
json_response = response.json()
floor= json_response['stats']['floor_price']

credits: @kindall

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading