# API

### Usage

Use the below endpoint to get quotes for the swap (also contains transaction data that can be sent to wallet adapter directly or used to build, sign and submit)

<mark style="color:green;">`POST`</mark> `https://api.panora.exchange/swap`

#### Headers

* **Public API Key**:

  ```
  a4^KV_EaTf4MW#ZdvgGKX#HUD^3IFEAOV_kzpIE^3BQGA8pDnrkT7JcIy#HNlLGi
  ```

  ***Note:** This API key's limits should be sufficient for most use cases. Protocols within the Aptos ecosystem with specific requirements or customization may submit a ticket on Discord.*&#x20;

<table><thead><tr><th width="123">Name</th><th width="135">Value</th><th>Description</th></tr></thead><tbody><tr><td>x-api-key</td><td>Your API Key</td><td>Use the public API key or enter the API key provided by Panora</td></tr></tbody></table>

### Query Parameters

{% hint style="info" %}
**Note**: Panora's APIs supports the following.

1. **ExactIn Swap:** When fromTokenAmount is entered, the endpoint returns the maximum  toTokenAmount that will be received. Example: If the fromToken is APT, fromTokenAmount is 10.5 and toToken is USDC, then the toTokenAmount response is the maximum USDC a user would receive for swapping from 10.5 APT.
2. **ExactOut Swap:** When toTokenAmount is entered, the endpoint returns the minimum fromTokenAmount that has to be paid. Example: If the toToken is USDC, toTokenAmount is 100 and fromToken is APT, then the fromTokenAmount response is the minimum APT a user would pay for swapping to 100 USDC.
   {% endhint %}

<table><thead><tr><th width="194">Parameter</th><th width="120.00006103515625">Required</th><th width="90">Type</th><th>Description</th></tr></thead><tbody><tr><td>chainId</td><td>no</td><td>number</td><td><p>ID for the chain for which the endpoint is being invoked. <br></p><p>Note: Default chainID is 1 for Aptos Mainnet</p></td></tr><tr><td>fromTokenAddress</td><td>yes</td><td>string</td><td>Address of the token being swapped from<br><br>Example: If you want to swap 10.5 APT to USDC, then fromTokenAddress is <code>0xa</code></td></tr><tr><td>toTokenAddress</td><td>yes</td><td>string</td><td>Address of the token being swapped to<br><br>Example: If you want to swap 10.5 APT to USDC, then toTokenAddress is <code>0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b</code></td></tr><tr><td>fromTokenAmount</td><td><a data-footnote-ref href="#user-content-fn-1">yes</a><mark style="color:red;">*</mark></td><td>number</td><td>Amount of the token being swapped from. Please set the amount without Token decimals<br><br>Example: If you want to swap 10.5 APT to USDC, then fromTokenAmount is 10.5</td></tr><tr><td>toTokenAmount</td><td>yes<mark style="color:red;">*</mark></td><td>number</td><td><p>Amount of the token being swapped to. Please set the amount without Token decimals </p><p></p><p>Example: If you want to swap from APT to 100 USDC, then toTokenAmount is 100</p></td></tr><tr><td>toWalletAddress</td><td>yes</td><td>string</td><td>Address of the wallet to which the swapped tokens will be sent</td></tr><tr><td>slippagePercentage</td><td>no</td><td>number</td><td><p>Slippage tolerance as 'auto' (which lets Panora choose the optimal slippage for the transaction, up to a maximum of 5%) or a percentage value.<br><br>Example: For 3% slippage tolerance, set the value as 3. This can be set as 0.1, 0.5, 1.0 or any custom slippage percentage between 0 and 100.</p><p><br>Note: If nothing is entered, slippage tolerance will be set to auto by default. If a numeric value is entered, anything after two decimal places will be truncated.</p></td></tr><tr><td>integratorFeePercentage</td><td>no</td><td>number</td><td><p>Integrator fee as a percentage value<br><br>Example: For 2% integrator fee, set the value as 2. This can be set as 0.1, 0.5, 1.0 or any custom integrator fee between 0 and 2.</p><p><br>Note: Fee sharing applicable. Fee amount is auto-swapped to APT, whenever possible. If nothing is entered, integrator fee will be set to 0 by default. If a numeric value is entered, anything after two decimal places will be truncated.</p></td></tr><tr><td>integratorFeeAddress</td><td>no</td><td>string</td><td><p>Wallet Address where integrators want to receive their fee share. The fee share is settled immediately with the swap transaction to the provided wallet address.</p><p></p><p>Note: Ensure it starts with 0x followed by 64 characters</p></td></tr><tr><td>includeSources</td><td>no</td><td>string</td><td><p>List of liquidity sources to be included for route calculation. </p><p></p><p>Example: Hyperion, ThalaSwapV2</p><p></p><p>Note: If nothing is entered, all available sources are included by default. Check entire list <a href="https://docs.panora.exchange/developer/swap/sources">here</a>.</p></td></tr><tr><td>excludeSources</td><td>no</td><td>string</td><td><p>List of liquidity sources to be excluded from the route. </p><p></p><p>Example: SushiSwap</p><p></p><p>Note: If nothing is entered, none of the sources will be excluded by default. Check entire list <a href="https://docs.panora.exchange/developer/swap/sources">here</a>.</p></td></tr><tr><td>includePools</td><td>no</td><td>string</td><td><p>List of pool addresses to be included for route calculation. </p><p></p><p>Example: 0xd3894aca06d5f42b27c89e6f448114b3ed6a1ba07f992a58b2126c71dd83c127, 0xc3c4cbb3efcd3ec1b6679dc0ed45851486920dba0e86e612e80a79041a6cf1a3</p><p></p><p>Note: If nothing is entered, all available pools are included by default. Max 10 pool addresses are supported. Coin standard DEX pools with comma ( , ) within the pool address would get skipped</p></td></tr><tr><td>maxHops</td><td>no</td><td>string</td><td>Set a value between 1 and 5, or max, to limit the maximum number of hops allowed in each split section of the route (default: max)</td></tr><tr><td>disableSplits</td><td>no</td><td>boolean</td><td>Set to true to disable splitting pools across the entire route (default: false)</td></tr><tr><td>onlyDirectRoutes</td><td>no</td><td>boolean</td><td>Set to true to restrict to direct routes without intermediate hops or splits.<br>Default is false.</td></tr></tbody></table>

