-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch_data.py
More file actions
37 lines (28 loc) · 1.04 KB
/
fetch_data.py
File metadata and controls
37 lines (28 loc) · 1.04 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
import requests
import pandas as pd
from config import DEBANK_API_URL, DEBANK_API_KEY
def fetch_wallet_data(csv_file):
df = pd.read_csv(csv_file)
wallet_data = []
for idx, row in df.iterrows():
wallet_id = row['wallet_id']
print(f"🔍 Fetching data for wallet {wallet_id}...")
try:
response = requests.get(
DEBANK_API_URL,
params={"id": wallet_id},
headers={"AccessKey": DEBANK_API_KEY}
)
response.raise_for_status()
data = response.json()
total_usd = data.get("total_usd_value", 0)
chains = data.get("chain_list", [])
active_chains = len(chains)
wallet_data.append({
"wallet_id": wallet_id,
"total_usd_value": total_usd,
"active_chains": active_chains,
})
except Exception as e:
print(f"❌ Error fetching data for {wallet_id}: {e}")
return wallet_data