v5

latestOpenAPI 3.1.0raw.githubusercontent.com2026-08-032714.3 KB
Swap

Create Swap Instructions

Returns Solana swap instructions for a given token pair and amount.

post/swap-instructions

Headers

0x-api-keystring required

Visit dashboard.0x.org to get your API Key

Request body

amount_ininteger required

Input amount in its base units.

disabled_sourcesstring[]

DEX sources to exclude from routing. Valid source names are returned by /enabled-sources.

recipientstring

Base-58 encoded recipient for swap output. If output token is native SOL this must be the address of the recipient, else a valid token account for that output token mint.

reserve_transaction_bytesinteger

Minimum bytes to reserve in the transaction for composing with additional instructions.

slippage_bpsinteger

Slippage tolerance in basis points.

swap_fee_ppmstring

Comma-separated volume-based swap fees in parts per million. Must be provided together with swap_fee_recipient. Each entry must be between 0 and the per-app maximum (100_000 unless configured otherwise). A value of 0 disables that fee entry. Multiple fees on the same side are applied sequentially, each on the amount remaining after prior deductions — not the original amount. Fee amounts are rounded up to the nearest base unit.

swap_fee_recipientstring

Comma-separated base-58 encoded recipients for the swap fees. Must be provided together with swap_fee_ppm. The number of entries must match swap_fee_ppm. If the respective token for swap_fee_side is native SOL this must be an address, else a valid token account for that token mint.

swap_fee_sidestring

Comma-separated fee sides for each fee entry. Supported values are buy and sell. This field may be omitted only when every fee uses the default buy side. When provided, the number of entries must match swap_fee_ppm.

takerstring required

Base-58 encoded taker wallet address.

token_instring required

Input token mint, base-58 encoded. Use So11111111111111111111111111111111111111111 for native SOL.

token_outstring required

Output token mint, base-58 encoded. Use So11111111111111111111111111111111111111111 for native SOL.

trade_surplus_cap_ppminteger

Trade surplus cap in parts per million of the total realized trade size. Must be provided together with trade_surplus_recipient, or both fields must be omitted. A value of 0 disables trade surplus collection for the request. When 0x controls trade surplus collection, the request value is ignored and the configured 0x policy is applied instead. The transferred amount is capped relative to trade size.

trade_surplus_recipientstring

Base-58 encoded recipient that should receive trade surplus. Must be provided together with trade_surplus_cap_ppm, or both fields must be omitted. If the output token is native SOL this must be an address, else a valid token account for that token mint. When 0x controls trade surplus collection, the request value is ignored and the configured 0x recipient is used instead.

Example request

{
  "amount_in": 1000000000,
  "slippage_bps": 50,
  "taker": "ZeroEx1111111111111111111111111111111111111",
  "token_in": "So11111111111111111111111111111111111111112",
  "token_out": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
}

Response

Swap instructions

address_lookup_tablesstring[] required

Address Lookup Table addresses that must be included in the versioned transaction.

amount_outinteger required

The estimated output amount after fees, in its base units.

min_amount_outinteger required

The minimum output amount after slippage and fees, in its base units. Transaction will fail if this amount is not met.

zidstring required

Unique 12-byte hex identifier for this request.