Skip to main content

GET /swap/v1/quote

Get an easy-to-consume quote for buying or selling any ERC20 token. The return format is a valid unsigned Ethereum transaction and can be submitted directly to an Ethereum node (or the nodes of other chains if applicable) to complete the swap. For transactions where the sellToken is not ETH, you will have to set your allowances.

Request

Either a sellAmount or buyAmount is required.

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=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 for 1%) 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) Liquidity sources (Uniswap, SushiSwap, 0x, Curve, etc) that will not be included in the provided quote. See here for a full list of sources.

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 (denoted as a decimal between 0 - 1.0 where 1.0 represents 100%) 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
enableSlippageProtection(Optional) A boolean field, set to true or false. If enableSlippageProtection is either not set or set to true, the quote will be adjusted for MEV-aware slippage.

If enableSlippageProtection is false, the quote returned will not be adjusted for MEV-aware slippage (this is recommended for meta-aggregators & integrators who will compare the quoted price with other sources).

See affects on buyAmount , price , and expectedSlippage in the Response fields.

Read more about Slippage Protection .
enableSlippageProtection=true
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
shouldSellEntireBalance(Optional) A boolean field. If set to true, the 0x Swap API quote request should sell the entirety of the caller's takerToken balance. A sellAmount is still required, even if it is a best guess, because it is how a reasonable minimum received amount is determined after slippage.

Note: This parameter is only required for special cases, such as when setting up a multi-step transaction or composable operation, where the entire balance is not known ahead of time. Read more about "Is there a way to sell assets via Swap API if the exact sellToken amount is not known before the transaction is executed?" here in the FAQs.
shouldSellEntireBalance=true

Response

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 feeRecipientwere set, the fee amount will be part of this returned price. If enableSlippageProtection in the request was not false, the buyAmount & price responses returned will factor slippage in its routing.
grossPriceSimilar to price but with fees removed in the price calculation. This is the price as if no fee is charged.
guaranteedPriceThe price which must be met or else the entire transaction will revert. This price is influenced by the slippagePercentage parameter. On-chain sources may encounter price movements from quote to settlement.
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(/0x-swap-api/advanced-topics/price-impact-protection)].

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 .
toThe address of the contract to send call data to.
dataThe call data required to be sent to the to contract address.
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.
ordersThe details used to fill orders, used by market makers. If orders is not empty, there will be a type on each order. For wrap/unwrap, orders is empty. otherwise, should be populated.
typeRelated to orders above. The order types correspond enums in the 0x Protocol FillQuoteTransformer smart contract. Bridge = 0, Limit = 1, Rfq = 2, Otc = 3. Bridge type means the order is executed on a DEX (aka AMMs). Limit corresponds to LimitOrder. Rfq corresponds to RfqOrder. Otc corresponds to OtcOrder. The "Rfq" type is deprecated.
sellTokenToEthRateThe rate between ETH and sellToken
buyTokenToEthRateThe rate between ETH and buyToken
expectedSlippageThis is the expected slippage used in routing calculations for the quote returned. It is the value of slippage that we estimate that the selected route will have:

- It can be used by integrators to calculate the Final Expected Amount for the asset: i.e. calculated as (buyAmount * expectedSlippage )

- It will only be returned when enableSlippageProtection is not set to false

- Slippage Protection is enabled for a specific set of trading pairs for which we expect significant slippage (typically larger trades and more volatile pairs). In cases where it is not enabled expectedSlippage=null is returned.
fees0x Swap API fees that would be charged. 0x takes an on-chain fee on swaps involving a select few token pairs for the Free and Starter tiers. This fee is charged on-chain to the users of your app during the transaction. If you are on the Growth tier, we completely waive this fee for your customers. Read more about it on our pricing page.

This objects contains the zeroExFee object. 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.

Examples

Simple Quote to Sell 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/quote?buyToken=0x6b175474e89094c44da98b954eedeac495271d0f&sellToken=0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2&sellAmount=100000000000000000  --header '0x-api-key: <API_KEY>'

Response

