-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbasic_usage.py
More file actions
45 lines (35 loc) · 1.5 KB
/
basic_usage.py
File metadata and controls
45 lines (35 loc) · 1.5 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
"""Basic usage examples for the Kubera API client."""
from kubera import KuberaClient
# Initialize client (automatically loads from ~/.env)
client = KuberaClient()
# Or provide credentials explicitly
# client = KuberaClient(api_key="your_key", secret="your_secret")
# Get all portfolios
portfolios = client.get_portfolios()
print(f"Found {len(portfolios)} portfolios:")
for portfolio in portfolios:
print(f" - {portfolio['name']} ({portfolio['currency']})")
# Get detailed data for first portfolio
if portfolios:
portfolio_id = portfolios[0]["id"]
portfolio = client.get_portfolio(portfolio_id)
print(f"\nPortfolio: {portfolio['name']}")
print(f"Net Worth: {portfolio.get('net_worth', {}).get('amount', 0)} {portfolio['currency']}")
# List assets
assets = portfolio.get("assets", [])
print(f"\nAssets ({len(assets)}):")
for asset in assets[:5]: # Show first 5
value = asset.get("value", {})
print(f" - {asset['name']}: {value.get('amount', 0)} {value.get('currency', '')}")
# List debts
debts = portfolio.get("debts", [])
print(f"\nDebts ({len(debts)}):")
for debt in debts[:5]: # Show first 5
value = debt.get("value", {})
print(f" - {debt['name']}: {value.get('amount', 0)} {value.get('currency', '')}")
# Update an item (uncomment to use)
# item_id = "your_asset_or_debt_id"
# updated = client.update_item(item_id, {"value": 50000, "description": "Updated via API"})
# print(f"Updated {updated['name']}")
# Clean up
client.close()