{% hint style="warning" %} <mark style="color:red;">\*</mark>Please send either fromTokenAmount or toTokenAmount at a time.
{% endhint %}

### Request Example

{% tabs %}
{% tab title="Javascript" %}

```javascript
//CALL THE BELOW FUNCTION WITH THE ASYNC
const end_point = 'https://api.panora.exchange/swap'
const query = {
    fromTokenAddress:"0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b"
    toTokenAddress:"0xa"
    fromTokenAmount:100
    toWalletAddress:"0x1c3206329806286fd2223647c9f9b130e66baeb6d7224a18c1f642ffe48f3b4c"
};

const headers = {
    "x-api-key": "Your API key"
};

const queryString = new URLSearchParams(query).toString();
const url = `${end_point}?${queryString}`;

const response = await (
    await fetch(url, {
        method: 'POST',
        headers: headers
    })
).json();
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

end_point = 'https://api.panora.exchange/swap'
query = {
    'fromTokenAddress': '0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b',
    'toTokenAddress':'0xa',
    'fromTokenAmount': '100',
    'toWalletAddress':'0x1c3206329806286fd2223647c9f9b130e66baeb6d7224a18c1f642ffe48f3b4c'
}

headers = {
    'x-api-key': 'Your API key',
}

url = f"{end_point}?{'&'.join([f'{key}={value}' for key, value in query.items()])}"

response = requests.post(url, headers=headers)

print(response.json())

```

{% endtab %}

{% tab title="Go" %}

```go

import (
    "fmt"
    "net/http"
    "io/ioutil"
    "net/url"
)

func main() {
    endPoint := "https://api.panora.exchange/swap"
    query := url.Values{
        "fromTokenAddress": {"0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b"},
        "toTokenAddress":{"0xa"},
        "fromTokenAmount": {"100"},
        "toWalletAddress":{"0x1c3206329806286fd2223647c9f9b130e66baeb6d7224a18c1f642ffe48f3b4c"}
    }

    headers := map[string]string{
        "x-api-key": "Your API key",
    }

    url := endPoint + "?" + query.Encode()

    req, err := http.NewRequest("POST", url, nil)
    if err != nil {
        fmt.Println("Error creating request:", err)
        return
    }

    for key, value := range headers {
        req.Header.Set(key, value)
    }

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        fmt.Println("Error sending request:", err)
        return
    }
    defer resp.Body.Close()

    body, err := ioutil.ReadAll(resp.Body)
    if err != nil {
        fmt.Println("Error reading response:", err)
        return
    }

    fmt.Println(string(body))
}

```

{% endtab %}

{% tab title="Curl" %}

```
// Copy and paste the below command in your terminal

curl -X POST \
  'https://api.panora.exchange/swap?fromTokenAddress=0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b&toTokenAddress=0xa&fromTokenAmount=100&toWalletAddress=0x1c3206329806286fd2223647c9f9b130e66baeb6d7224a18c1f642ffe48f3b4c' \
  -H 'x-api-key: Your API key'
```

{% endtab %}
{% endtabs %}

### Response

#### Scenario 1: For ExactIn Swap where fromTokenAmount is entered (instead of toTokenAmount), the endpoint returns the maximum toTokenAmount