{
"chainId": 1,
"price": "2504.4918553394464675",
"guaranteedPrice": "2479.4469367860520028",
"estimatedPriceImpact": "0.0001",
"to": "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
"data": "0xd9627aa40000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000015817a685f9a1645c00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0f869584cd000000000000000000000000100000000000000000000000000000000000001100000000000000000000000000000000000000000000001c2e352fd761f763ab",
"value": "0",
"gas": "111000",
"estimatedGas": "111000",
"gasPrice": "93000000000",
"protocolFee": "0",
"minimumProtocolFee": "0",
"buyTokenAddress": "0x6b175474e89094c44da98b954eedeac495271d0f",
"sellTokenAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"buyAmount": "25044918553394464675",
"sellAmount": "10000000000000000",
"sources": [
{
"name": "0x",
"proportion": "0"
},
{
"name": "Uniswap",
"proportion": "0"
},
{
"name": "Uniswap_V2",
"proportion": "0"
},
{
"name": "Eth2Dai",
"proportion": "0"
},
{
"name": "Kyber",
"proportion": "0"
},
{
"name": "Curve",
"proportion": "0"
},
{
"name": "Balancer",
"proportion": "0"
},
{
"name": "Balancer_V2",
"proportion": "0"
},
{
"name": "Bancor",
"proportion": "0"
},
{
"name": "mStable",
"proportion": "0"
},
{
"name": "Mooniswap",
"proportion": "0"
},
{
"name": "Swerve",
"proportion": "0"
},
{
"name": "SnowSwap",
"proportion": "0"
},
{
"name": "SushiSwap",
"proportion": "1"
},
{
"name": "Shell",
"proportion": "0"
},
{
"name": "MultiHop",
"proportion": "0"
},
{
"name": "DODO",
"proportion": "0"
},
{
"name": "DODO_V2",
"proportion": "0"
},
{
"name": "CREAM",
"proportion": "0"
},
{
"name": "LiquidityProvider",
"proportion": "0"
},
{
"name": "CryptoCom",
"proportion": "0"
},
{
"name": "Linkswap",
"proportion": "0"
},
{
"name": "Lido",
"proportion": "0"
},
{
"name": "MakerPsm",
"proportion": "0"
},
{
"name": "KyberDMM",
"proportion": "0"
},
{
"name": "Smoothy",
"proportion": "0"
},
{
"name": "Component",
"proportion": "0"
},
{
"name": "Saddle",
"proportion": "0"
},
{
"name": "xSigma",
"proportion": "0"
},
{
"name": "Uniswap_V3",
"proportion": "0"
},
{
"name": "Curve_V2",
"proportion": "0"
},
{
"name": "ShibaSwap",
"proportion": "0"
}
],
"orders": [
{
"makerToken": "0x6b175474e89094c44da98b954eedeac495271d0f",
"takerToken": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"makerAmount": "25044918553394464675",
"takerAmount": "10000000000000000",
"fillData": {
"tokenAddressPath": [
"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"0x6b175474e89094c44da98b954eedeac495271d0f"
],
"router": "0xd9e1ce17f2641f24ae83637ab66a2cca9c378b9f"
},
"source": "SushiSwap",
"sourcePathId": "0xe58bde9f0ca002c1e99df8df403eabe6431a3b0476ee5dfb92fe0a35af2f5ead",
"type": 0
}
],
"allowanceTarget": "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
"sellTokenToEthRate": "1",
"buyTokenToEthRate": "2504.46738154874763977",
"fees": {
"zeroExFee": null
},
"grossPrice": "2504.4918553394464675",
"grossBuyAmount": "25044918553394464675",
"grossSellAmount": "10000000000000000"
}

Excluding liquidity sources (Sell ETH to Buy DAI, Exclude 0x, Kyber)

Supply a comma delimited list of liquidty source names to exclude them from the aggregator logic. See here for a full list of sources.

Request

GET

curl https://api.0x.org/swap/v1/quote?buyToken=0x6b175474e89094c44da98b954eedeac495271d0f&sellToken=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE&sellAmount=1000000000000000000&excludedSources=0x,Kyber  --header '0x-api-key: <API_KEY>'

Response

