# Get Price & Calldata: /swap

It is designed to simplify the trading process by combining price estimation and transaction calldata generation into a single API call. This makes it a convenient option for users who want a quick and streamlined way to execute trades without handling multiple requests. However, while it offers ease of use, it also comes with certain limitations.

## Limitations

* Lower rate limits
* It doesn't check sufficient allowances and balances
* It doesn't return the gas field in txParams, thus the transaction should be simulated locally
* It automatically excludes RFQ-based DEXs such as AugustusRFQ & ParaSwapLimitOrders.&#x20;

## Get Price Route & Transaction Building

<mark style="color:blue;">`GET`</mark> `https://api.paraswap.io/swap`

This endpoint gets the optimal price and price route required to swap from one token to another.

Additionally the swap endpoint also generates the parameters required for the transaction.

#### Query Parameters

| Name                                           | Type    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ---------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| srcToken<mark style="color:red;">\*</mark>     | string  | Source Token Address. Instead **Token Symbol** could be used for tokens listed in the `/tokens` endpoint.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| srcDecimals<mark style="color:red;">\*</mark>  | integer | Source Token Decimals. (Can be omitted if Token Symbol is used in `srcToken`).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| destToken<mark style="color:red;">\*</mark>    | string  | Destination Token Address. Instead **Token Symbol** could be used for tokens listed in the  `/tokens` endpoint.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| amount<mark style="color:red;">\*</mark>       | string  | <p>srcToken amount (in case of SELL) or destToken amount (in case of BUY). <br>The amount should be in <strong>WEI/Raw units</strong> (eg. 1WBTC -> 100000000) </p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| side                                           | string  | <p><strong>SELL</strong> or <strong>BUY</strong>. <br>Default: <code>SELL</code>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| network                                        | string  | <p>Network ID. (Mainnet - 1, Optimism - 10, BSC - 56, Polygon - 137, Base - 8453, Arbitrum - 42161, Avalanche - 43114, Gnosis - 100, Sonic - 146, Unichain - 130, Plasma - 9745).<br>Default: <code>1</code>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| otherExchangePrices                            | boolean | <p>If provided, <strong>others</strong> object is filled in the response with price quotes from other exchanges <em>(if available for comparison)</em>.<br>Default: <code>false</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| includeDEXS                                    | string  | <p>Comma Separated List of DEXs to include. <br><strong>Supported DEXs:</strong> <br>Uniswap, Kyber, Bancor, AugustusRFQ, Oasis, Compound, Fulcrum, 0x, MakerDAO, Chai, Aave, Aave2, MultiPath, MegaPath, Curve, Curve3, Saddle, IronV2, BDai, idle, Weth, Beth, UniswapV2, Balancer, 0xRFQt, SushiSwap, LINKSWAP, Synthetix, DefiSwap, Swerve, CoFiX, Shell, DODOV1, DODOV2, OnChainPricing, PancakeSwap, PancakeSwapV2, ApeSwap, Wbnb, acryptos, streetswap, bakeryswap, julswap, vswap, vpegswap, beltfi, ellipsis, QuickSwap, COMETH, Wmatic, Nerve, Dfyn, UniswapV3, Smoothy, PantherSwap, OMM1, OneInchLP, CurveV2, mStable, WaultFinance, MDEX, ShibaSwap, CoinSwap, SakeSwap, JetSwap, Biswap, BProtocol<br>eg: <code>UniswapV3,0x</code></p> |
| excludeDEXS                                    | string  | Comma Separated List of DEXs to exclude. (from the list of DEXs mentioned above).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| includeContractMethods                         | string  | <p>Comma Separated List of Contract Methods to include without spaces. <strong>Available values:</strong> swapOnUniswap, buyOnUniswap, swapOnUniswapFork, buyOnUniswapFork, swapOnUniswapV2Fork, buyOnUniswapV2Fork, simpleBuy, simpleSwap, multiSwap, megaSwap, protectedMultiSwap, protectedMegaSwap, protectedSimpleSwap, protectedSimpleBuy, swapOnZeroXv2, swapOnZeroXv4, buy.<br>eg: <code>simpleSwap,multiSwap</code></p>                                                                                                                                                                                                                                                                                                                      |
| excludeContractMethods                         | string  | Comma Separated List of Contract Methods to exclude without spaces. (from the list of contract methods mentioned above).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| userAddress                                    | string  | User's Wallet Address.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| route                                          | string  | <p>Dash (-) separated list of tokens (addresses or symbols from <code>/tokens</code>) to comprise the price route. <em>Max 4 tokens.</em> <br><em><strong>\*Note:</strong> If <code>route</code> is specified, the response will only comprise of the route specified which might not be the optimal route.</em> </p>                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| partner                                        | string  | Partner string.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| partnerFeeBps                                  | string  | <p>If provided it is used together with <code>partnerAddress</code>. Should be in basis points percentage. Look at <code>slippage</code> parameter description for understanding better. Eg: <code>200</code> (for 2% fee percent)</p><p><em>\*Note: Fees have to be claimed from the</em> <a href="https://developers.paraswap.network/smart-contracts#fee-claimer"><em>Fee Claimer contract</em></a> <em>unless <code>isSurplusToUser</code> or <code>isDirectFeeTransfer</code> are used</em></p>                                                                                                                                                                                                                                                  |
| partnerAddress                                 | string  | <p>Address that will be entitled to claim fees or surplus.</p><p><em>\*Note: Fees have to be claimed from the</em> <a href="https://developers.paraswap.network/smart-contracts#fee-claimer"><em>Fee Claimer contract</em></a> <em>unless <code>isSurplusToUser</code> or <code>isDirectFeeTransfer</code> are used</em></p>                                                                                                                                                                                                                                                                                                                                                                                                                          |
| slippage                                       | integer | <p>Allowed slippage percentage represented in basis points. <br><em>Eg:</em> for <strong>2.5%</strong> slippage, set the value to <strong>2.5 \* 100 = 250</strong>; for 10% = 1000. Slippage could be passed instead of <code>destAmount</code> when <strong>side=SELL</strong> or <code>srcAmount</code> when <strong>side=BUY</strong>. <br><code>Min: 0; Max: 10000</code></p>                                                                                                                                                                                                                                                                                                                                                                    |
| destDecimals<mark style="color:red;">\*</mark> | integer | Destination Token Decimals. (Can be omitted if Token Symbol is used in `destToken`).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| maxImpact                                      | number  | In %. It's a way to bypass the API price impact check (default = 15%).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| receiver                                       | String  | Receiver's Wallet address. (Can be omitted if swapping tokens from and to same account)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| srcTokenTransferFee                            | string  | <p>If the source token is a tax token, you should specify the tax amount in BPS.</p><p><em>\*For example: for a token with a 5% tax, you should set it to 500 as</em><br><em><code>\[(500/10000)\*100=5%]</code></em></p><p><em>\*\*Note: not all DEXs and contract methods support trading tax tokens, so we will filter those that don't.</em> </p>                                                                                                                                                                                                                                                                                                                                                                                                 |
| destTokenTransferFee                           | string  | <p>If the destination token is a tax token, you should specify the tax amount in BPS.</p><p><em>\*For example: for a token with a 5% tax, you should set it to 500 as</em><br><em><code>\[(500/10000)\*100=5%]</code></em></p><p><em>\*\*Note: not all DEXs and contract methods support trading tax tokens, so we will filter those that don't.</em> </p>                                                                                                                                                                                                                                                                                                                                                                                            |
| srcTokenDexTransferFee                         | string  | <p>If the source token is a tax token, you should specify the tax amount in BPS.<br>Some tokens only charge tax when swapped in/out DEXs and not on ordinary transfers.</p><p><em>\*For example: for a token with a 5% tax, you should set it to 500 as</em><br><em><code>\[(500/10000)\*100=5%]</code></em></p><p><em>\*\*Note: not all DEXs and contract methods support trading tax tokens, so we will filter those that don't.</em> </p>                                                                                                                                                                                                                                                                                                          |
| destTokenDexTransferFee                        | string  | <p>If the destination token is a tax token, you should specify the tax amount in BPS. <br>Some tokens only charge tax when swapped in/out DEXs, not on ordinary transfers.</p><p><em>\*For example: for a token with a 5% tax, you should set it to 500 as</em><br><em><code>\[(500/10000)\*100=5%]</code></em></p><p><em>\*\*Note: not all DEXs and contract methods support trading tax tokens, so we will filter those that don't.</em> </p>                                                                                                                                                                                                                                                                                                       |
| version                                        | number  | To specify the protocol version. **Values:** 5 or 6.2 **Default**: 5                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ignoreBadUsdPrice                              | boolean | If tokens USD prices are not available, `Bad USD Price` error will be thrown. Use this param to skip this check. Default: `false`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| isSurplusToUser                                | boolean | <p>Specify if user should receive surplus instead of partner.<br>Default: <code>false</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| isDirectFeeTransfer                            | boolean | <p>Specify if fees should be sent directly to the partner instead of registering them on FeeClaimer.</p><p>Default: <code>false</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| isCapSurplus                                   | boolean | <p>Allows for capping the surplus at 1% maximum.</p><p>Default: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| takeSurplus                                    | boolean | <p>Allows to collect surplus. Works with <code>partnerAddress</code></p><p>Default: <code>false</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |

