Here is the data i want to get from
import json
url = "https://api.opensea.io/api/v1/collection/elonpunkyachtclub/stats"
headers = {"Accept": "application/json"}
response = requests.request("GET", url, headers=headers)
data = response.json
decoded = json.loads(data)
{
"stats": {
"one_day_volume": 3.4598559686941988,
"one_day_change": -0.26082160690977335,
"one_day_sales": 167,
"one_day_average_price": 0.020717700411342507,
"seven_day_volume": 24.111522658583088,
"seven_day_change": 60.74608045431068,
"seven_day_sales": 1284,
"seven_day_average_price": 0.01877844443814882,
"thirty_day_volume": 24.502017447583082,
"thirty_day_change": 0,
"thirty_day_sales": 1370,
"thirty_day_average_price": 0.017884684268308818,
"total_volume": 24.50201744758308,
"total_sales": 1370,
"total_supply": 6969,
"count": 6969,
"num_owners": 1854,
"average_price": 0.017884684268308818,
"num_reports": 4,
"market_cap": 130.86697928945915,
"floor_price": 0.022
}
}
print(data)
print(data['stats']['floor_price'])
I want to fetch the floor price from the data
Getting error, what I am doing wrong?
Any help is appreciated, thanks…….
>Solution :
From the error, it seems that you are operating on a string, not decoded data. Try decoding first:
import json
# ... get data
decoded = json.loads(data)
print(decoded['stats']['floor_price'])