REST API + WebSocket for the Lunex DEX. Base URL:
/api/v1
Authentication: Most write operations require an sr25519 wallet signature. Admin operations require Authorization: Bearer <ADMIN_SECRET>. AI Agent operations require X-API-Key: <agent-key>.
- Pairs
- Orders
- Trades
- Orderbook
- Candles
- Smart Router
- Social
- Copy Trade
- Margin
- Affiliate
- AI Agents
- Asymmetric Orders
- Token Listing
- Governance
- WebSocket Channels
- Error Responses
List all active trading pairs.
Response 200:
{
"pairs": [
{
"symbol": "LUNES/LUSDT",
"baseToken": "WLUNES",
"quoteToken": "LUSDT",
"pairAddress": "5GrwvaEF...",
"isActive": true,
"lastPrice": "0.0821",
"volume24h": "142500.00"
}
]
}Get 24h ticker for a pair.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
symbol |
string | Yes | Pair symbol (e.g. LUNES/LUSDT) |
Response 200:
{
"symbol": "LUNES/LUSDT",
"lastPrice": "0.0821",
"priceChange24h": "0.0012",
"priceChangePct24h": "1.48",
"high24h": "0.0850",
"low24h": "0.0800",
"volume24h": "142500.00",
"trades24h": 387
}Fetch all pairs from the Factory smart contract.
Headers: Authorization: Bearer <ADMIN_SECRET>
Register a new on-chain pair in the database.
Body:
{ "symbol": "TOKEN/LUSDT", "pairAddress": "5Abc..." }Sync pair data from on-chain state.
Place a new order. Requires wallet signature.
Body:
{
"pairSymbol": "LUNES/LUSDT",
"side": "BUY",
"type": "LIMIT",
"price": "0.0810",
"amount": "1000",
"timeInForce": "GTC",
"nonce": "1741612800001",
"signature": "0x...",
"makerAddress": "5GrwvaEF..."
}Response 201:
{
"order": {
"id": "ord_abc123",
"status": "OPEN",
"pairSymbol": "LUNES/LUSDT",
"side": "BUY",
"type": "LIMIT",
"price": "0.0810",
"amount": "1000",
"filledAmount": "0",
"remainingAmount": "1000",
"createdAt": "2026-03-10T11:00:00Z"
}
}Order types: LIMIT, MARKET, STOP_LIMIT, STOP_MARKET
Time in force: GTC (Good Till Cancel), FOK (Fill or Kill), IOC (Immediate or Cancel)
Cancel an open order. Requires wallet signature.
Body:
{ "makerAddress": "5GrwvaEF...", "signature": "0x..." }Response 200: Cancelled order object.
List orders for a wallet address.
Query parameters:
| Name | Type | Default | Description |
|---|---|---|---|
makerAddress |
string | required | Wallet address |
status |
string | all | OPEN, FILLED, CANCELLED, PARTIALLY_FILLED |
limit |
number | 50 | Max results (β€ 200) |
offset |
number | 0 | Pagination offset |
Recent trades for a pair.
Query: limit (default 50, max 200)
Response 200:
{
"trades": [
{
"id": "trd_xyz",
"pairSymbol": "LUNES/LUSDT",
"price": "0.0821",
"amount": "500",
"side": "BUY",
"executedAt": "2026-03-10T10:55:00Z"
}
]
}Trades for a specific wallet address.
Query: limit (default 50, max 200)
Orderbook snapshot for a pair.
Query: depth (default 25, max 200)
Response 200:
{
"bids": [["0.0810", "5000"], ["0.0800", "12000"]],
"asks": [["0.0825", "3000"], ["0.0830", "8000"]],
"spread": "0.0015",
"lastUpdated": "2026-03-10T11:00:00Z"
}OHLCV candlestick data.
Query:
| Name | Description | Default |
|---|---|---|
interval |
1m, 5m, 15m, 1h, 4h, 1d |
1h |
limit |
Number of candles | 100 |
from |
Unix timestamp (seconds) | β |
to |
Unix timestamp (seconds) | β |
Simulate the best execution route. Public β no auth required.
Query:
| Name | Type | Required | Description |
|---|---|---|---|
pairSymbol |
string | Yes | Pair to trade |
side |
string | Yes | BUY or SELL |
amountIn |
number | Yes | Input amount |
Response 200:
{
"bestSource": "ORDERBOOK",
"routes": [
{ "source": "ORDERBOOK", "amountOut": "241.5", "priceImpact": "0.12", "isViable": true },
{ "source": "AMM", "amountOut": "239.1", "priceImpact": "0.82", "isViable": true },
{ "source": "ASYMMETRIC", "amountOut": null, "isViable": false }
]
}Execute a swap via Smart Router V2. Requires X-API-Key with TRADE_SPOT permission.
Body:
{
"pairSymbol": "LUNES/LUSDT",
"side": "BUY",
"amountIn": 1000,
"maxSlippageBps": 100
}Platform-wide statistics.
Response 200:
{
"totalAum": 4250000,
"activeTraders": 142,
"aiAgents": 23,
"totalFollowers": 8830,
"totalIdeas": 412,
"totalVaultEquity": 1250000
}List all copy-trade leaders.
Query:
| Name | Type | Default | Description |
|---|---|---|---|
tab |
string | all |
all, traders, bots |
sortBy |
string | roi30d |
roi30d, followers, winRate |
search |
string | β | Search by name/username/bio |
limit |
number | 50 | Max results |
Get a leader's full profile, trade history, and ideas.
Top 10 leaders by Sharpe ratio.
Upsert (create or update) a leader profile.
Body:
{
"address": "5GrwvaEF...",
"name": "LunesWhale",
"username": "luneswhale",
"bio": "DeFi since 2020",
"fee": 10,
"twitterUrl": "https://x.com/luneswhale",
"signature": "0x...",
"nonce": "1741612800001"
}Follow a leader.
Unfollow a leader.
Like a trade idea.
Unlike a trade idea.
Post a comment on a trade idea.
Deposit into a copy vault.
Withdraw shares from a copy vault.
List all copy vaults.
Get a follower's positions across all vaults.
Activity history (deposits, withdrawals, PnL).
Get a signature challenge for generating a leader API key.
Create a leader API key (used to submit trading signals).
Submit a copy-trade signal for followers to mirror.
Active leveraged positions for a wallet.
Open a leveraged position.
Body:
{
"pairSymbol": "LUNES/LUSDT",
"side": "LONG",
"leverage": 5,
"collateral": "200",
"collateralToken": "LUSDT",
"makerAddress": "5GrwvaEF...",
"signature": "0x...",
"nonce": "1741612800001"
}Add collateral to an existing position.
Withdraw collateral from a position.
Close a leveraged position.
Get or generate a referral code for a wallet address.
Response 200:
{ "referralCode": "A1B2C3D4", "address": "5GrwvaEF..." }Register a referral (link referee to referrer's code).
Body:
{ "refereeAddress": "5FHne...", "referralCode": "A1B2C3D4" }Affiliate earnings dashboard.
Response 200:
{
"referralCode": "A1B2C3D4",
"directReferrals": 12,
"totalUnpaid": 142.5,
"totalPaid": 890.25,
"earningsByLevel": [
{ "level": 1, "token": "LUSDT", "totalEarned": 850, "tradeCount": 432 }
],
"levels": [
{ "level": 1, "ratePct": 4, "rateBps": 400 }
]
}Referral tree (downstream referees, up to 3 levels deep).
Payout history for a wallet.
Trigger the weekly payout batch job.
Register an AI trading agent.
Body:
{
"walletAddress": "5GrwvaEF...",
"agentType": "BOT",
"framework": "custom",
"strategyDescription": "Grid trading on LUNES/LUSDT"
}Response 201: Agent object with ID and staking tier.
Generate an API key for an agent (max 5 active keys).
Body:
{
"walletAddress": "5GrwvaEF...",
"label": "production-key",
"permissions": ["TRADE_SPOT", "READ"],
"expiresInDays": 90
}Response 201: { "key": "lnx_<64 chars>" } β shown once only.
Revoke an API key.
Get agent profile, staking tier, and trading limits.
Top agents by total volume.
Record a stake event for an agent (increases trading limits).
| Tier | Min Stake (LUNES) | Daily Trade Limit | Max Position |
|---|---|---|---|
| 0 | 0 | 10 | 100 |
| 1 | 100 | 100 | 1,000 |
| 2 | 1,000 | 500 | 10,000 |
| 3 | 10,000 | 2,000 | 100,000 |
Paginated list of token listings.
Query: tier (BASIC/VERIFIED/FEATURED), status, limit, offset
Get a listing by ID.
Get a listing by token contract address.
All listings by an owner wallet.
Create a new token listing (pending on-chain confirmation).
Body:
{
"ownerAddress": "5GrwvaEF...",
"tokenAddress": "5XYZ...",
"tokenName": "My Token",
"tokenSymbol": "MTK",
"tier": "BASIC",
"lpTokenAddress": "5LP...",
"lpAmount": "10000",
"lunesLiquidity": "5000",
"tokenLiquidity": "1000000"
}Activate a listing after on-chain confirmation.
Reject a listing.
Withdraw a liquidity lock (after lock period expires).
Check if a wallet can vote on a proposal.
Body:
{ "walletAddress": "5GrwvaEF...", "proposalId": 1 }Response 200:
{
"canVote": false,
"lastVotedAt": "2026-03-10T10:00:00Z",
"timeUntilNextVote": 2847
}Record an on-chain vote.
Body:
{
"walletAddress": "5GrwvaEF...",
"proposalId": 42,
"voteType": "YES",
"txHash": "0x..."
}Cooldown: 1 hour between votes per wallet+proposal pair.
Vote history for a wallet.
Connect to ws://localhost:4001.
Subscribe:
{ "type": "subscribe", "channel": "orderbook:LUNES/LUSDT" }Unsubscribe:
{ "type": "unsubscribe", "channel": "orderbook:LUNES/LUSDT" }| Channel | Payload | Description |
|---|---|---|
orderbook:<symbol> |
Full orderbook snapshot | Live order book |
trades:<symbol> |
Trade object | New trade executed |
ticker:<symbol> |
Ticker object | 24h price stats |
user:<address> |
Order/trade event | Personal notifications |
All errors follow this format:
{
"error": "Human-readable message",
"code": "MACHINE_READABLE_CODE",
"details": [ ... ]
}Common status codes:
| Code | Meaning |
|---|---|
| 400 | Bad request / validation failed |
| 401 | Invalid or missing signature/token |
| 403 | Valid auth but insufficient permissions |
| 404 | Resource not found |
| 409 | Conflict (duplicate resource) |
| 422 | Valid syntax, invalid business logic |
| 429 | Rate limit exceeded / vote cooldown |
| 500 | Internal server error |
| 503 | Service unavailable (node disconnected, config missing) |
| Method | Where Used | Format |
|---|---|---|
| sr25519 Signature | Order create/cancel, social writes, margin, copy trade | signature field in body |
| Admin Bearer Token | Pair register, listing activate/reject, payouts | Authorization: Bearer <secret> |
| Agent API Key | Smart Router swap, trade execution | X-API-Key: lnx_<key> |
| Leader API Key | Copy trade signal submission | X-Leader-Key: <key> |