Skip to main content
POST
/
trade
/
swap
Execute trade via aggregator (EVM + Solana)
curl --request POST \
  --url https://api.afkcrypto.com/v1/trade/swap \
  --header 'Content-Type: application/json' \
  --header 'Idempotency-Key: <idempotency-key>' \
  --header 'x-api-key: <api-key>' \
  --data '{
  "chain": "<string>",
  "from": "<string>",
  "fromToken": "<string>",
  "toToken": "<string>",
  "amount": "<string>",
  "slippage": 123,
  "includeGas": true,
  "protocols": "<string>",
  "excludeProtocols": "<string>"
}'
{ "id": "tx_...", "status": "SUBMITTED", "hash": "0x..." }
{ "id": "tx_...", "status": "SUBMITTED", "hash": "0x..." }

Authorizations

x-api-key
string
header
required

Headers

Idempotency-Key
string<uuid>
required

Provide a unique Idempotency-Key per user to ensure single submission.

Body

application/json
  • EVM
  • Solana
chain
string
required

EVM chain slug.

fromToken
string
required

Token or native address (0xEeee... for native)

toToken
string
required

Output token address (0x...).

amount
string
required

Amount in wei (decimal or 0x-hex supported for EVM).

slippage
number
required

Percentage (e.g., 1 = 1%)

from
string | null

Optional sender wallet; defaults to user's default wallet for the chain.

includeGas
boolean | null

Include gas estimates in the build (optional).

protocols
string | null

Comma-separated allowlist of protocols (optional).

excludeProtocols
string | null

Comma-separated blocklist of protocols (optional).

Response

Submission accepted

id
string
required

AFK transaction id for the submitted action.

status
enum<string>
required

Submission status.

Available options:
SUBMITTED
hash
string | null
required

On-chain transaction hash/signature (may be null at submission time).

I