# Examples

{% hint style="warning" %}
The values and responses provided are solely for illustrative purposes and to aid in the understanding of requests and responses; actual values and responses may vary.
{% endhint %}

## 1. ExactIn swap: Get Transaction Data for swap from USDC to APT when fromTokenAmount is entered

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

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

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();

```

Below is the response for the above request

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

```json
// Succesful response
{
    "fromToken": {
        "address": "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b",
        "decimals": 6,
        "current_price": "0.99995023"
    },
    "toToken": {
        "address": "0xa",
        "decimals": 8,
        "current_price": "5.55701085"
    },
    "fromTokenAmount": "100",
    "fromTokenAmountUSD": "99.995023",
    "quotes": [
        {
            "toTokenAmount": "17.96724953",
            "priceImpact": "-0.15",
            "slippagePercentage": "1",
            "feeAmount": "0",
            "feeToken": {
                "tokenType": "0x1::aptos_coin::AptosCoin",
                "name": "Aptos Coin",
                "symbol": "APT",
                "decimals": 8
            },
            "minToTokenAmount": "17.78757703",
            "txData": {
                "function": "0x1c3206329806286fd2223647c9f9b130e66baeb6d7224a18c1f642ffe48f3b4c::panora_swap::router_entry",
                "type_arguments": [
                    "0x1::string::String",
                    "0x1::aptos_coin::AptosCoin",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::aptos_coin::AptosCoin"
                ],
                "arguments": [
                    null,
                    "0x1c3206329806286fd2223647c9f9b130e66baeb6d7224a18c1f642ffe48f3b4c",
                    1,
                    2,
                    [
                        3,
                        1,
                        0
                    ],
                    [
                        [
                            [
                                40
                            ],
                            [
                                40
                            ]
                        ],
                        [
                            [
                                44
                            ],
                            []
                        ],
                        [
                            [
                                23
                            ],
                            []
                        ]
                    ],
                    [
                        [
                            [
                                2
                            ],
                            [
                                2
                            ]
                        ],
                        [
                            [
                                0
                            ],
                            []
                        ],
                        [
                            [
                                0
                            ],
                            []
                        ]
                    ],
                    [
                        [
                            [
                                false
                            ],
                            [
                                false
                            ]
                        ],
                        [
                            [
                                true
                            ],
                            []
                        ],
                        [
                            [
                                false
                            ],
                            []
                        ]
                    ],
                    [
                        [
                            2,
                            2
                        ],
                        [
                            3,
                            4
                        ],
                        [
                            2,
                            4
                        ]
                    ],
                    [
                        [
                            [
                                "0xa928222429caf1924c944973c2cd9fc306ec41152ba4de27a001327021a4dff7"
                            ],
                            [
                                "0xa928222429caf1924c944973c2cd9fc306ec41152ba4de27a001327021a4dff7"
                            ]
                        ],
                        [
                            [
                                "0x18269b1090d668fbbc01902fa6a5ac6e75565d61860ddae636ac89741c883cbc"
                            ],
                            [
                                "0x0"
                            ]
                        ],
                        [
                            [
                                "0x0"
                            ],
                            [
                                "0x0"
                            ]
                        ]
                    ],
                    [
                        [
                            "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b",
                            "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b"
                        ],
                        [
                            "0xa",
                            "0x2ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12"
                        ],
                        [
                            "0x357b0b74bc833e95a115ad22604854d6b0fca151cecd94111770e5d6ffc9dc2b",
                            "0x2ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12"
                        ]
                    ],
                    [
                        [
                            "0xa",
                            "0xa"
                        ],
                        [
                            "0x357b0b74bc833e95a115ad22604854d6b0fca151cecd94111770e5d6ffc9dc2b",
                            "0x2ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12"
                        ],
                        [
                            "0xa",
                            "0x2ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12"
                        ]
                    ],
                    null,
                    [
                        [
                            [
                                10000
                            ],
                            [
                                10000
                            ]
                        ],
                        [
                            [
                                10000
                            ],
                            []
                        ],
                        [
                            [
                                10000
                            ],
                            []
                        ]
                    ],
                    [
                        [
                            [
                                4,
                                135,
                                1,
                                0,
                                0,
                                0,
                                0,
                                0
                            ]
                        ]
                    ],
                    "0xa",
                    [
                        90000000,
                        10000000
                    ],
                    1778757703,
                    10000000000000000,
                    "0x90c588d22ee7dd42d55d73e63b50f0f9dfe7113952374040ae8c4adfd137176d"
                ]
            },
            "toTokenAmountUSD": "99.84420058",
            "feeAmountUSD": "0"
        }
    ]
}
```

{% endtab %}

{% tab title="400" %}

```json
//Bad Request
{
    "statusCode": 400,
    "message": "<Error Message>",
    "status": "fail"
}
```

{% endtab %}

{% tab title="401" %}

```json
//Unauthorized
{
    "statusCode": 401,
    "message": "<Error Message>",
    "status": "fail"
}
```

{% endtab %}

{% tab title="404" %}

```json
//Not Found
{
    "statusCode": 404,
    "message": "<Error Message>",
    "status": "fail"
}
```

{% endtab %}

{% tab title="429" %}

```json
//Too Many Request
{
    "statusCode": 429,
    "message": "<Error Message>",
    "status": "fail"
}
```

{% endtab %}

{% tab title="500" %}

```json
// Internal Server Error
{
    "statusCode": 500,
    "message": "internal server error",
    "status": "fail"
}
```

{% endtab %}
{% endtabs %}

This response can be sent to Aptos chain with the required signatures to execute the transaction.&#x20;

## 2. ExactOut swap: Get transaction data for swap from USDC to APT when toTokenAmount is entered

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

<pre class="language-javascript"><code class="lang-javascript"><strong>const end_point = 'https://api.panora.exchange/swap'
</strong>const query = {  
    fromTokenAddress: "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b",
    toTokenAddress: "0xa",
    toTokenAmount: 10.5,
    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();


</code></pre>

{% hint style="info" %}
Note:  toTokenAmount here is amount (without Token Decimals) that the user desires to receive after the swap is executed
{% endhint %}

Below is the response for the above request

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

```json
// Successful response
{
    "fromToken": {
        "address": "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b",
        "decimals": 6,
        "current_price": "0.99994999"
    },
    "toToken": {
        "address": "0xa",
        "decimals": 8,
        "current_price": "5.55088748"
    },
    "toTokenAmount": "10.5",
    "toTokenAmountUSD": "58.28431854",
    "quotes": [
        {
            "fromTokenAmount": "58.292962",
            "maxFromTokenAmount": "58.875892",
            "slippagePercentage": "1",
            "feeAmount": "0",
            "feeToken": {
                "tokenType": "0x1::aptos_coin::AptosCoin",
                "name": "Aptos Coin",
                "symbol": "APT",
                "decimals": 8
            },
            "priceImpact": "-0.01",
            "txData": {
                "function": "0x1c3206329806286fd2223647c9f9b130e66baeb6d7224a18c1f642ffe48f3b4c::panora_swap::router_entry",
                "type_arguments": [
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::aptos_coin::AptosCoin"
                ],
                "arguments": [
                    null,
                    "0x1c3206329806286fd2223647c9f9b130e66baeb6d7224a18c1f642ffe48f3b4c",
                    2,
                    1,
                    [
                        1,
                        0,
                        1
                    ],
                    [
                        [
                            [
                                44
                            ],
                            [
                                44
                            ],
                            [
                                44
                            ]
                        ],
                        [
                            []
                        ],
                        [
                            []
                        ]
                    ],
                    [
                        [
                            [
                                0
                            ],
                            [
                                0
                            ],
                            [
                                0
                            ]
                        ],
                        [
                            []
                        ],
                        [
                            []
                        ]
                    ],
                    [
                        [
                            [
                                false
                            ],
                            [
                                true
                            ],
                            [
                                true
                            ]
                        ],
                        [
                            []
                        ],
                        [
                            []
                        ]
                    ],
                    [
                        [
                            2,
                            3,
                            3
                        ],
                        [
                            4
                        ],
                        [
                            4
                        ]
                    ],
                    [
                        [
                            [
                                "0x925660b8618394809f89f8002e2926600c775221f43bf1919782b297a79400d8"
                            ],
                            [
                                "0x925660b8618394809f89f8002e2926600c775221f43bf1919782b297a79400d8"
                            ],
                            [
                                "0x925660b8618394809f89f8002e2926600c775221f43bf1919782b297a79400d8"
                            ]
                        ],
                        [
                            [
                                "0x0"
                            ]
                        ],
                        [
                            [
                                "0x0"
                            ]
                        ]
                    ],
                    [
                        [
                            "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b",
                            "0xa",
                            "0xa"
                        ],
                        [
                            "0x2ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12"
                        ],
                        [
                            "0x2ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12"
                        ]
                    ],
                    [
                        [
                            "0xa",
                            "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b",
                            "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b"
                        ],
                        [
                            "0x2ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12"
                        ],
                        [
                            "0x2ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12"
                        ]
                    ],
                    null,
                    [
                        [
                            [
                                10000
                            ],
                            [
                                10000
                            ],
                            [
                                10000
                            ]
                        ],
                        [
                            []
                        ],
                        [
                            []
                        ]
                    ],
                    [
                        [
                            [
                                4,
                                135,
                                1,
                                0,
                                0,
                                0,
                                0,
                                0
                            ]
                        ]
                    ],
                    "0xa",
                    [
                        58875892
                    ],
                    1050000000,
                    10000000000000000,
                    "0x90c588d22ee7dd42d55d73e63b50f0f9dfe7113952374040ae8c4adfd137176d"
                ]
            },
            "fromTokenAmountUSD": "58.29004677"
        }
    ]
}
```

{% endtab %}

{% tab title="400" %}

```json
//Bad Request
{
    "statusCode": 400,
    "message": "<Error Message>",
    "status": "fail"
}
```

{% endtab %}

{% tab title="401" %}

```json
//Bad Request
{
    "statusCode": 401,
    "message": "<Error Message>",
    "status": "fail"
}
```

{% endtab %}

{% tab title="404" %}

```json
//Not Found
{
    "statusCode": 404,
    "message": "<Error Message>",
    "status": "fail"
}
```

{% endtab %}

{% tab title="429" %}

```json
//Too Many Request
{
    "statusCode": 429,
    "message": "<Error Message>",
    "status": "fail"
}
```

{% endtab %}

{% tab title="500" %}

```json
// Internal Server Error
{
    "statusCode": 500,
    "message": "internal server error",
    "status": "fail"
}
```

{% endtab %}
{% endtabs %}

This response can be sent to Aptos chain with the required signatures to execute the transaction.&#x20;

## 3. ExactIn swap: Get Quote Data for swap from USDC to APT when fromTokenAmount is entered

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

```javascript
const end_point = 'https://api.panora.exchange/swap/quote'
const query = {
    fromTokenAddress: "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b",
    toTokenAddress: "0xa",
    fromTokenAmount: 100,
};

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: 'GET',
        headers: headers
    })
).json();

