Skip to main content

webData2

Get comprehensive web interface data for a user in a single request, optimized for dashboard and UI rendering.

When to Use This Endpoint#

The webData2 endpoint is essential for:

  • Dashboard Building — Get all necessary data for user dashboards
  • Web Interface — Populate web UI with complete user data
  • Performance Optimization — Reduce multiple API calls to one request
  • Full State Access — Access comprehensive user state efficiently

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 "webData2"
userstringYesUser's Ethereum wallet address

Example Request#

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

Response#

Success Response#

Returns comprehensive web interface data for the specified user.

{
"data": {}
}

Response Fields#

FieldTypeDescription
dataobjectComprehensive web interface data including account state, positions, orders, and other UI-relevant information

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": "webData2",
"user": "0x63E8c7C149556D5f34F833419A287bb9Ef81487f"
}'

Common Use Cases#

1. Load Complete Dashboard#

Load all data needed for a user dashboard:

async function loadUserDashboard(userAddress) {
const webData = await getWebData2(userAddress);

console.log('=== User Dashboard ===\n');
console.log('Dashboard data loaded successfully');
console.log('Ready to render UI');

return webData.data;
}

// Usage
const dashboardData = await loadUserDashboard('0x63E8c7C149556D5f34F833419A287bb9Ef81487f');

2. Initialize Web Interface#

Bootstrap a web application with user data:

class WebInterface {
constructor(userAddress) {
this.userAddress = userAddress;
this.data = null;
}

async initialize() {
console.log('Initializing web interface...');
this.data = await getWebData2(this.userAddress);
console.log('Interface ready');
return this.data;
}

getData() {
return this.data;
}

async refresh() {
console.log('Refreshing data...');
this.data = await getWebData2(this.userAddress);
return this.data;
}
}

// Usage
const interface = new WebInterface('0x63E8c7C149556D5f34F833419A287bb9Ef81487f');
await interface.initialize();

3. Periodic Data Refresh#

Refresh dashboard data at intervals:

class DashboardDataManager {
constructor(userAddress, refreshIntervalMs = 30000) {
this.userAddress = userAddress;
this.refreshIntervalMs = refreshIntervalMs;
this.currentData = null;
this.onUpdate = null;
}

async start(updateCallback) {
this.onUpdate = updateCallback;

// Initial load
await this.refresh();

// Periodic refresh
setInterval(() => this.refresh(), this.refreshIntervalMs);
}

async refresh() {
try {
this.currentData = await getWebData2(this.userAddress);

if (this.onUpdate) {
this.onUpdate(this.currentData);
}

return this.currentData;
} catch (error) {
console.error('Failed to refresh data:', error);
}
}

getCurrentData() {
return this.currentData;
}
}

// Usage
const manager = new DashboardDataManager('0x63E8c7C149556D5f34F833419A287bb9Ef81487f');
manager.start((data) => {
console.log('Dashboard data updated');
// Update UI with new data
});

4. Build Trading Interface#

Create a complete trading interface:

async function buildTradingInterface(userAddress) {
try {
const webData = await getWebData2(userAddress);

return {
status: 'success',
data: webData.data,
isReady: true,
lastUpdated: new Date().toISOString()
};
} catch (error) {
return {
status: 'error',
error: error.message,
isReady: false
};
}
}

// Usage
const tradingInterface = await buildTradingInterface('0x63E8c7C149556D5f34F833419A287bb9Ef81487f');

if (tradingInterface.isReady) {
console.log('Trading interface ready');
} else {
console.error('Failed to load interface:', tradingInterface.error);
}

5. Cache-Optimized Data Loading#

Implement efficient caching for web data:

class CachedWebDataLoader {
constructor(userAddress, cacheDurationMs = 60000) {
this.userAddress = userAddress;
this.cacheDurationMs = cacheDurationMs;
this.cache = null;
this.cacheTime = 0;
}

async load(forceRefresh = false) {
const now = Date.now();
const cacheAge = now - this.cacheTime;

if (!forceRefresh && this.cache && cacheAge < this.cacheDurationMs) {
console.log(`Using cached data (age: ${Math.round(cacheAge / 1000)}s)`);
return this.cache;
}

console.log('Loading fresh data...');
const data = await getWebData2(this.userAddress);

this.cache = data;
this.cacheTime = now;

return data;
}

invalidateCache() {
this.cache = null;
this.cacheTime = 0;
}
}

// Usage
const loader = new CachedWebDataLoader('0x63E8c7C149556D5f34F833419A287bb9Ef81487f');
const data = await loader.load(); // Fresh load
const cachedData = await loader.load(); // From cache

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 safeGetWebData2(userAddress, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
return await getWebData2(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. Cache appropriately — Cache data for 30-60 seconds to reduce API calls
  2. Handle loading states — Show loading indicators during data fetch
  3. Validate addresses — Ensure user addresses are valid before requests
  4. Refresh periodically — Update dashboard data every 30-60 seconds
  5. Optimize rendering — Only re-render UI components when data changes

Performance Tips#

Efficient Dashboard Updates#

class EfficientDashboard {
constructor(userAddress) {
this.userAddress = userAddress;
this.lastData = null;
}

async update() {
const newData = await getWebData2(this.userAddress);

// Compare with previous data
const hasChanged = JSON.stringify(newData) !== JSON.stringify(this.lastData);

if (hasChanged) {
console.log('Data changed - updating UI');
this.lastData = newData;
return { changed: true, data: newData };
}

console.log('No changes detected');
return { changed: false, data: newData };
}
}

Build powerful web interfaces with comprehensive data from Dwellir's HyperCore Info Endpoint. Get your API key →