Register API keys with exchanges to enable trading operations. This endpoint links your server wallet to exchange accounts and generates the necessary credentials.
Important: You must create a server wallet first using POST /api/wallets before registering API keys.
Features
- Multi-exchange support: Generate API keys for Aster and Hyperliquid
- Wallet-based registration: Link API keys to server wallets
- Secure storage: API credentials are encrypted and stored securely
- Automatic signing: Server handles message signing for authentication
Supported Exchanges
| Exchange | Endpoint | Notes |
|---|
| Aster | POST /api/trading/aster/apikey | Generates API key and secret |
| Hyperliquid | POST /api/trading/hyperliquid/apikey | Creates API wallet with expiry |
| Lighter | N/A | Use Lighter platform directly |
Lighter DEX: You do NOT register API keys through HyperDEX for Lighter. Instead, create an account on Lighter DEX, deposit funds, and generate API keys from their platform. Provide these credentials as query parameters when placing orders.
Aster API Key Registration
Register your server wallet with Aster exchange to get API credentials.
Endpoint
POST /api/trading/aster/apikey
Request Body
{
"walletIdOrAddress": "user_123"
}
Request Parameters
| Field | Type | Required | Description |
|---|
walletIdOrAddress | string | Yes | Can be userId, walletId (UUID), or wallet address (0x…) |
Example Request
curl -X POST https://api.dexaggregatorbeta.xyz/api/trading/aster/apikey \
-H "Content-Type: application/json" \
-d '{"walletIdOrAddress": "user_123"}'
await axios.post('https://api.dexaggregatorbeta.xyz/api/trading/aster/apikey', {
walletIdOrAddress: 'user_123'
});
What Happens
- Server retrieves the wallet using the provided identifier
- Server signs a message using the wallet’s MPC key shares
- Aster verifies the signature to authenticate the wallet
- Aster returns API key and secret
- API credentials are encrypted and stored in the database
Success Response
{
"success": true,
"message": "API key generated successfully",
"data": {
"signerAddress": "0x173404aAAa4d6539e2C7dbcC1931Cf41b3A3D5c7",
"createdAt": "2025-11-27T02:00:00Z"
},
"timestamp": 1762765034479
}
Response Fields
| Field | Type | Description |
|---|
success | boolean | Operation status |
message | string | Success message |
data.signerAddress | string | Wallet address registered with Aster |
data.createdAt | string | ISO timestamp of registration |
timestamp | number | Unix timestamp in milliseconds |
Hyperliquid API Key Registration
Register your server wallet with Hyperliquid exchange to create an API wallet.
Endpoint
POST /api/trading/hyperliquid/apikey
Request Body
{
"walletIdOrAddress": "user_123"
}
Request Parameters
| Field | Type | Required | Description |
|---|
walletIdOrAddress | string | Yes | Can be userId, walletId (UUID), or wallet address (0x…) |
Example Request
curl -X POST https://api.dexaggregatorbeta.xyz/api/trading/hyperliquid/apikey \
-H "Content-Type: application/json" \
-d '{"walletIdOrAddress": "user_123"}'
await axios.post('https://api.dexaggregatorbeta.xyz/api/trading/hyperliquid/apikey', {
walletIdOrAddress: 'user_123'
});
What Happens
- Server creates a new API wallet for Hyperliquid
- Server signs an agent approval message
- Hyperliquid verifies and approves the API wallet
- API wallet credentials are encrypted and stored
Success Response
{
"success": true,
"data": {
"apiWalletAddress": "0x1A31d05B2B58d559D578E13E0Fb77cB197D36A08",
"apiPrivateKey": "0x0e6b33d1867274a297f977f0d82f186b0fb053ad80fbc60969decd9908140a0a",
"mainWalletAddress": "0x90EA34C09B612AC68E696BdC7be0ED037a086E72",
"expiryTimestamp": 1780240026028
},
"timestamp": 1764688027666
}
Response Fields
| Field | Type | Description |
|---|
success | boolean | Operation status |
data.apiWalletAddress | string | Generated API wallet address |
data.apiPrivateKey | string | API wallet private key (encrypted in storage) |
data.mainWalletAddress | string | Main server wallet address |
data.expiryTimestamp | number | API key expiration timestamp (Unix ms) |
timestamp | number | Unix timestamp in milliseconds |
Lighter API Key Registration
Lighter DEX Requirement: You do NOT register API keys through HyperDEX for Lighter DEX.
How to Get Lighter API Keys
- Create Account: Visit Lighter DEX and create an account
- Deposit Funds: Deposit USDC directly on the Lighter platform
- Generate API Keys: Navigate to your account settings and generate API keys
- Note Credentials: Save your:
apiKeyPrivateKey - Your API key private key (hex format)
apiKeyIndex - API key index number
accountIndex - Your Lighter account index
Using Lighter API Keys
When placing orders on Lighter through HyperDEX, provide these credentials as query parameters:
POST /api/trading/lighter/orders?apiKeyPrivateKey=<key>&apiKeyIndex=<index>&accountIndex=<account>
See the Place Order documentation for more details.
Error Responses
400 Bad Request - Missing Parameters
{
"success": false,
"error": "Missing required parameter: walletIdOrAddress",
"timestamp": 1762765034479
}
404 Not Found - Wallet Not Found
{
"success": false,
"error": "Wallet not found",
"timestamp": 1762765034479
}
409 Conflict - Key Already Exists
{
"success": false,
"error": "API key already exists for this wallet",
"message": "Use the existing key or delete it before creating a new one",
"timestamp": 1762765034479
}
500 Internal Server Error
{
"success": false,
"error": "Failed to generate API key",
"timestamp": 1762765034479
}
Use Cases
- Initial account setup for trading on Aster and Hyperliquid
- Link server wallets to exchange accounts
- Enable automated trading through API credentials
- Secure multi-exchange trading setup
Important Notes
Security: API credentials are encrypted and stored securely in the database. Never expose API keys or private keys to clients.
Prerequisites: You must create a server wallet using POST /api/wallets before registering API keys.
Wallet Identifiers: You can use any of these identifiers for walletIdOrAddress:
userId (e.g., “user_123”)
walletId (UUID format)
address (0x… format)
Lighter Integration: For Lighter DEX, create your account and generate API keys directly on their platform. Then provide those credentials as query parameters when placing orders through HyperDEX.
Exchange adapter name (aster or hyperliquid). Note: Lighter requires direct platform registration.
Available options:
hyperliquid,
aster
Can be userId, walletId (UUID), or wallet address (0x...)
API key generated successfully
Example:"API key generated successfully"