Skip to main content
POST
/
api
/
trading
/
{exchange}
/
apikey
curl --request POST \ --url https://api.dexaggregatorbeta.xyz/api/trading/{exchange}/apikey \ --header 'Content-Type: application/json' \ --header 'X-API-KEY: <api-key>' \ --data ' { "walletIdOrAddress": "user_123" } '
{
  "success": true,
  "message": "API key generated successfully",
  "data": {
    "signerAddress": "<string>",
    "createdAt": "2023-11-07T05:31:56Z"
  },
  "timestamp": 123
}
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

ExchangeEndpointNotes
AsterPOST /api/trading/aster/apikeyGenerates API key and secret
HyperliquidPOST /api/trading/hyperliquid/apikeyCreates API wallet with expiry
LighterN/AUse 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

FieldTypeRequiredDescription
walletIdOrAddressstringYesCan 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

  1. Server retrieves the wallet using the provided identifier
  2. Server signs a message using the wallet’s MPC key shares
  3. Aster verifies the signature to authenticate the wallet
  4. Aster returns API key and secret
  5. 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

FieldTypeDescription
successbooleanOperation status
messagestringSuccess message
data.signerAddressstringWallet address registered with Aster
data.createdAtstringISO timestamp of registration
timestampnumberUnix 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

FieldTypeRequiredDescription
walletIdOrAddressstringYesCan 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

  1. Server creates a new API wallet for Hyperliquid
  2. Server signs an agent approval message
  3. Hyperliquid verifies and approves the API wallet
  4. API wallet credentials are encrypted and stored

Success Response

{
  "success": true,
  "data": {
    "apiWalletAddress": "0x1A31d05B2B58d559D578E13E0Fb77cB197D36A08",
    "apiPrivateKey": "0x0e6b33d1867274a297f977f0d82f186b0fb053ad80fbc60969decd9908140a0a",
    "mainWalletAddress": "0x90EA34C09B612AC68E696BdC7be0ED037a086E72",
    "expiryTimestamp": 1780240026028
  },
  "timestamp": 1764688027666
}

Response Fields

FieldTypeDescription
successbooleanOperation status
data.apiWalletAddressstringGenerated API wallet address
data.apiPrivateKeystringAPI wallet private key (encrypted in storage)
data.mainWalletAddressstringMain server wallet address
data.expiryTimestampnumberAPI key expiration timestamp (Unix ms)
timestampnumberUnix 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

  1. Create Account: Visit Lighter DEX and create an account
  2. Deposit Funds: Deposit USDC directly on the Lighter platform
  3. Generate API Keys: Navigate to your account settings and generate API keys
  4. 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.

Authorizations

X-API-KEY
string
header
required

Path Parameters

exchange
enum<string>
required

Exchange adapter name (aster or hyperliquid). Note: Lighter requires direct platform registration.

Available options:
hyperliquid,
aster

Body

application/json
walletIdOrAddress
string
required

Can be userId, walletId (UUID), or wallet address (0x...)

Response

API key generated successfully

success
boolean
message
string
Example:

"API key generated successfully"

data
object
timestamp
integer