For the complete documentation index, see llms.txt. This page is also available as Markdown.

API Reference

Programmatic interface for perpetual contract trading on the AFX DEX.

AFX DEX uses wallet-signed requests and on-chain settlement for perpetual trading. No API keys required -- all Exchange API requests are authenticated via EIP-712 signatures from Ethereum wallets.

Quick Start — First Trade in 5 Minutes

Base URLs

Environment
Exchange API
Info API
WebSocket

Mainnet

https://api.afx.xyz/api/v1/exchange

https://api.afx.xyz/info/...

wss://ws.afx.xyz/ws/dex

Testnet

https://api-testnet.afx.xyz/api/v1/exchange

https://api-testnet.afx.xyz/info/...

wss://ws-testnet.afx.xyz/ws/dex

Start with the Testnet environment. Use faucetClaim to get free test funds.

Funding Limits

On mainnet, the minimum deposit is 10 USDC and the minimum withdrawal is 2 USDC.

API Categories

Authentication

Master Wallet

Controls funds and permissions.

Signs: approveAgent, withdraw

Domain: SignTransaction

Agent Wallet

Authorized by Master for daily trading.

Signs: placeOrder, replaceOrder, placeBracketOrder, cancelOrder, setLeverage, setMarginMode, and other authorized trading operations.

Domain: Exchange

See Authentication for the full EIP-712 signing specification.

Permission Boundary

Operation family
Signature
Notes

Trading actions such as placeOrder, replaceOrder, cancelOrder, setLeverage, and setMarginMode

Agent wallet

Intended for day-to-day trading automation. These actions can change market risk but cannot withdraw account funds to an external address.

approveAgent, revokeAgent, account withdraw, and testnet faucetClaim

Master wallet

Privileged operations. Keep the Master wallet separate from automated trading infrastructure.

Vault operations

Agent wallet in a vault context

Vault actions can affect vault balances, ownership, withdrawal flow, or closure. Do not assume a vault-authorized Agent is trading-only. Review each vault operation before granting automated access.

See Agent Safety for key handling, revocation, rotation, and vault-operation guidance.

Common Response Format

Error Codes
Code
Description

0

Success

40201

Unsupported action type

40204

Signature verification failed

40207

Invalid nonce

40208

Request expired

40220

Rate limit exceeded

40230

Blockchain call failed

40231

Transaction broadcast failed

40006

Location is not supported

40280

Action disabled (emergency)

40281

Address banned

Available Symbols

Query GET /info/public/product-meta for the canonical product list. Do not hardcode symbol codes or max leverage from examples, because listed markets and risk parameters can change.

Important fields returned by product-meta:

Field
Description

code

Numeric product code used by Exchange API requests.

symbol

Product symbol, such as BTCUSDC.

maxLeverage

Current maximum leverage for the product.

pricePrecision, qtyPrecision

Display and input precision.

tickSize, stepSize

Minimum price and quantity increments.

minOrderValue

Minimum order notional.

maxSlippagePct

Maximum allowed market-order slippage ratio.

Rate Limits

Dimension
Limit

Per address per action

Configurable per action type

WebSocket connections per IP

10

WebSocket subscriptions per connection

50

WebSocket messages per second

50

Last updated