Skip to main content
POST
/
api
/
trading
/
lighter
/
import
Import Lighter Credentials
curl --request POST \
  --url https://api.dexaggregatorbeta.xyz/api/trading/lighter/import \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "walletIdOrAddress": "0xA5BD439c4d4Fc7cA8B14A9FE77fd5C4FFd7e4996",
  "accountIndex": 0,
  "apiKeyIndex": 10,
  "apiPublicKey": "0x...",
  "apiPrivateKey": "0x..."
}
'
{
  "success": true,
  "message": "Lighter credentials imported successfully",
  "timestamp": 123
}
Import existing Lighter API credentials for a wallet. This endpoint is used when delegation or server wallet generation is not possible, allowing users to provide their own pre-generated API keys from the Lighter platform.
The imported credentials will be securely linked to the authenticated user account. Never share your API private keys.

Features

  • Credential Import: Link existing Lighter API keys to your HyperDEX account
  • Secure Storage: Credentials are encrypted and stored securely
  • Flexible Wallet Linking: Use wallet address or internal wallet ID

When to Use

Use this endpoint when:
  • You already have Lighter API credentials generated from the Lighter platform
  • Server-side wallet delegation is not available
  • You want to use your existing Lighter account with HyperDEX

Request

  • Method: POST
  • Endpoint: /api/trading/lighter/import
  • Authentication: Required (JWT Bearer token)

Headers

HeaderValueRequired
Content-Typeapplication/jsonYes
AuthorizationBearer <jwt_token>Yes

Request Body

{
  "walletIdOrAddress": "0xA5BD439c4d4Fc7cA8B14A9FE77fd5C4FFd7e4996",
  "accountIndex": 0,
  "apiKeyIndex": 10,
  "apiPublicKey": "0x...",
  "apiPrivateKey": "0x..."
}

Request Parameters

FieldTypeRequiredDescription
walletIdOrAddressstringYesThe wallet address or internal wallet ID associated with these credentials
accountIndexnumberYesThe Lighter account index (usually 0 or 1)
apiKeyIndexnumberYesThe index of the API key being imported
apiPublicKeystringYesThe public key of the API key pair
apiPrivateKeystringYesThe private key of the API key pair

Example Request

curl -X POST https://api.dexaggregatorbeta.xyz/api/trading/lighter/import \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -d '{
    "walletIdOrAddress": "0xA5BD439c4d4Fc7cA8B14A9FE77fd5C4FFd7e4996",
    "accountIndex": 0,
    "apiKeyIndex": 10,
    "apiPublicKey": "your_public_key",
    "apiPrivateKey": "your_private_key"
  }'
await axios.post('https://api.dexaggregatorbeta.xyz/api/trading/lighter/import', {
  walletIdOrAddress: '0xA5BD439c4d4Fc7cA8B14A9FE77fd5C4FFd7e4996',
  accountIndex: 0,
  apiKeyIndex: 10,
  apiPublicKey: 'your_public_key',
  apiPrivateKey: 'your_private_key'
}, {
  headers: {
    'Authorization': 'Bearer YOUR_JWT_TOKEN'
  }
});

Success Response

{
  "success": true,
  "message": "Lighter credentials imported successfully",
  "timestamp": 1733215000000
}

Response Fields

FieldTypeDescription
successbooleanOperation status
messagestringSuccess message
timestampnumberUnix timestamp in milliseconds

Error Responses

400 Bad Request - Missing Parameters

{
  "success": false,
  "error": "Missing parameters",
  "message": "walletIdOrAddress, accountIndex, apiKeyIndex, apiPublicKey, and apiPrivateKey are required",
  "timestamp": 1733215000000
}

401 Unauthorized - Missing Token

{
  "success": false,
  "error": "No authorization header provided"
}

500 Internal Server Error - Wallet Not Found

{
  "success": false,
  "error": "Internal server error",
  "message": "Wallet not found in system. Please connect wallet first.",
  "timestamp": 1733215000000
}

How to Get Lighter Credentials

  1. Visit Lighter DEX and create an account
  2. Navigate to your account settings
  3. Generate API keys from the dashboard
  4. Note down your:
    • accountIndex - Your Lighter account index
    • apiKeyIndex - The API key index
    • apiPublicKey - Your API public key
    • apiPrivateKey - Your API private key
After importing credentials, you can use the standard trading endpoints to place orders on Lighter without providing credentials as query parameters.
If you don’t have existing Lighter credentials, you can generate them directly on the Lighter platform and then import them using this endpoint.

Authorizations

Authorization
string
header
required

JWT token for authentication. Required for smart order execution.

Body

application/json
walletIdOrAddress
string
required

The wallet address or internal wallet ID associated with these credentials

Example:

"0xA5BD439c4d4Fc7cA8B14A9FE77fd5C4FFd7e4996"

accountIndex
integer
required

The Lighter account index (usually 0 or 1)

Example:

0

apiKeyIndex
integer
required

The index of the API key being imported

Example:

10

apiPublicKey
string
required

The public key of the API key pair

Example:

"0x..."

apiPrivateKey
string
required

The private key of the API key pair

Example:

"0x..."

Response

Credentials imported successfully

success
boolean
Example:

true

message
string
Example:

"Lighter credentials imported successfully"

timestamp
integer

Unix timestamp in milliseconds