```

Below is the response for the above request

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

```json
// Successful response
{
    "fromToken": {
        "address": "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b",
        "decimals": 6,
        "current_price": "0.99995007"
    },
    "toToken": {
        "address": "0xa",
        "decimals": 8,
        "current_price": "5.54399864"
    },
    "fromTokenAmount": "100",
    "fromTokenAmountUSD": "99.995007",
    "quotes": [
        {
            "toTokenAmount": "18.03063233",
            "priceImpact": "-0.03",
            "slippagePercentage": "1",
            "feeAmount": "0",
            "feeToken": {
                "tokenType": "0x1::aptos_coin::AptosCoin",
                "name": "Aptos Coin",
                "symbol": "APT",
                "decimals": 8
            },
            "minToTokenAmount": "17.850326",
            "toTokenAmountUSD": "99.96180112",
            "feeAmountUSD": "0"
        }
    ]
}
```

{% endtab %}

{% tab title="400" %}

```json
//Bad Request
{
    "statusCode": 400,
    "message": "<Error Message>",
    "status": "fail"
}
```

{% endtab %}

{% tab title="401" %}

```json
//UnAuthourized
{
    "statusCode": 401,
    "message": "<Error Message>",
    "status": "fail"
}
```

{% endtab %}

{% tab title="404" %}

```json
//Not Found
{
    "statusCode": 404,
    "message": "<Error Message>",
    "status": "fail"
}
```

{% endtab %}

{% tab title="429" %}

```json
//Too Many Request
{
    "statusCode": 429,
    "message": "<Error Message>",
    "status": "fail"
}
```

{% endtab %}

{% tab title="500" %}

```json
//Not Found
{
    "statusCode": 500,
    "message": "internal server error",
    "status": "fail"
}
```

{% endtab %}
{% endtabs %}

## 4. ExactOut swap: Get Quote data for swap from USDC to APT when toTokenAmount is entered

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

```javascript
const query = {  
    fromTokenAddress: "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b",
    toTokenAddress: "0xa",
    toTokenAmount: 10.5
};

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: 'GET',
        headers: headers
    })
).json();
```

Below is the response for the request.

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

```json
// Successful response
{
    "fromToken": {
        "address": "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b",
        "decimals": 6,
        "current_price": "0.99995009"
    },
    "toToken": {
        "address": "0xa",
        "decimals": 8,
        "current_price": "5.53744039"
    },
    "toTokenAmount": "10.5",
    "toTokenAmountUSD": "58.1431241",
    "quotes": [
        {
            "fromTokenAmount": "58.172607",
            "maxFromTokenAmount": "58.754333",
            "slippagePercentage": "1",
            "feeAmount": "0",
            "feeToken": {
                "tokenType": "0x1::aptos_coin::AptosCoin",
                "name": "Aptos Coin",
                "symbol": "APT",
                "decimals": 8
            },
            "priceImpact": "-0.05",
            "fromTokenAmountUSD": "58.16970361"
        }
    ]
}
```

{% endtab %}

{% tab title="400" %}

```json
//Bad Request
{
    "statusCode": 400,
    "message": "<Error Message>",
    "status": "fail"
}
```

{% endtab %}

{% tab title="401" %}

```json
//UnAuthorized
{
    "statusCode": 401,
    "message": "<Error Message>",
    "status": "fail"
}
```

{% endtab %}

{% tab title="404" %}

```json
//Not Found
{
    "statusCode": 404,
    "message": "<Error Message>",
    "status": "fail"
}
```

{% endtab %}

{% tab title="429" %}

```json
//Too many requests
{
    "statusCode": 429,
    "message": "<Error Message>",
    "status": "fail"
}
```

{% endtab %}

{% tab title="500" %}

```json
//Internal Server Error
{
    "statusCode": 500,
    "message": "<Error Message>",
    "status": "fail"
}
```

{% endtab %}
{% endtabs %}


---

# 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/api_old/examples.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.