{
"chainId": 1,
"price": "2484.996784870669179426",
"guaranteedPrice": "2460.146817021962487631",
"estimatedPriceImpact": "0.0001",
"to": "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
"data": "0xd9627aa400000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000855d653faa3dfe074f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f869584cd00000000000000000000000010000000000000000000000000000000000000110000000000000000000000000000000000000000000000ee7813bf1e61f766c0",
"value": "1000000000000000000",
"gas": "136000",
"estimatedGas": "136000",
"gasPrice": "96000000000",
"protocolFee": "0",
"minimumProtocolFee": "0",
"buyTokenAddress": "0x6b175474e89094c44da98b954eedeac495271d0f",
"sellTokenAddress": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"buyAmount": "2484996784870669179426",
"sellAmount": "1000000000000000000",
"sources": [
{
"name": "0x",
"proportion": "0"
},
{
"name": "Uniswap",
"proportion": "0"
},
{
"name": "Uniswap_V2",
"proportion": "1"
},
{
"name": "Eth2Dai",
"proportion": "0"
},
{
"name": "Kyber",
"proportion": "0"
},
{
"name": "Curve",
"proportion": "0"
},
{
"name": "Balancer",
"proportion": "0"
},
{
"name": "Balancer_V2",
"proportion": "0"
},
{
"name": "Bancor",
"proportion": "0"
},
{
"name": "mStable",
"proportion": "0"
},
{
"name": "Mooniswap",
"proportion": "0"
},
{
"name": "Swerve",
"proportion": "0"
},
{
"name": "SnowSwap",
"proportion": "0"
},
{
"name": "SushiSwap",
"proportion": "0"
},
{
"name": "Shell",
"proportion": "0"
},
{
"name": "MultiHop",
"proportion": "0"
},
{
"name": "DODO",
"proportion": "0"
},
{
"name": "DODO_V2",
"proportion": "0"
},
{
"name": "CREAM",
"proportion": "0"
},
{
"name": "LiquidityProvider",
"proportion": "0"
},
{
"name": "CryptoCom",
"proportion": "0"
},
{
"name": "Linkswap",
"proportion": "0"
},
{
"name": "Lido",
"proportion": "0"
},
{
"name": "MakerPsm",
"proportion": "0"
},
{
"name": "KyberDMM",
"proportion": "0"
},
{
"name": "Smoothy",
"proportion": "0"
},
{
"name": "Component",
"proportion": "0"
},
{
"name": "Saddle",
"proportion": "0"
},
{
"name": "xSigma",
"proportion": "0"
},
{
"name": "Uniswap_V3",
"proportion": "0"
},
{
"name": "Curve_V2",
"proportion": "0"
},
{
"name": "ShibaSwap",
"proportion": "0"
}
],
"orders": [
{
"makerToken": "0x6b175474e89094c44da98b954eedeac495271d0f",
"takerToken": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"makerAmount": "2484996784870669179426",
"takerAmount": "1000000000000000000",
"fillData": {
"tokenAddressPath": [
"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"0x6b175474e89094c44da98b954eedeac495271d0f"
],
"router": "0xf164fc0ec4e93095b804a4795bbe1e041497b92a"
},
"source": "Uniswap_V2",
"sourcePathId": "0x3d17978a401419de71950469cdeec831aeaafc5abbab547a5e79cc2d4c38cce3",
"type": 0
}
],
"allowanceTarget": "0x0000000000000000000000000000000000000000",
"sellTokenToEthRate": "1",
"buyTokenToEthRate": "2482.11547954119199012",
"fees": {
"zeroExFee": null
},
"grossPrice": "2484.996784870669179426",
"grossBuyAmount": "2484996784870669179426",
"grossSellAmount": "1000000000000000000"
}

Supplying a Taker Address (Sell ETH to Buy DAI)

Supply a takerAddress to use an eth_call to perform additional validation, and an accurate gas estimate.

Request

GET

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

Response

