Files
inspiration-collector/fetch_balance.py
2026-06-14 13:26:45 +08:00

12 lines
445 B
Python

import json, requests, os
BALANCE_FILE = '/var/www/nav/data/balance.json'
try:
r = requests.get('https://api.deepseek.com/user/balance',
headers={'Authorization': 'Bearer sk-bbca4a0380d549389f0d27cdea0b5228'}, timeout=10)
data = r.json()
with open(BALANCE_FILE, 'w') as f:
json.dump(data, f)
print('OK:', data.get('balance_infos', [{}])[0].get('total_balance', '?'))
except Exception as e:
print('Error:', e)