Skip to main content
Version: 1.0

GET /swap/v1/price

/swap/v1/price can be used to acquire an indicative price for a transaction.

Rather than returning a transaction that can be submitted to an Ethereum node, this resource simply indicates the pricing that would be available for an analogous call to /swap/v1/quote.

Intended for use with RFQ; see Indicative Pricing & Firm Quotes for more details.

Request​

Identical to the request schema for /swap/v1/quote, with a few exceptions on all supported chains:

  • For /price, the default of skipValidation=true but can be overridden to false, whereas for /quote, the default of skipValidation=false but can be overridden to true
Query ParamDescriptionExample
sellTokenThe ERC20 token address of the token you want to sell. It is recommended to always use the token address instead of token symbols (e.g. ETH ) which may not be recognized by the API.sellToken=ETH, sellToken=0x6b175474e89094c44da98b954eedeac495271d0f
buyTokenThe ERC20 token address of the token you want to receive. It is recommended to always use the token address instead of token symbols (e.g. ETH ) which may not be recognized by the API.buyToken=0x6b175474e89094c44da98b954eedeac495271d0f
sellAmount(Optional) The amount of sellToken (in sellToken base units) you want to send. Either sellAmount or buyAmount must be present in a request. Specifying sellAmount is the recommended way to interact with 0x API as it covers all on-chain sources.sellAmount=100000000000
buyAmount(Optional) The amount of buyToken(in buyToken base units) you want to receive. Either sellAmount or buyAmount must be present in a request. Note that some on-chain sources do not allow specifying buyAmount, when using buyAmount these sources are excluded.buyAmount=100000000000
slippagePercentage(Optional, default is 0.01) The maximum acceptable slippage of the buyToken amount if sellAmount is provided; The maximum acceptable slippage of the sellAmount amount if buyAmount is provided (e.g. 0.03 for 3% slippage allowed). The lowest possible value that can be set for this parameter is 0; in other words, no amount of slippage would be allowed. If no value for this optional parameter is provided in the API request, the default slippage percentage is 1%.slippagePercentage=0.03
gasPrice(Optional, defaults to ethgasstation "fast") The target gas price (in wei) for the swap transaction. If the price is too low to achieve the quote, an error will be returned.gasPrice=1000000
takerAddress(Optional) The address which will fill the quote. While optional, we highly recommend providing this parameter if possible so that the API can more accurately estimate the gas required for the swap transaction. This helps when validating the entire transaction for success, and catches revert issues. If the validation fails, a Revert Error will be returned in the response. The quote should be fillable if this address is provided.

Also, make sure this address has enough token balance. Additionally, including the takerAddress is required if you want to integrate RFQ liquidity.
takerAddress=0xa8aac589a67ecfade31efde49a062cc21d68a64e
excludedSources(Optional) When used, only the specified liquidity sources (Uniswap, SushiSwap, 0x, Curve, etc) will be included in the provided quote.

One use case is for testing your RFQ integration by setting the value to 0x. This should be used when the integrator only wants RFQ liquidity without any other DEX orders.

This parameter cannot be combined with includedSources.
excludedSources=Uniswap,SushiSwap,Curve
includedSources(Optional) Typically used to filter for RFQ liquidity without any other DEX orders which this is useful for testing your RFQ integration. To do so, set it to 0x.

This parameter cannot be combined with excludedSources.
includedSources=0x
skipValidation(Optional) Normally, whenever a takerAddress is provided, the API will validate the quote for the user.

For more details, see "How does takerAddress help with catching issues?".

When this parameter is set to true, that validation will be skipped.

Also see Quote Validation here. For /quote , the default of skipValidation=false but can be overridden to true .
skipValidation=false
feeRecipient(Optional) The ETH address that should receive affiliate fees specified with buyTokenPercentageFee . Can be used combination with buyTokenPercentageFee to set a commission/trading fee when using the API.

Learn more about how to setup a trading fee/commission fee/transaction fee here in the FAQs.
feeRecipient=0xa8aac589a67ecfade31efde49a062cc21d68a64e
buyTokenPercentageFee(Optional) The percentage (between 0 - 1.0) of the buyAmount that should be attributed to feeRecipient as affiliate fees. Note that this requires that the feeRecipient parameter is also specified in the request. Learn more about how to setup a trading fee/commission fee/transaction fee here in the FAQs.buyTokenPercentageFee=0.1
priceImpactProtectionPercentage(Optional, defaults to 100%) The percentage (between 0 - 1.0) of allowed price impact.

When priceImpactProtectionPercentage is set, estimatedPriceImpact is returned which estimates the change in the price of the specified asset that would be caused by the executed swap due to price impact.

If the estimated price impact is above the percentage indicated, an error will be returned. For example, if priceImpactProtectionPercentage=.15 (15%), any quote with a price impact higher than 15% will return an error.

This is an opt-in feature, the default value of 1.0 will disable the feature. When it is set to 1.0 (100%) it means that every transaction is allowed to pass.

Note: When we fail to calculate Price Impact we will return null and Price Impact Protection will be disabled. See affects on estimatedPriceImpact in the Response fields. Read more about price impact protection and how to set it up here.
priceImpactProtectionPercentage=0.15
feeRecipientTradeSurplus(Optional) The recipient address of any trade surplus fees. If specified, this address will collect trade surplus when applicable. Otherwise, trade surplus will not be collected.