{
"chainId": 1,
"price": "2496.390120385736312458",
"guaranteedPrice": "2471.426219181878949333",
"estimatedPriceImpact": "0.0001",
"to": "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
"data": "0x3598d8ab0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000085f9edbc2b2a9635d50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc20001f46b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000869584cd00000000000000000000000010000000000000000000000000000000000000110000000000000000000000000000000000000000000000f4d36b6ed161f769fa",
"value": "1000000000000000000",
"gas": "151000",
"estimatedGas": "151000",
"from": "0xab5801a7d398351b8be11c439e05c5b3259aec9b",
"gasPrice": "88000000000",
"protocolFee": "0",
"minimumProtocolFee": "0",
"buyTokenAddress": "0x6b175474e89094c44da98b954eedeac495271d0f",
"sellTokenAddress": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"buyAmount": "2496390120385736312458",
"sellAmount": "1000000000000000000",
"sources": [
{
"name": "0x",
"proportion": "0"
},
{
"name": "Uniswap",
"proportion": "0"
},
{
"name": "Uniswap_V2",
"proportion": "0"
},
{
"name": "Eth2Dai",
"proportion": "0"
},
{
"name": "Kyber",
"proportion": "0"
},
{
"name": "Curve",
"proportion": "0"
},
{
"name": "Balancer",
"proportion": "0"
},
{
"name": "Balancer_V2",
"proportion": "0"
},
{
"name": "Bancor",
"proportion": "0"
},
{
"name": "mStable",
"proportion": "0"
},
{
"name": "Mooniswap",
"proportion": "0"
},
{
"name": "Swerve",
"proportion": "0"
},
{
"name": "SnowSwap",
"proportion": "0"
},
{
"name": "SushiSwap",
"proportion": "0"
},
{
"name": "Shell",
"proportion": "0"
},
{
"name": "MultiHop",
"proportion": "0"
},
{
"name": "DODO",
"proportion": "0"
},
{
"name": "DODO_V2",
"proportion": "0"
},
{
"name": "CREAM",
"proportion": "0"
},
{
"name": "LiquidityProvider",
"proportion": "0"
},
{
"name": "CryptoCom",
"proportion": "0"
},
{
"name": "Linkswap",
"proportion": "0"
},
{
"name": "Lido",
"proportion": "0"
},
{
"name": "MakerPsm",
"proportion": "0"
},
{
"name": "KyberDMM",
"proportion": "0"
},
{
"name": "Smoothy",
"proportion": "0"
},
{
"name": "Component",
"proportion": "0"
},
{
"name": "Saddle",
"proportion": "0"
},
{
"name": "xSigma",
"proportion": "0"
},
{
"name": "Uniswap_V3",
"proportion": "1"
},
{
"name": "Curve_V2",
"proportion": "0"
},
{
"name": "ShibaSwap",
"proportion": "0"
}
],
"orders": [
{
"makerToken": "0x6b175474e89094c44da98b954eedeac495271d0f",
"takerToken": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"makerAmount": "2496390120385736312458",
"takerAmount": "1000000000000000000",
"fillData": {
"router": "0xe592427a0aece92de3edee1f18e0157c05861564",
"tokenAddressPath": [
"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"0x6b175474e89094c44da98b954eedeac495271d0f"
],
"uniswapPath": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc20001f46b175474e89094c44da98b954eedeac495271d0f"
},
"source": "Uniswap_V3",
"sourcePathId": "0xcb26f3151d130b8a513c634db8a75b30f1ed3ee24a41a578b90efe1de55ac28c",
"type": 0
}
],
"allowanceTarget": "0x0000000000000000000000000000000000000000",
"sellTokenToEthRate": "1",
"buyTokenToEthRate": "2485.49297930185739314",
"fees": {
"zeroExFee": null
},
"grossPrice": "2496.390120385736312458",
"grossBuyAmount": "2496390120385736312458",
"grossSellAmount": "1000000000000000000"
}

If the eth_call fails (because takerAddress cannot complete the transaction), the response will include reasons for the failure.

{
"code": 105,
"reason": "IncompleteFillError",
"values": {
"error": 0,
"expectedAssetFillAmount": "10000000",
"actualAssetFillAmount": "0"
}
}

Wrapping and Unwrapping between ETH and WETH

Easily wrap and unwrap between ETH and WETH by requesting a swap quote by setting sellToken and buyToken as either WETH or ETH. The swap quote returned will provide the calldata to directly interact with the WETH9 contract and not with 0x exchange contracts.

Wrap ETH

Request

Get

curl https://api.0x.org/swap/v1/quote?buyToken=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&sellToken=0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2&buyAmount=10000000   --header '0x-api-key: <API_KEY>'

Response

