> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.0x.org/api-reference/evm-ap-is/swap/permit-2-getprice/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.0x.org/_mcp/server. # getPrice (Permit2) GET https://api.0x.org/swap/permit2/price Get the indicative price for a swap using Permit2 to set allowances Reference: https://docs.0x.org/api-reference/evm-ap-is/swap/permit-2-getprice ## Request ### Query parameters - `chainId` (integer, required) — Chain ID. See [here](https://docs.0x.org/docs/introduction/supported-chains) for the list of supported chains - `buyToken` (string, required) — The contract address of the token to buy - `sellToken` (string, required) — The contract address of the token to sell - `sellAmount` (string, optional) — The amount of `sellToken` in `sellToken` base units to sell. Exactly one of `sellAmount` or `buyAmount` must be provided — specifying both will result in an error. - `buyAmount` (string, optional) — The amount of `buyToken` in `buyToken` base units to buy. Exactly one of `sellAmount` or `buyAmount` must be provided — specifying both will result in an error. - `taker` (string, optional) — The address which holds the `sellToken` balance and has the allowance set for the swap - `txOrigin` (string, optional) — The address of the external account that started the transaction. This is only needed if `taker` is a smart contract. - `recipient` (string, optional) — The address to receive the `buyToken`. If not provided, defaults to the taker address. Not supported for wrap/unwrap operations. - `swapFeeRecipient` (string, optional) — 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`. - `swapFeeBps` (string, optional) — 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. - `swapFeeToken` (string, optional) — 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`. - `tradeSurplusRecipient` (string, optional) — 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. - `tradeSurplusMaxBps` (integer, optional) — 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`. - `gasPrice` (string, optional) — The target gas price (in wei) for the swap transaction. If not provided, the default value is based on the 0x gas price oracle - `slippageBps` (integer, optional) — The maximum acceptable slippage of the `buyToken` in Bps. If this parameter is set to 0, no slippage will be tolerated. If not provided, the default slippage tolerance is 100Bps - `slippagePpm` (integer, optional) — The maximum acceptable slippage of the `buyToken` in parts-per-million (PPM). Mutually exclusive with `slippageBps`. e.g. 3000 PPM = 30 BPS = 0.30%. - `excludedSources` (string, optional) — Liquidity sources e.g. Uniswap\_V3, SushiSwap, 0x\_RFQ to exclude from the provided quote. See [https://api.0x.org/sources?chainId=\<chain\_id](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 - `sellEntireBalance` (enum, optional, default: false) — If set to `true`, the taker's entire `sellToken` balance will be sold during trade execution. The `sellAmount` should be the maximum estimated value, as close as possible to the actual taker's balance to ensure the best routing. Selling more than the `sellAmount` may cause the trade to revert. This feature is designed for cases where the precise sell amount is determined during execution. Learn more [here](https://docs.0x.org/docs/0x-swap-api/additional-topics/sell-entire-balance). - Allowed values: `true`, `false` - `wrapUnwrapMode` (SwapPermit2PriceGetParametersWrapUnwrapMode, optional) — Controls how native wrap/unwrap trades are executed. `direct` calls the wrapped-native token contract directly. `settler` routes wrap/unwrap through Settler or Allowance Holder for compatibility. Ignored for non-wrap/unwrap swaps. If omitted, `direct` mode is used. ### Headers - `0x-api-key` (string, required) — Visit dashboard.0x.org to get your API Key - `0x-version` (string, required) — API version ## Response ### 200 Successful response - `Swap_permit2Getprice_Response_200` ## Errors ### 400 Bad Request Error 400 error response - `Swap::permit2::getPriceRequestBadRequestError` ### 403 Forbidden Error 403 error response - `Swap::permit2::getPriceRequestForbiddenError` ### 422 Unprocessable Entity Error 422 error response - `Swap::permit2::getPriceRequestUnprocessableEntityError` ### 500 Internal Server Error 500 error response - `Swap::permit2::getPriceRequestInternalServerError` ## Types ### SwapPermit2PriceGetParametersWrapUnwrapMode ### SwapPermit2GetpriceResponse2001 - `liquidityAvailable` (boolean, required) — This validates the availability of liquidity for the quote requested. No other fields will be returned if it is `false` - `zid` (string, required) — The unique ZeroEx identifier of the request ### INPUT_INVALID - `name` (enum, required) - Allowed values: `INPUT_INVALID` - `message` (string, required) - `data` (InputInvalidData, required) ### RECIPIENT_NOT_SUPPORTED - `name` (enum, required) - Allowed values: `RECIPIENT_NOT_SUPPORTED` - `message` (string, required) - `data` (RecipientNotSupportedData, required) ### SWAP_VALIDATION_FAILED - `name` (enum, required) - Allowed values: `SWAP_VALIDATION_FAILED` - `message` (string, required) - `data` (SwapValidationFailedData, required) ### TOKEN_NOT_SUPPORTED - `name` (enum, required) - Allowed values: `TOKEN_NOT_SUPPORTED` - `message` (string, required) - `data` (TokenNotSupportedData, required) ### USER_NOT_AUTHORIZED - `name` (enum, required) - Allowed values: `USER_NOT_AUTHORIZED` - `message` (string, required) - `data` (UserNotAuthorizedData, required) ### TAKER_NOT_AUTHORIZED_FOR_TRADE - `name` (enum, required) - Allowed values: `TAKER_NOT_AUTHORIZED_FOR_TRADE` - `message` (string, required) - `data` (TakerNotAuthorizedForTradeData, required) ### RECIPIENT_NOT_AUTHORIZED_FOR_TRADE - `name` (enum, required) - Allowed values: `RECIPIENT_NOT_AUTHORIZED_FOR_TRADE` - `message` (string, required) - `data` (RecipientNotAuthorizedForTradeData, required) ### XSTOCKS_NOT_AUTHORIZED - `name` (enum, required) - Allowed values: `XSTOCKS_NOT_AUTHORIZED` - `message` (string, required) - `data` (XstocksNotAuthorizedData, required) ### BUY_TOKEN_NOT_AUTHORIZED_FOR_TRADE - `name` (enum, required) - Allowed values: `BUY_TOKEN_NOT_AUTHORIZED_FOR_TRADE` - `message` (string, required) - `data` (BuyTokenNotAuthorizedForTradeData, required) ### SELL_TOKEN_NOT_AUTHORIZED_FOR_TRADE - `name` (enum, required) - Allowed values: `SELL_TOKEN_NOT_AUTHORIZED_FOR_TRADE` - `message` (string, required) - `data` (SellTokenNotAuthorizedForTradeData, required) ### INTERNAL_SERVER_ERROR - `name` (enum, required) - Allowed values: `INTERNAL_SERVER_ERROR` - `message` (string, required) - `data` (InternalServerErrorData, required) ### UNCATEGORIZED - `name` (enum, required) - Allowed values: `UNCATEGORIZED` - `message` (string, required) - `data` (UncategorizedData, required) ### InputInvalidData - `zid` (string, required) — The unique ZeroEx identifier of the request - `details` (list of InputInvalidDataDetailsItems, required) — The list of invalid inputs ### RecipientNotSupportedData - `zid` (string, required) — The unique ZeroEx identifier of the request ### SwapValidationFailedData - `zid` (string, required) — The unique ZeroEx identifier of the request ### TokenNotSupportedData - `token` (string, required) — Unsupported token address - `zid` (string, required) — The unique ZeroEx identifier of the request ### UserNotAuthorizedData - `zid` (string, required) — The unique ZeroEx identifier of the request ### TakerNotAuthorizedForTradeData - `zid` (string, required) — The unique ZeroEx identifier of the request ### RecipientNotAuthorizedForTradeData - `zid` (string, required) — The unique ZeroEx identifier of the request ### XstocksNotAuthorizedData - `zid` (string, required) — The unique ZeroEx identifier of the request ### BuyTokenNotAuthorizedForTradeData - `zid` (string, required) — The unique ZeroEx identifier of the request ### SellTokenNotAuthorizedForTradeData - `zid` (string, required) — The unique ZeroEx identifier of the request ### InternalServerErrorData - `zid` (string, required) — The unique ZeroEx identifier of the request ### UncategorizedData - `zid` (string, required) — The unique ZeroEx identifier of the request ### InputInvalidDataDetailsItems - `field` (string, required) — The input field name - `reason` (string, required) — The validation failure reason ## Examples **Response** ```json { "allowanceTarget": "0x000000000022d473030f116ddee9f6b43ac78ba3", "blockNumber": null, "buyAmount": null, "buyToken": "0xdac17f958d2ee523a2206206994597c13d831ec7", "fees": { "integratorFee": null, "integratorFees": [ { "amount": null, "token": "string", "type": "volume" } ], "zeroExFee": null, "gasFee": null }, "issues": { "allowance": { "actual": null, "spender": "0x000000000022d473030f116ddee9f6b43ac78ba3" }, "balance": { "token": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "actual": null, "expected": null }, "simulationIncomplete": false, "invalidSourcesPassed": [] }, "liquidityAvailable": true, "minBuyAmount": null, "mode": "exact-in", "route": { "fills": [ { "from": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "to": "0xdac17f958d2ee523a2206206994597c13d831ec7", "source": "SolidlyV3", "proportionBps": null } ], "tokens": [ { "address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "symbol": "USDC" }, { "address": "0xdac17f958d2ee523a2206206994597c13d831ec7", "symbol": "USDT" } ] }, "sellAmount": null, "sellToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "tokenMetadata": { "buyToken": { "buyTaxBps": null, "sellTaxBps": null, "transferTaxBps": null }, "sellToken": { "buyTaxBps": null, "sellTaxBps": null, "transferTaxBps": null } }, "totalNetworkFee": null, "zid": "0x111111111111111111111111", "gas": null, "gasPrice": null } ``` **SDK Code** ```python Swap_permit2Getprice_example import requests url = "https://api.0x.org/swap/permit2/price" querystring = {"chainId":"1","buyToken":"0xdac17f958d2ee523a2206206994597c13d831ec7","sellToken":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","sellAmount":"100000000","taker":"0x70a9f34f9b34c64957b9c401a97bfed35b95049e"} headers = { "0x-api-key": "0x-api-key", "0x-version": "v2" } response = requests.get(url, headers=headers, params=querystring) print(response.json()) ``` ```javascript Swap_permit2Getprice_example const url = 'https://api.0x.org/swap/permit2/price?chainId=1&buyToken=0xdac17f958d2ee523a2206206994597c13d831ec7&sellToken=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48&sellAmount=100000000&taker=0x70a9f34f9b34c64957b9c401a97bfed35b95049e'; const options = {method: 'GET', headers: {'0x-api-key': '0x-api-key', '0x-version': 'v2'}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Swap_permit2Getprice_example package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.0x.org/swap/permit2/price?chainId=1&buyToken=0xdac17f958d2ee523a2206206994597c13d831ec7&sellToken=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48&sellAmount=100000000&taker=0x70a9f34f9b34c64957b9c401a97bfed35b95049e" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("0x-api-key", "0x-api-key") req.Header.Add("0x-version", "v2") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby Swap_permit2Getprice_example require 'uri' require 'net/http' url = URI("https://api.0x.org/swap/permit2/price?chainId=1&buyToken=0xdac17f958d2ee523a2206206994597c13d831ec7&sellToken=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48&sellAmount=100000000&taker=0x70a9f34f9b34c64957b9c401a97bfed35b95049e") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["0x-api-key"] = '0x-api-key' request["0x-version"] = 'v2' response = http.request(request) puts response.read_body ``` ```java Swap_permit2Getprice_example import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.0x.org/swap/permit2/price?chainId=1&buyToken=0xdac17f958d2ee523a2206206994597c13d831ec7&sellToken=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48&sellAmount=100000000&taker=0x70a9f34f9b34c64957b9c401a97bfed35b95049e") .header("0x-api-key", "0x-api-key") .header("0x-version", "v2") .asString(); ``` ```php Swap_permit2Getprice_example request('GET', 'https://api.0x.org/swap/permit2/price?chainId=1&buyToken=0xdac17f958d2ee523a2206206994597c13d831ec7&sellToken=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48&sellAmount=100000000&taker=0x70a9f34f9b34c64957b9c401a97bfed35b95049e', [ 'headers' => [ '0x-api-key' => '0x-api-key', '0x-version' => 'v2', ], ]); echo $response->getBody(); ``` ```csharp Swap_permit2Getprice_example using RestSharp; var client = new RestClient("https://api.0x.org/swap/permit2/price?chainId=1&buyToken=0xdac17f958d2ee523a2206206994597c13d831ec7&sellToken=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48&sellAmount=100000000&taker=0x70a9f34f9b34c64957b9c401a97bfed35b95049e"); var request = new RestRequest(Method.GET); request.AddHeader("0x-api-key", "0x-api-key"); request.AddHeader("0x-version", "v2"); IRestResponse response = client.Execute(request); ``` ```swift Swap_permit2Getprice_example import Foundation let headers = [ "0x-api-key": "0x-api-key", "0x-version": "v2" ] let request = NSMutableURLRequest(url: NSURL(string: "https://api.0x.org/swap/permit2/price?chainId=1&buyToken=0xdac17f958d2ee523a2206206994597c13d831ec7&sellToken=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48&sellAmount=100000000&taker=0x70a9f34f9b34c64957b9c401a97bfed35b95049e")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` > Developer documentation for the 0x API. Embed swaps in your onchain app. Access 10+ million tokens with liquidity from 150+ exchanges with a single API.