-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyapp.py
More file actions
52 lines (41 loc) · 1.63 KB
/
Copy pathmyapp.py
File metadata and controls
52 lines (41 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import streamlit as st
import requests, json
import math
endpoint = st.sidebar.selectbox("Endpoints", ["Assets","Events","Rarity"])
st.header(f"OpenSea NFT Explorer - {endpoint}")
st.sidebar.subheader("Filters")
collection = st.sidebar.text_input("Collection")
token_id = st.sidebar.text_input("Token ID")
owner = st.sidebar.text_input("Owner")
if endpoint == "Assets":
params = {}
if collection != "":
params["collection"] = collection
if token_id != "":
params["token_ids"] = [token_id]
if owner != "":
params["owner"] = owner
r = requests.get("https://api.opensea.io/api/v1/assets", params=params)
response = r.json()
if "assets" not in response:
st.write("No assets found")
else:
for asset in response["assets"]:
st.write(f"{asset['name']} (#{asset['token_id']})")
if asset["sell_orders"] is not None:
sell_order = asset["sell_orders"][0]
if sell_order["side"] == 1:
currency_sym = sell_order["payment_token_contract"]["symbol"]
currency_decimals = sell_order["payment_token_contract"]["decimals"]
price = float(sell_order["current_price"]) / math.pow(10, currency_decimals)
st.write(f"Buy Now: {price} {currency_sym}")
if asset["image_url"] != "":
st.image(asset["image_url"])
if asset["token_id"] == token_id:
st.write(asset)
hide_menu_style = """
<style>
#MainMenu {visibility: hidden;}
</style>
"""
st.markdown(hide_menu_style, unsafe_allow_html=True)