<table><thead><tr><th width="223">Name</th><th width="139">Type</th><th>Description</th></tr></thead><tbody><tr><td>fromToken</td><td>object</td><td>An object containing the details of the fromToken, which includes <code>address</code> , <code>decimals</code> and <code>current_price</code></td></tr><tr><td>toToken</td><td>object</td><td>An object containing the details of the toToken, which includes <code>address</code> , <code>decimals</code> and <code>current_price</code> </td></tr><tr><td>feeToken</td><td>object</td><td>An object containing the details of the feeToken, which includes <code>address</code>, <code>name</code>, <code>symbol</code>, <code>decimals and current_price</code> </td></tr><tr><td>fromTokenAmount</td><td>string</td><td>Amount of token being swapped from<br><br><strong>Note</strong>: Amount is without Token decimals</td></tr><tr><td>fromTokenAmountUSD</td><td>string</td><td>USD equivalent of fromTokenAmount<br><br><strong>Note</strong>: Will be null for those tokens whose usd price is not available from external price feeds </td></tr><tr><td>quotes</td><td>array</td><td><p>An object (within an array) containing the swap details.The object consists of:</p><p><br><code>toTokenAmount</code>:  Amount of the token (without Token decimals) being swapped to. </p><p><br><code>priceImpact</code>: percentage difference between USD price of fromTokenAmount and toTokenAmount. Will be null if either fromTokenAmountUSD or toTokenAmountUSD is null</p><p></p><p><code>slippagePercentage</code>: Percentage of slippage tolerance</p><p><br><code>feeTokenAmount</code>: Platform fee for the transaction</p><p></p><p><code>minToTokenAmount</code>:  Minimum amount of token (without Token decimals) user would receive after reducing slippage. </p><p><br><code>txData</code>: Details of the transaction for the swap</p><p></p><p><code>toTokenAmountUSD:</code> USD equivalent of toTokenAmount. Will be null for those tokens whose USD price is not available from external price feeds<br><br>Note: Values are of type string</p></td></tr><tr><td>status Code</td><td></td><td><p><code>200</code>:  Successful response<br><code>400</code>: Bad Request</p><p><code>401</code>: Unauthorized (in case no/wrong API key is passed)</p><p><code>404</code>: Not Found</p><p><code>429</code>: Too  many requests (in case of rate limit breach)<br><code>500</code>: Internal Server Error </p></td></tr></tbody></table>

#### Scenario 2: For ExactOut Swap where toTokenAmount is entered (instead of fromTokenAmount), the endpoint returns the minimum toTokenAmount

<table><thead><tr><th width="210">Name</th><th width="126">Type</th><th>Description</th></tr></thead><tbody><tr><td>fromToken</td><td>object</td><td>An object containing the details of the fromToken, which includes <code>address</code> , <code>decimals</code> and <code>current_price</code></td></tr><tr><td>toToken</td><td>object</td><td>An object containing the details of the toToken, which includes <code>address</code> , <code>decimals</code> and <code>current_price</code> </td></tr><tr><td>feeToken</td><td>object</td><td>An object containing the details of the feeToken, which includes <code>address</code>, <code>name</code>, <code>symbol</code>, <code>decimals and current_price</code></td></tr><tr><td>toTokenAmount</td><td>string</td><td>Amount of token user desires to get after the swap<br><br><strong>Note</strong>: Amount is without Token decimals</td></tr><tr><td>toTokenAmountUSD</td><td>string</td><td>USD equivalent of toTokenAmount. <br><br><strong>Note</strong>: Will be null for those tokens whose usd price is not available from external price feeds </td></tr><tr><td>quotes</td><td>array</td><td><p>An object (within an array) containing the swap details.The object consists of:</p><p><br><code>fromTokenAmount</code>:  Amount of tokens (without Token decimals) user needs to pay for the swap<br><br><code>maxFromTokenAmount:</code> Maximum amount of tokens (without Token decimals) user would need to pay after adding slippage.</p><p></p><p><code>slippagePercentage</code>:  Percentage of slippage tolerance</p><p><br><code>feeTokenAmount</code>:  Platform fee for the transaction<br><br><code>priceImpact</code>:  percentage difference between USD price of fromTokenAmount and toTokenAmount. Will be null if either fromTokenAmountUSD or toTokenAmountUSD is null </p><p><br><code>txData</code>: Details of the transaction for the swap<br><br><code>fromTokenAmountUSD:</code> USD equivalent of fromTokenAmount. Will be null for those tokens whose usd price is not available from external price feeds</p><p></p><p>Note: Values are of type string </p></td></tr><tr><td>status code</td><td></td><td><p><code>200</code>:  Successful response<br><code>400</code>: Bad Request</p><p><code>401</code>: Unauthorized (in case no/wrong API key is passed)</p><p><code>404</code>: Not Found</p><p><code>429</code>: Too  many requests (in case of rate limit breach)<br><code>500</code>: Internal Server Error </p></td></tr></tbody></table>

[^1]:


---

# 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://docs.panora.exchange/developer/swap/api.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.
