Skip to main content

subAccounts

Get sub-account information for a user, including linked accounts, permissions, and relationship details.

When to Use This Endpoint#

The subAccounts endpoint is essential for:

  • Account Management — View all sub-accounts linked to a main account
  • Permission Tracking — Monitor sub-account permissions and access levels
  • Portfolio Organization — Organize trading strategies across multiple accounts
  • Access Control — Manage delegation and trading permissions

Request#

Endpoint#

POST https://api-hyperliquid-mainnet-info.n.dwellir.com/info

Headers#

HeaderValueRequired
Content-Typeapplication/jsonYes
X-Api-KeyYour API keyYes

Parameters#

ParameterTypeRequiredDescription
typestringYesMust be "subAccounts"
userstringYesUser's Ethereum wallet address

Example Request#

{
"type": "subAccounts",
"user": "0x63E8c7C149556D5f34F833419A287bb9Ef81487f"
}

Response#

Success Response#

Returns sub-account information for the specified user.

{
"subAccounts": []
}

Response Fields#

FieldTypeDescription
subAccountsarrayArray of sub-account records with addresses and permissions

Code Examples#

curl -X POST 'https://api-hyperliquid-mainnet-info.n.dwellir.com/info' \
-H 'X-Api-Key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"type": "subAccounts",
"user": "0x63E8c7C149556D5f34F833419A287bb9Ef81487f"
}'

Common Use Cases#

1. List All Sub-Accounts#

Display all sub-accounts for a user:

async function listSubAccounts(userAddress) {
const data = await getSubAccounts(userAddress);

console.log('=== Sub-Accounts ===\n');
console.log(`Total sub-accounts: ${data.subAccounts.length}`);

if (data.subAccounts.length === 0) {
console.log('No sub-accounts configured');
} else {
console.log('Sub-accounts are configured');
}
}

// Usage
await listSubAccounts('0x63E8c7C149556D5f34F833419A287bb9Ef81487f');

2. Check Account Structure#

Verify account hierarchy:

async function checkAccountStructure(userAddress) {
const data = await getSubAccounts(userAddress);

return {
mainAccount: userAddress,
subAccountCount: data.subAccounts.length,
hasSubAccounts: data.subAccounts.length > 0,
timestamp: new Date().toISOString()
};
}

// Usage
const structure = await checkAccountStructure('0x63E8c7C149556D5f34F833419A287bb9Ef81487f');
console.log('Account structure:', structure);

3. Build Account Management Dashboard#

Create a dashboard for account management:

async function getAccountDashboard(userAddress) {
try {
const data = await getSubAccounts(userAddress);

return {
status: 'success',
mainAccount: userAddress,
subAccounts: data.subAccounts,
totalAccounts: 1 + data.subAccounts.length, // main + sub-accounts
lastUpdated: new Date().toISOString()
};
} catch (error) {
return {
status: 'error',
error: error.message
};
}
}

// Usage
const dashboard = await getAccountDashboard('0x63E8c7C149556D5f34F833419A287bb9Ef81487f');
console.log('Account Dashboard:', dashboard);

4. Monitor Account Changes#

Track sub-account additions or removals:

class SubAccountMonitor {
constructor(userAddress) {
this.userAddress = userAddress;
this.lastKnownCount = null;
}

async checkForChanges() {
const data = await getSubAccounts(this.userAddress);
const currentCount = data.subAccounts.length;

if (this.lastKnownCount !== null) {
const change = currentCount - this.lastKnownCount;

if (change > 0) {
console.log(`${change} sub-account(s) added`);
} else if (change < 0) {
console.log(`${Math.abs(change)} sub-account(s) removed`);
}
}

this.lastKnownCount = currentCount;

return {
currentCount: currentCount,
changed: this.lastKnownCount !== null && currentCount !== this.lastKnownCount
};
}
}

// Usage
const monitor = new SubAccountMonitor('0x63E8c7C149556D5f34F833419A287bb9Ef81487f');
await monitor.checkForChanges();

5. Validate Sub-Account Access#

Check if sub-accounts are properly configured:

async function validateSubAccountAccess(userAddress) {
const data = await getSubAccounts(userAddress);

const validation = {
isConfigured: data.subAccounts.length > 0,
accountCount: data.subAccounts.length,
status: data.subAccounts.length > 0 ? 'configured' : 'unconfigured',
recommendation: data.subAccounts.length === 0
? 'Consider setting up sub-accounts for strategy separation'
: 'Sub-accounts are active'
};

console.log('Sub-Account Validation:', validation);
return validation;
}

Error Handling#

Common Errors#

ErrorCauseSolution
401 UnauthorizedInvalid API keyVerify your API key is correct
400 Bad RequestMissing or invalid user addressEnsure valid Ethereum address format
429 Too Many RequestsRate limit exceededImplement request throttling
500 Internal Server ErrorServer issueRetry with exponential backoff

Error Response Example#

{
"error": "Missing required parameter: user",
"code": "MISSING_PARAMETER"
}

Robust Error Handling#

async function safeGetSubAccounts(userAddress, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
return await getSubAccounts(userAddress);
} catch (error) {
if (error.response?.status === 429) {
await new Promise(r => setTimeout(r, Math.pow(2, i) * 1000));
} else if (error.response?.status === 400) {
throw new Error('Invalid user address');
} else if (i === maxRetries - 1) {
throw error;
}
}
}
}

Best Practices#

  1. Validate addresses — Ensure user addresses are valid Ethereum addresses
  2. Cache data — Cache sub-account data for several minutes
  3. Handle empty states — Account for users without sub-accounts
  4. Monitor changes — Track sub-account additions/removals over time
  5. Organize strategies — Use sub-accounts to separate different trading strategies

Manage your Hyperliquid sub-accounts with Dwellir's HyperCore Info Endpoint. Get your API key →