{
"chainId": 1,
"price": "1",
"guaranteedPrice": "1",
"to": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"data": "0x2e1a7d4d0000000000000000000000000000000000000000000000000000000000989680869584cd0000000000000000000000001000000000000000000000000000000000000011000000000000000000000000000000000000000000000087b981bc4361f76bbe",
"value": "0",
"gas": "46000",
"estimatedGas": "46000",
"gasPrice": "104000000000",
"protocolFee": "0",
"minimumProtocolFee": "0",
"buyTokenAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"sellTokenAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"buyAmount": "10000000",
"sellAmount": "10000000",
"sources": [],
"orders": [],
"sellTokenToEthRate": "1",
"buyTokenToEthRate": "1",
"allowanceTarget": "0x0000000000000000000000000000000000000000"
}

Unwrap ETH

Request

Get

https://api.0x.org/swap/v1/quote?buyToken=WETH&sellToken=ETH&buyAmount=10000000

Response

{
"chainId": 1,
"price": "1",
"guaranteedPrice": "1",
"to": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"data": "0xd0e30db0869584cd0000000000000000000000001000000000000000000000000000000000000011000000000000000000000000000000000000000000000024811cd5d661f76c49",
"value": "10000000",
"gas": "46000",
"estimatedGas": "46000",
"gasPrice": "105000000000",
"protocolFee": "0",
"minimumProtocolFee": "0",
"buyTokenAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"sellTokenAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"buyAmount": "10000000",
"sellAmount": "10000000",
"sources": [],
"orders": [],
"sellTokenToEthRate": "1",
"buyTokenToEthRate": "1",
"allowanceTarget": "0x0000000000000000000000000000000000000000"
}

Ensure RFQ liquidity

RFQ liquidity can only be accessed if the request supplies a taker address and a permissioned API key via header 0x-api-key (get one from the 0x Dashboard). For more details see the guide here.

Request

Get

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

Response

{
"price": "376.7868259",
"guaranteedPrice": "375.506208585632606933",
"to": "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
"data": "0xa6c3bf3300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000007200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002600000000000000000000000006425bb021dabd5d6b443a1ab47b003a1b7a27d4b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000051b3ded76a61cee0000000000000000000000000000000000000000000000000003782dace9d900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005f2d826000000000000000000000000000000000000000000000000000000173c9bc22f400000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000005e0000000000000000000000000000000000000000000000000000000000000064000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000000024f47261b00000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000000000000000000000000000000c47b7094f378e54347e281aab170e8cca69d880a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000145b320b31045e6ad60000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005f2d9dcb7be1c251ac3d8521ea92398740531b31bd13d1e48c182ebb46dfc2360b9f433400000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000003c00000000000000000000000000000000000000000000000000000000000000420000000000000000000000000000000000000000000000000000000000000042000000000000000000000000000000000000000000000000000000000000001c4dc1600f30000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000c47b7094f378e54347e281aab170e8cca69d880a00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000140000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000036691c4f426eb8f42f150ebde43069a31cb080ad0000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000145b320b31045e6ad600000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024f47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000421ca9636d5a84fb4e458816391b3d8860bf4b459f97b8962f8ec1c35d7240cce6d51ad2d55a2dec2562194ec7457d10d73b8f55fcdc144ee21e4211c067251973680200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010400000000000000000000000000000000000000000000000000000000000000869584cd00000000000000000000000010000000000000000000000000000000000000110000000000000000000000000000000000000000000000cef59c5ef35f2d81ac",
"value": "12320000000000000",
"gas": "540000",
"estimatedGas": "450000",
"from": "0xffffffffffffffffffffffffffffffffffffffff",
"gasPrice": "88000000000",
"protocolFee": "12320000000000000",
"minimumProtocolFee": "6160000000000000",
"buyTokenAddress": "0x6b175474e89094c44da98b954eedeac495271d0f",
"sellTokenAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"buyAmount": "376786825900000000000",
"sellAmount": "1000000000000000000",
"estimatedGasTokenRefund": "0",
"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": "Balancer",
"proportion": "0"
}
],
"allowanceTarget": "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
"fees": {
"zeroExFee": null
},
"grossPrice": "376.7868259",
"grossBuyAmount": "376786825900000000000",
"grossSellAmount": "1000000000000000000"
}