curl --request GET \
--url https://api.example.com/{EP_NET_WORTH}{
"data": {
"assets": {
"clientId": "<string>",
"assets": [
{
"currency": {
"id": "<string>",
"name": "<string>",
"decimals": 123,
"allowTransfers": true,
"disabled": true,
"priority": 123
},
"quoteCurrency": {},
"available": "<string>",
"locked": "<string>",
"total": "<string>",
"staking": {
"initial": "<string>",
"accrued": "<string>"
},
"estPrice": "<string>",
"estValue": "<string>"
}
],
"estTotalValue": "<string>"
},
"liabilities": {
"liabilities": [
{
"currency": {},
"quoteCurrency": {},
"amount": "<string>",
"debt": "<string>",
"interest": "<string>",
"estPrice": "<string>",
"estValue": "<string>",
"estInterestValue": "<string>"
}
],
"estTotalValue": "<string>",
"estTotalInterestValue": "<string>"
},
"estTotalValue": "<string>"
},
"status": 123
}Retrieve comprehensive net worth data including assets, liabilities, and total portfolio value
curl --request GET \
--url https://api.example.com/{EP_NET_WORTH}{
"data": {
"assets": {
"clientId": "<string>",
"assets": [
{
"currency": {
"id": "<string>",
"name": "<string>",
"decimals": 123,
"allowTransfers": true,
"disabled": true,
"priority": 123
},
"quoteCurrency": {},
"available": "<string>",
"locked": "<string>",
"total": "<string>",
"staking": {
"initial": "<string>",
"accrued": "<string>"
},
"estPrice": "<string>",
"estValue": "<string>"
}
],
"estTotalValue": "<string>"
},
"liabilities": {
"liabilities": [
{
"currency": {},
"quoteCurrency": {},
"amount": "<string>",
"debt": "<string>",
"interest": "<string>",
"estPrice": "<string>",
"estValue": "<string>",
"estInterestValue": "<string>"
}
],
"estTotalValue": "<string>",
"estTotalInterestValue": "<string>"
},
"estTotalValue": "<string>"
},
"status": 123
}pollIntervalMs parameterpollIntervalMs > 0Show Net Worth Data
Show Assets
"79f970d7-3b2f-492c-a358-6c1f1c2fd429"Show Asset Object
Show Currency
"BTC", "ETH")"Bitcoin", "Ethereum")"0.0083506""0.00016514""0.00851574""94040.55""800.82""1350.89"Show Liabilities
Show Liability Object
"32.48""32.48""0.36""32.48""0.36""32.48""0.36""1318.41"200{
"data": {
"assets": {
"clientId": "79f970d7-3b2f-492c-a358-6c1f1c2fd429",
"assets": [
{
"currency": {
"id": "BTC",
"name": "Bitcoin",
"decimals": 8,
"allowTransfers": true,
"disabled": false,
"priority": 3
},
"quoteCurrency": {
"id": "USDT",
"name": "Tether",
"decimals": 2,
"allowTransfers": true,
"disabled": false,
"priority": 3
},
"available": "0.0083506",
"locked": "0.00016514",
"total": "0.00851574",
"staking": {
"initial": "0",
"accrued": "0"
},
"estPrice": "94040.55",
"estValue": "800.82"
},
{
"currency": {
"id": "ETH",
"name": "Ethereum",
"decimals": 8,
"allowTransfers": true,
"disabled": false,
"priority": 2
},
"quoteCurrency": {
"id": "USDT",
"name": "Tether",
"decimals": 2,
"allowTransfers": true,
"disabled": false,
"priority": 3
},
"available": "0.04256646",
"locked": "0.04683954",
"total": "0.089406",
"staking": {
"initial": "0",
"accrued": "0"
},
"estPrice": "3202.515",
"estValue": "286.32"
},
{
"currency": {
"id": "USDT",
"name": "Tether",
"decimals": 2,
"allowTransfers": true,
"disabled": false,
"priority": 3
},
"quoteCurrency": {
"id": "USDT",
"name": "Tether",
"decimals": 2,
"allowTransfers": true,
"disabled": false,
"priority": 3
},
"available": "34.49",
"locked": "34.54",
"total": "69.03",
"staking": {
"initial": "33.3",
"accrued": "0.24"
},
"estPrice": "1",
"estValue": "69.03"
}
],
"estTotalValue": "1350.89"
},
"liabilities": {
"liabilities": [
{
"currency": {
"id": "USDT",
"name": "Tether",
"decimals": 2,
"allowTransfers": true,
"disabled": false,
"priority": 3
},
"quoteCurrency": {
"id": "USDT",
"name": "Tether",
"decimals": 2,
"allowTransfers": true,
"disabled": false,
"priority": 3
},
"amount": "32.48",
"debt": "32.48",
"interest": "0.36",
"estPrice": "1",
"estValue": "32.48",
"estInterestValue": "0.36"
}
],
"estTotalValue": "32.48",
"estTotalInterestValue": "0.36"
},
"estTotalValue": "1318.41"
},
"status": 200
}
import { z } from "zod";
export const CurrencySchema = z.object({
id: z.string(),
name: z.string(),
decimals: z.number(),
allowTransfers: z.boolean(),
disabled: z.boolean(),
priority: z.number(),
});
export const StakingSchema = z.object({
initial: z.string(),
accrued: z.string(),
});
export const AssetSchema = z.object({
currency: CurrencySchema,
quoteCurrency: CurrencySchema,
available: z.string(),
locked: z.string(),
total: z.string(),
staking: StakingSchema,
estPrice: z.string(),
estValue: z.string(),
});
export type Asset = z.infer<typeof AssetSchema>;
export const LiabilitySchema = z.object({
currency: CurrencySchema,
quoteCurrency: CurrencySchema,
amount: z.string(),
debt: z.string(),
interest: z.string(),
estPrice: z.string(),
estValue: z.string(),
estInterestValue: z.string(),
});
export type Liability = z.infer<typeof LiabilitySchema>;
export const NetWorthDataSchema = z.object({
assets: z.object({
clientId: z.string(),
assets: z.array(AssetSchema),
estTotalValue: z.string(),
}),
liabilities: z.object({
liabilities: z.array(LiabilitySchema),
estTotalValue: z.string(),
estTotalInterestValue: z.string(),
}),
estTotalValue: z.string(),
});
export type NetWorthData = z.infer<typeof NetWorthDataSchema>;
export const netWorthDataResponseSchema = z.object({
data: NetWorthDataSchema,
status: z.number(),
});
export type NetWorthDataResponse = z.infer<typeof netWorthDataResponseSchema>;
import { useNetWorth } from '@/services/hooks/use-net-worth';
function PortfolioComponent() {
const userId = "user-123";
const pollInterval = 30000; // Poll every 30 seconds
const { data: netWorthData, isLoading, error } = useNetWorth(
userId,
pollInterval
);
if (isLoading) return <div>Loading...</div>;
if (error) return <div>Error loading portfolio</div>;
return (
<div>
<h1>Net Worth: ${netWorthData?.estTotalValue}</h1>
<h2>Total Assets: ${netWorthData?.assets.estTotalValue}</h2>
<h2>Total Liabilities: ${netWorthData?.liabilities.estTotalValue}</h2>
</div>
);
}