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#
| Header | Value | Required |
|---|---|---|
Content-Type | application/json | Yes |
X-Api-Key | Your API key | Yes |
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
type | string | Yes | Must be "webData2" |
user | string | Yes | User'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#
| Field | Type | Description |
|---|---|---|
data | object | Comprehensive web interface data including account state, positions, orders, and other UI-relevant information |
Code Examples#
- cURL
- JavaScript
- Python
- Go
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"
}'
const ENDPOINT = 'https://api-hyperliquid-mainnet-info.n.dwellir.com/info';
const API_KEY = 'your-api-key-here';
async function getWebData2(userAddress) {
const response = await fetch(ENDPOINT, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Api-Key': API_KEY
},
body: JSON.stringify({
type: 'webData2',
user: userAddress
})
});
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
}
return await response.json();
}
// Usage
const webData = await getWebData2('0x63E8c7C149556D5f34F833419A287bb9Ef81487f');
console.log('Web data loaded successfully');
import requests
from typing import Dict
ENDPOINT = 'https://api-hyperliquid-mainnet-info.n.dwellir.com/info'
API_KEY = 'your-api-key-here'
def get_web_data_2(user_address: str) -> Dict:
"""Get comprehensive web interface data"""
response = requests.post(
ENDPOINT,
json={
'type': 'webData2',
'user': user_address
},
headers={
'Content-Type': 'application/json',
'X-Api-Key': API_KEY
},
timeout=10
)
response.raise_for_status()
return response.json()
# Usage
web_data = get_web_data_2('0x63E8c7C149556D5f34F833419A287bb9Ef81487f')
print("Web data loaded successfully")
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
const (
Endpoint = "https://api-hyperliquid-mainnet-info.n.dwellir.com/info"
APIKey = "your-api-key-here"
)
type WebData2Request struct {
Type string `json:"type"`
User string `json:"user"`
}
type WebData2Response struct {
Data map[string]interface{} `json:"data"`
}
func getWebData2(userAddress string) (*WebData2Response, error) {
reqBody, _ := json.Marshal(WebData2Request{
Type: "webData2",
User: userAddress,
})
req, _ := http.NewRequest("POST", Endpoint, bytes.NewBuffer(reqBody))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-Api-Key", APIKey)
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
var result WebData2Response
if err := json.Unmarshal(body, &result); err != nil {
return nil, err
}
return &result, nil
}
func main() {
webData, err := getWebData2("0x63E8c7C149556D5f34F833419A287bb9Ef81487f")
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Println("Web data loaded successfully")
}
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#
| Error | Cause | Solution |
|---|---|---|
401 Unauthorized | Invalid API key | Verify your API key is correct |
400 Bad Request | Missing or invalid user address | Ensure valid Ethereum address format |
429 Too Many Requests | Rate limit exceeded | Implement request throttling |
500 Internal Server Error | Server issue | Retry 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#
- Cache appropriately — Cache data for 30-60 seconds to reduce API calls
- Handle loading states — Show loading indicators during data fetch
- Validate addresses — Ensure user addresses are valid before requests
- Refresh periodically — Update dashboard data every 30-60 seconds
- 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 };
}
}
Related Endpoints#
- clearinghouseState — Get detailed account state
- openOrders — Get open orders separately
- userFees — Get fee information
- spotClearinghouseState — Get spot balances
Build powerful web interfaces with comprehensive data from Dwellir's HyperCore Info Endpoint. Get your API key →