- 👋 Hi, I’m @MarcelF807
- 👀 I’m interested in ...
- 🌱 I’m currently learning ...
- 💞️ I’m looking to collaborate on ...
- 📫 How to reach me ...
- 😄 Pronouns: ...
- ⚡ Fun fact: ...
import requests import csv from datetime import datetime
API_KEY = "HIER_DEIN_API_KEY" API_SECRET = "HIER_DEIN_API_SECRET"
url = "https://api.coinbase.com/v2/accounts"
headers = { "Authorization": f"Bearer {API_KEY}", "CB-VERSION": "2021-08-01" }
csv_file = "coinbase_report.csv" headers_csv = ["Zeitstempel", "Währung", "Balance"]
with open(csv_file, mode="w", newline="", encoding="utf-8") as file: writer = csv.writer(file) writer.writerow(headers_csv)
try: r = requests.get(url, headers=headers, timeout=10) data = r.json()
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
for account in data["data"]:
currency = account["currency"]["code"]
balance = account["balance"]["amount"]
# Nur speichern, wenn Guthaben vorhanden
if float(balance) > 0:
with open(csv_file, mode="a", newline="", encoding="utf-8") as file:
writer = csv.writer(file)
writer.writerow([timestamp, currency, balance])
print(f"\n✅ Coinbase-Bericht gespeichert in: {csv_file}")
except Exception as e:
print(f"\n