Note: Trade surplus is only sent to this address for sells. It is a no-op for buys. Read more about "Can I collect trade surplus?" here in the FAQs.
feeRecipientTradeSurplus=0xa8aac589a67ecfade31efde49a062cc21d68a64e

Response​

Identical to the response schema for /swap/v1/quote, with the execption that the orders property, guaranteedPrice, to and data fields will always be undefined

FieldDescription
priceIf buyAmount was specified in the request it provides the price of buyToken in sellToken and vice versa. This price does not include the slippage provided in the request above, and therefore represents the best possible price.

If buyTokenPercentageFee and feeRecipient were set, the fee amount will be part of this returned price.
grossPriceSimilar to price but with fees removed in the price calculation. This is the price as if no fee is charged.
estimatedPriceImpactWhen priceImpactProtectionPercentage is set, this value returns the estimated change in the price of the specified asset that would be caused by the executed swap due to price impact.

Note: If we fail to estimate price change we will return null.

Read more about price impact protection and how to set it up here .
valueThe amount of ether (in wei) that should be sent with the transaction. (Assuming protocolFee is paid in ether).
gasPriceThe gas price (in wei) that should be used to send the transaction. The transaction needs to be sent with this gasPrice or lower for the transaction to be successful.
gasThe estimated gas limit that should be used to send the transaction to guarantee settlement. While a computed estimate is returned in all responses, an accurate estimate will only be returned if a takerAddress is included in the request.
estimatedGasThe estimate for the amount of gas that will actually be used in the transaction. Always less than gas.
protocolFeeThe maximum amount of ether that will be paid towards the protocol fee (in wei), and what is used to compute the value field of the transaction. Note, as of ZEIP-91, protocol fees have been removed for all order types.
minimumProtocolFeeThe minimum amount of ether that will be paid towards the protocol fee (in wei) during the transaction.
buyAmountThe amount of buyToken (in buyToken units) that would be bought in this swap. Certain on-chain sources do not allow specifying buyAmount, when using buyAmount these sources are excluded.
grossBuyAmountSimilar to buyAmount but with fees removed. This is the buyAmount as if no fee is charged.
sellAmountThe amount of sellToken (in sellToken units) that would be sold in this swap. Specifying sellAmount is the recommended way to interact with 0xAPI as it covers all on-chain sources.
grossSellAmountSimilar to sellAmount but with fees removed. This is the sellAmount as if no fee is charged. Note: Currently, this will be the same as sellAmount as fees can only be configured to occur on the buyToken.
sourcesThe percentage distribution of buyAmount or sellAmount split between each liquidity source. Ex: [{ name: '0x', proportion: "0.8" }, { name: 'Kyber', proportion: "0.2"}, ...]
buyTokenAddressThe ERC20 token address of the token you want to receive in quote.
sellTokenAddressThe ERC20 token address of the token you want to sell with quote.
allowanceTargetThe target contract address for which the user needs to have an allowance in order to be able to complete the swap. Typically this is the 0x Exchange Proxy contract address for the specified chain. For swaps with "ETH" as sellToken, wrapping "ETH" to "WETH" or unwrapping "WETH" to "ETH" no allowance is needed, a null address of 0x0000000000000000000000000000000000000000 is then returned instead.
sellTokenToEthRateThe rate between ETH and sellToken
buyTokenToEthRateThe rate between ETH and buyToken
feesFees that would be charged. It can contain zeroExFee. See details about this fee type below.
zeroExFeeRelated to fees param above.

Fee that 0x charges:
  - feeType: volume which means 0x would charge a certain percentage of the trade.
  - feeToken: The ERC20 token address to charge fee.
  - feeAmount: The amount of feeToken to be charged as the 0x fee.
  - billingType: The method that 0x fee is transferred. It can currently only be on-chain which means the fee would be charged on-chain.

Example​

Get Price for Selling WETH to Buy DAI​

Specify a sellToken, buyToken and sellAmount to get a simple quote of 1 WETH for DAI.

Request

GET

curl https://api.0x.org/swap/v1/price?sellToken=0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2&buyToken=0x6b175474e89094c44da98b954eedeac495271d0f&sellAmount=1000000000000000000   --header '0x-api-key: <API_KEY>'

Response​

{
"price": "391.1643362",
"value": "11340000000000000",
"gasPrice": "81000000000",
"gas": "605952",
"estimatedGas": "504960",
"protocolFee": "11340000000000000",
"minimumProtocolFee": "5670000000000000",
"buyTokenAddress": "0x6b175474e89094c44da98b954eedeac495271d0f",
"buyAmount": "391164336200000000000",
"sellTokenAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"sellAmount": "1000000000000000000",
"sources": [
{
"name": "0x",
"proportion": "1"
},
{
"name": "Uniswap",
"proportion": "0"
},
{
"name": "Uniswap_V2",
"proportion": "0"
},
{
"name": "Eth2Dai",
"proportion": "0"
},
{
"name": "Kyber",
"proportion": "0"
},
{
"name": "Curve",
"proportion": "0"
},
{
"name": "LiquidityProvider",
"proportion": "0"
},
{
"name": "MultiBridge",
"proportion": "0"
},
{
"name": "Balancer",
"proportion": "0"
}
],
"estimatedGasTokenRefund": "252480",
"allowanceTarget": "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
"fees": {
"zeroExFee": null
},
"grossPrice": "391.1643362",
"grossBuyAmount": "391164336200000000000",
"grossSellAmount": "1000000000000000000"
}