**Example:**&#x20;

Here’s an example of an integrator that used the swap function to request a price and generate a transaction.

{% tabs %}
{% tab title="200 Successful Price Response." %}

```
{
  "priceRoute": {
    "blockNumber": 20184108,
    "network": 1,
    "srcToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
    "srcDecimals": 6,
    "srcAmount": "1000000",
    "destToken": "0x6b175474e89094c44da98b954eedeac495271d0f",
    "destDecimals": 18,
    "destAmount": "997620341641628401",
    "bestRoute": [
      {
        "percent": 100,
        "swaps": [
          {
            "srcToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
            "srcDecimals": 6,
            "destToken": "0x6b175474e89094c44da98b954eedeac495271d0f",
            "destDecimals": 18,
            "swapExchanges": [
              {
                "exchange": "ShibaSwap",
                "srcAmount": "1000000",
                "destAmount": "997620341641628401",
                "percent": 100,
                "poolAddresses": [
                  "0x4610bA8d5D10FBa8C048A2051a0883CE04eaBAcE"
                ],
                "data": {
                  "router": "0xF9234CB08edb93c0d4a4d4c70cC3FfD070e78e07",
                  "path": [
                    "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
                    "0x6b175474e89094c44da98b954eedeac495271d0f"
                  ],
                  "factory": "0x115934131916C8b277DD010Ee02de363c09d037c",
                  "initCode": "0x65d1a3b1e46c6e4f1be1ad5f99ef14dc488ae0549dc97db9b30afe2241ce1c7a",
                  "feeFactor": 10000,
                  "pools": [
                    {
                      "address": "0x4610bA8d5D10FBa8C048A2051a0883CE04eaBAcE",
                      "fee": 30,
                      "direction": false
                    }
                  ],
                  "gasUSD": "5.515040"
                }
              }
            ]
          }
        ]
      }
    ],
    "gasCostUSD": "5.932529",
    "gasCost": "107570",
    "side": "SELL",
    "version": "6.2",
    "contractAddress": "0x6a000f20005980200259b80c5102003040001068",
    "tokenTransferProxy": "0x6a000f20005980200259b80c5102003040001068",
    "contractMethod": "swapExactAmountIn",
    "partnerFee": 0,
    "srcUSD": "1.0000000000",
    "destUSD": "0.9973641328",
    "partner": "anon",
    "maxImpactReached": false,
    "hmac": "39d19445379b69c115149340c5caaa05c898e840"
  },
  "txParams": {
    "from": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
    "to": "0x6a000f20005980200259b80c5102003040001068",
    "value": "0",
    "data": "0xe3ead59e0000000000000000000000005f0000d4780a00d2dce0a00004000800cb0e5041000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000000000f42400000000000000000000000000000000000000000000000000db4d11c67691ad50000000000000000000000000000000000000000000000000dd8426a4440caf10a8104c26c244959a1d46f205acc49520000000000000000000000000133fc2c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000160a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000006000240000ff00000300000000000000000000000000000000000000000000000000000000a9059cbb0000000000000000000000004610ba8d5d10fba8c048a2051a0883ce04eabace00000000000000000000000000000000000000000000000000000000000f42406a000f20005980200259b80c51020030400010680000008000240000ff0600030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000f4240000000000000000000004de54610ba8d5d10fba8c048a2051a0883ce04eabace",
    "gasPrice": "16000000000",
    "chainId": 1
  }
}
```

{% endtab %}

{% tab title="400 Price Error" %}

```
{
  "error": "computePrice Error
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
🧙Though **srcDecimals** and **destDecimals** are optional parameters it is highly recommended to add them while doing the pricing. This will allow you to get prices for all the tokens, including the ones which are also not listed by Velora.&#x20;
{% endhint %}

{% hint style="warning" %}
Swaps fees and Swap\&Transfer (where the receiver is not the same as the sender) don't work when `swapOnUniswap`, `swapOnUniswapFork`, `swapOnZeroXv2`, and `swapOnZeroXv4` etc. contract methods are used.&#x20;

If you would like to disable these methods you can do so by setting a whitelist for methods where Swap\&Transfer is supported`includeContractMethods=simpleSwap,multiSwap,megaSwap`
{% endhint %}

#### Most common error messages

The following is a list of the most common error messages of the `/swap` endpoint. Most are self-explanatory and can be self-solved,  but feel free to contact Velora Support using the chat in the bottom right corner of this page.

* `Missing response from pricing API` - failed to get a response from pricing API
* `Can not receive price route` - failed to receive price route from the pricing API response


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.velora.xyz/api/velora-api/velora-market-api/get-rate-for-a-token-pair-1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
