getPrice

View as Markdown
Get the indicative price for a gasless swap

Headers

0x-api-keystringRequired
Visit dashboard.0x.org to get your API Key
0x-versionstringRequired
API version

Query parameters

chainIdintegerRequired>=0
Chain ID. See [here](https://0x.org/docs/developer-resources/supported-chains) for the list of supported chains
buyTokenstringRequiredformat: "^0x(?!0{40})[a-fA-F0-9]{40}$"
The contract address of the token to buy
sellTokenstringRequiredformat: "^0x(?!0{40})[a-fA-F0-9]{40}$"
The contract address of the token to sell. Native token is not supported
sellAmountstringRequired

The amount of sellToken in sellToken base units to sell

takerstringOptionalformat: "^0x[a-fA-F0-9]{40}$"

The address which holds the sellToken balance and has the allowance set for the swap

recipientstringOptionalformat: "^0x[a-fA-F0-9]{40}$"

The address to receive the buyToken. If not provided, defaults to the taker address. Not supported for wrap/unwrap operations.

swapFeeRecipientstringOptionalformat: "^\s*0x[a-fA-F0-9]{40}(\s*,\s*0x[a-fA-F0-9]{40})*\s*$"

The wallet address to receive the specified trading fees (supports single or multiple comma-separated values). You must also specify the swapFeeBps in the request to use this feature. When multiple values are provided, must match length of swapFeeBps.

swapFeeBpsstringOptionalformat: "^\s*\d+(\s*,\s*\d+)*\s*$"

The amount in Bps of the swapFeeToken to charge and deliver to the swapFeeRecipient (supports single or multiple comma-separated values). You must also specify the swapFeeRecipient in the request to use this feature. For security, this field has a default limit of 1000 Bps. If your application requires a higher value, please reach out to us.

swapFeeTokenstringOptionalformat: "^\s*0x(?!0{40})[a-fA-F0-9]{40}(\s*,\s*0x(?!0{40})[a-fA-F0-9]{40})*\s*$"
The contract address of the token to receive trading fees in (supports single or multiple comma-separated values). Each token must be set to the value of either the `buyToken` or the `sellToken`. If omitted, the fee token will be determined by 0x with preference to stablecoins and highly liquid assets. You must also specify the `swapFeeRecipient` and `swapFeeBps` to charge integrator fees. When multiple values are provided, must match length of `swapFeeBps`.
tradeSurplusRecipientstringOptionalformat: "^0x[a-fA-F0-9]{40}$"
The address to receive any trade surplus. If specified, this address will receive trade surplus when applicable. Otherwise, the taker will receive the surplus. This feature is only available to selected integrators on a custom pricing plan. In other cases, the surplus will be collected by 0x. For assistance with a custom plan, please contact support.
tradeSurplusMaxBpsintegerOptional1-10000

The maximum trade surplus (positive slippage) that can be collected in Bps of the buy amount. If not provided, defaults to 10000 (100%). Must be used together with tradeSurplusRecipient.

slippageBpsintegerOptional30-10000

The maximum acceptable slippage of the buyToken in Bps. 0x sets the optimal slippage tolerance per trade by default. To mitigate the risk of MEV attacks, we recommend adjusting this value only when trading low-liquidity tokens.

excludedSourcesstringOptional
Liquidity sources e.g. Uniswap_V3, SushiSwap, 0x_RFQ to exclude from the provided quote. See https://api.0x.org/sources?chainId=<chain_id> with the desired chain's ID for a full list of sources. Separate multiple sources with a comma

Response

Successful response
GaslessGetpriceResponse2000object
OR
GaslessGetpriceResponse2001object

Errors