Failure to fetch $SLI price from ICPSwap into a webpage

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 = “”;
const agent = new HttpAgent({ fetch, host });
const canisterId = ‘yr4hc-viaaa-aaaag-qcirq-cai’; // ICPSwap canister ID

const actor = Actor.createActor(canisterId, {
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);

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 “”? Let us see how we can help you!

Thank you.


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.


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

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.

1 Like

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

## Swap Pool Info

Url: GET


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

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

Hello, sir.

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

1 Like