Panora
  • 👋Welcome to Panora
  • 🌐Official Links
  • PRODUCT SUITE
    • 💱Panora Swap
    • 📊Panora Trade
  • Developer
    • 💻Swap Widget
      • Install Widget
      • Widget Configuration
      • Theme Customization
      • Widget Controls
      • Guide
    • 🤖Swap API & SDK
      • 💻Swap API
        • Examples
      • 🖥️Swap SDK
      • 💦Supported Sources
    • 🎞️Swap iframe
    • 🪙Token List
      • 📔How to Add Your Token to the Panora Token List
    • 💲Token Prices
  • PARTNERSHIPS
    • 🤝Become Our Partner
    • 🏢Media & Brand Kit
  • FAQs
    • ❓Panora Help
  • LEGAL
    • 🗒️Legal Disclaimer
    • 🔓Brand & Logos
    • 📏Terms of Use
Powered by GitBook
On this page
  • 1. ExactIn swap: Get Transaction Data for swap from USDC to APT when fromTokenAmount is entered
  • 2. ExactOut swap: Get transaction data for swap from USDC to APT when toTokenAmount is entered
  • 3. ExactIn swap: Get Quote Data for swap from USDC to APT when fromTokenAmount is entered
  • 4. ExactOut swap: Get Quote data for swap from lzUSDC to APT when toTokenAmount is entered
  1. Developer
  2. Swap API & SDK
  3. Swap API

Examples

Here you will some of the examples of the API integration

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.

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

POST https://api.panora.exchange/swap

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

// 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"
        }
    ]
}
//Bad Request
{
    "statusCode": 400,
    "message": "<Error Message>",
    "status": "fail"
}
//Unauthorized
{
    "statusCode": 401,
    "message": "<Error Message>",
    "status": "fail"
}
//Not Found
{
    "statusCode": 404,
    "message": "<Error Message>",
    "status": "fail"
}
//Too Many Request
{
    "statusCode": 429,
    "message": "<Error Message>",
    "status": "fail"
}
// Internal Server Error
{
    "statusCode": 500,
    "message": "internal server error",
    "status": "fail"
}

This response can be sent to Aptos chain with the required signatures to execute the transaction.

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

POST https://api.panora.exchange/swap

const end_point = 'https://api.panora.exchange/swap'
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();

Note: toTokenAmount here is amount (without Token Decimals) that the user desires to receive after the swap is executed

Below is the response for the above request

// 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"
        }
    ]
}
//Bad Request
{
    "statusCode": 400,
    "message": "<Error Message>",
    "status": "fail"
}
//Bad Request
{
    "statusCode": 401,
    "message": "<Error Message>",
    "status": "fail"
}
//Not Found
{
    "statusCode": 404,
    "message": "<Error Message>",
    "status": "fail"
}
//Too Many Request
{
    "statusCode": 429,
    "message": "<Error Message>",
    "status": "fail"
}
// Internal Server Error
{
    "statusCode": 500,
    "message": "internal server error",
    "status": "fail"
}

This response can be sent to Aptos chain with the required signatures to execute the transaction.

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

GET https://api.panora.exchange/swap/quote

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

// 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"
        }
    ]
}
//Bad Request
{
    "statusCode": 400,
    "message": "<Error Message>",
    "status": "fail"
}
//UnAuthourized
{
    "statusCode": 401,
    "message": "<Error Message>",
    "status": "fail"
}
//Not Found
{
    "statusCode": 404,
    "message": "<Error Message>",
    "status": "fail"
}
//Too Many Request
{
    "statusCode": 429,
    "message": "<Error Message>",
    "status": "fail"
}
//Not Found
{
    "statusCode": 500,
    "message": "internal server error",
    "status": "fail"
}

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

GET https://api.panora.exchange/swap/quote

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.

// 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"
        }
    ]
}
//Bad Request
{
    "statusCode": 400,
    "message": "<Error Message>",
    "status": "fail"
}
//UnAuthorized
{
    "statusCode": 401,
    "message": "<Error Message>",
    "status": "fail"
}
//Not Found
{
    "statusCode": 404,
    "message": "<Error Message>",
    "status": "fail"
}
//Too many requests
{
    "statusCode": 429,
    "message": "<Error Message>",
    "status": "fail"
}
//Internal Server Error
{
    "statusCode": 500,
    "message": "<Error Message>",
    "status": "fail"
}
PreviousSwap APINextSwap SDK

Last updated 15 days ago

🤖
💻