# Failure to fetch $SLI price from ICPSwap into a webpage

**URL:** <https://forum.dfinity.org/t/failure-to-fetch-sli-price-from-icpswap-into-a-webpage/24051>\
**Category:** Developers\
**Tags:** Functional-Programming, agent, JavaScript\
**Created:** [October 28, 2023, 2:53am UTC](https://forum.dfinity.org/t/failure-to-fetch-sli-price-from-icpswap-into-a-webpage/24051 "2023-10-28T02:53:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Slice\_Info](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/slice_info/32/11977_2.png) [@Slice\_Info](https://forum.dfinity.org/u/Slice_Info)\
**Post date:** [October 28, 2023, 2:53am UTC](https://forum.dfinity.org/t/failure-to-fetch-sli-price-from-icpswap-into-a-webpage/24051/1 "2023-10-28T02:53:04Z")

</div>

I’m trying to fetch the price of $SLI from ICPSwap into a webpage. Here is a Javascript code that isn’t working as expected. Is there anything I’m doing wrong? Please advice:

// Import the required dependencies  
import { Principal } from “@dfinity/principal”;  
import { Actor, HttpAgent } from ‘@dfinity/agent’;  
import fetch from ‘isomorphic-fetch’;

async function getPrice() {  
const host = “[https://ic0.io](https://ic0.io)”;  
const agent = new HttpAgent({ fetch, host });  
const canisterId = ‘yr4hc-viaaa-aaaag-qcirq-cai’; // ICPSwap canister ID

const actor = Actor.createActor(canisterId, {  
agent,  
canisterId: Principal.fromText(canisterId),  
});

try {  
const operator = ‘yr4hc-viaaa-aaaag-qcirq-cai’;  
const amountIn = ‘100000000’;  
const zeroForOne = false;  
const amountOutMinimum = ‘0’;

```
const request = { operator, amountIn, zeroForOne, amountOutMinimum };
const quoteResponse = await actor.quote(request);

if (quoteResponse.ok !== null) {
  console.log(`price: ${quoteResponse.ok}`);
} else {
  console.log('Error: Failed to get price');
}

```

} catch (error) {  
console.log(`Error: ${error}`);  
}  
}

window.addEventListener(‘load’, getPrice);

---

<div class="post-metadata">

**Author:** ![ICPSwap](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/icpswap/32/11193_2.png) [@ICPSwap](https://forum.dfinity.org/u/ICPSwap)\
**Post date:** [October 28, 2023, 1:39pm UTC](https://forum.dfinity.org/t/failure-to-fetch-sli-price-from-icpswap-into-a-webpage/24051/2 "2023-10-28T13:39:48Z")

</div>

Hello, sir.

Do you have any error messages when running the code?

And what specific outcome are you aiming to achieve?

If it’s convenient for you, could you please record a video of the code execution and the error messages and send it to us at “[contact@icpswap.org](mailto:contact@icpswap.org)”? Let us see how we can help you!

Thank you.

---

<div class="post-metadata">

**Author:** ![Slice\_Info](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/slice_info/32/11977_2.png) [@Slice\_Info](https://forum.dfinity.org/u/Slice_Info)\
**Post date:** [October 29, 2023, 12:56am UTC](https://forum.dfinity.org/t/failure-to-fetch-sli-price-from-icpswap-into-a-webpage/24051/3 "2023-10-29T00:56:06Z")

</div>

I appreciate your response. I aim pull the number of ICPs required per slice or the number of slices required per ICP and proceed display on page. I thought I was missing some dependencies, that’s why i posted here. I can get from from Internet Computer dashboard using pair ID. However, the code presented doesn’t seem to fetch price on webpage. I’ll contact your team as suggested. Thank you.

---

<div class="post-metadata">

**Author:** ![let4be](https://avatars.discourse-cdn.com/v4/letter/l/ecc23a/32.png) [@let4be](https://forum.dfinity.org/u/let4be)\
**Post date:** [October 29, 2023, 10:23am UTC](https://forum.dfinity.org/t/failure-to-fetch-sli-price-from-icpswap-into-a-webpage/24051/4 "2023-10-29T10:23:20Z")

</div>

Are there any docs on the icpswap interfaces?  
Like canister IDs and a short description what various queries/update calls do

---

<div class="post-metadata">

**Author:** ![ICPSwap](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/icpswap/32/11193_2.png) [@ICPSwap](https://forum.dfinity.org/u/ICPSwap)\
**Post date:** [October 30, 2023, 1:42pm UTC](https://forum.dfinity.org/t/failure-to-fetch-sli-price-from-icpswap-into-a-webpage/24051/5 "2023-10-30T13:42:53Z")

</div>

This is our API interface, and the API documentation is currently quite basic. We will send you the updated documentation once we have it finalized. Thank you.  
[https://uvevg-iyaaa-aaaak-ac27q-cai.raw.ic0.app/tickers](https://uvevg-iyaaa-aaaak-ac27q-cai.raw.ic0.app/tickers)

---

<div class="post-metadata">

**Author:** ![ICPSwap](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/icpswap/32/11193_2.png) [@ICPSwap](https://forum.dfinity.org/u/ICPSwap)\
**Post date:** [November 1, 2023, 1:03pm UTC](https://forum.dfinity.org/t/failure-to-fetch-sli-price-from-icpswap-into-a-webpage/24051/6 "2023-11-01T13:03:55Z")

</div>

Sir, @let4be Here is a basic API document. Please see if it can address your initial requirements.

````auto
## Swap Pool Info

Url: GET https://uvevg-iyaaa-aaaak-ac27q-cai.raw.ic0.app/tickers

Response: 

```json
[
   {
        "ticker_id":"xmiu5-jqaaa-aaaag-qbz7q-cai",
        "ticker_name":"ckBTC_ICP",
        "base_id":"mxzaz-hqaaa-aaaar-qaada-cai",
        "base_currency":"ckBTC",
        "target_id":"mxzaz-hqaaa-aaaar-qaada-cai",
        "target_currency":"ICP",
        "last_price":"0.000116",
        "base_volume":"211198.622355",
        "target_volume":"128359.964731"
    },
    {
        "ticker_id":"nm7k6-wyaaa-aaaag-qcasa-cai",
        "ticker_name":"CHAT_ckBTC",
        "base_id":"2ouva-viaaa-aaaaq-aaamq-cai",
        "base_currency":"CHAT",
        "target_id":"2ouva-viaaa-aaaaq-aaamq-cai",
        "target_currency":"ckBTC",
        "last_price":"149164.263992",
        "base_volume":"636.387938",
        "target_volume":"327.550608"
    }
]

````

| Name | Description |
| --- | --- |
| ticker\_id | swap pool id |
| ticker\_name | swap pool name |
| base\_id | token0 id |
| base\_currency | token0 symbol |
| target\_id | token1 id |
| target\_currency | token1 symbol |
| last\_price | last price of the pool |
| base\_volume | token0 total volume |
| target\_volume | token1 total volume |

```auto

```

---

<div class="post-metadata">

**Author:** ![let4be](https://avatars.discourse-cdn.com/v4/letter/l/ecc23a/32.png) [@let4be](https://forum.dfinity.org/u/let4be)\
**Post date:** [December 26, 2023, 9:45pm UTC](https://forum.dfinity.org/t/failure-to-fetch-sli-price-from-icpswap-into-a-webpage/24051/7 "2023-12-26T21:45:28Z")

</div>

> [@ICPSwap](#):
>
> `https://uvevg-iyaaa-aaaak-ac27q-cai.raw.ic0.app/tickers`

What other endpoints are available? I’m interested in reading last trades on a pool with certain ID

---

<div class="post-metadata">

**Author:** ![ICPSwap](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/icpswap/32/11193_2.png) [@ICPSwap](https://forum.dfinity.org/u/ICPSwap)\
**Post date:** [December 27, 2023, 6:07am UTC](https://forum.dfinity.org/t/failure-to-fetch-sli-price-from-icpswap-into-a-webpage/24051/8 "2023-12-27T06:07:49Z")

</div>

Hello, sir.

Devs has made updates, please check out this latest docs:

> **[GitHub - ICPSwap-Labs/docs](https://github.com/ICPSwap-Labs/docs)**
>
> Contribute to ICPSwap-Labs/docs development by creating an account on GitHub.
