Add on public icrc-api specific no-sns ledger

Hey guys,
We are using this api : https://icrc-api.internetcomputer.org/api/v1/ledgers/tyyy3-4aaaa-aaaaq-aab7a-cai/total-supply to create our dashboard and our explorer. We released few weeks ago now the gldt, and we wanted to create an explorer and use the same api as before, but looks like the ledger is not sync in your api : https://icrc-api.internetcomputer.org/api/v1/ledgers/6c7su-kiaaa-aaaar-qaira-cai/total-supply return no data.
Can you guys can add no-sns ledger to this api ? Or this api is opensource and we can use it directly on our side?
Thanks !
Gautier

1 Like

I assume that you are looking to get the total supply which should be exposed from the icrc1_total_supply function. Have you considered using an ICP agent library to call the exposed icrc1_total_supply function?

There are agents for different languages. Something like this for JavaScript should work:

import { Actor, HttpAgent } from '@dfinity/agent';

const idlFactory = ({ IDL }) => {
  return IDL.Service({
    'icrc1_total_supply': IDL.Func([], [IDL.Nat], ['query']),
  });
};

async function checkTotalSupply() {
  const agent = new HttpAgent({
    host: 'https://ic0.app'
  });

  const canisterId = '6c7su-kiaaa-aaaar-qaira-cai';
  const actor = Actor.createActor(idlFactory, {
    agent,
    canisterId,
  });

  const totalSupply = await actor.icrc1_total_supply();
  console.log('Total supply:', totalSupply.toString());
  return totalSupply;
}

checkTotalSupply().catch(console.error);

Hey Jennifer,
Thanks for your reply. I took the total-supply endpoint because it was the first one i had in my history, but we were using this api to requests transactions and filters over it easily, which is almost impossible via canister call directly - even on indexer canister - and need a better data indexer, like this api. Here’s an example where we used this api for Origyn Explorer : SNS OGY Dashboard, and where you can filter by transaction type, amount sent… and btw the data returned by the api is easier to parse ahah

What is the challenge with calling the Index canister?

The Dashboard APIs are not open sourced at the moment; it will probably be an easier path to use agents and call any public functions.

Maybe is missed the query parameter, but is that possible to filter by query type or amount with index canister ?

There isn’t a filter by amounts or type on the get_blocks query on the Index canister. You would have to external data processing yourself which I assume you want to avoid or at least get guidance from based on the IC Dashboard API implementation.

The ICRC API currently only supports SNS and chain-key tokens. We will add support for non-SNS/ck tokens in the future, but I don’t have an ETA on that. Also see my post here.

As @jennifertran indicated, you can always call the token canisters directly, and optionally index the data yourself, especially if you’re building your own dashboard, as the ICRC API does for the ICP Dashboard.

3 Likes

Ah nice !
Thanks for your reply. We will do via canister calls for now, and once no-sns/no-ck tokens will be available on icp dashboard we will migrate then.
Thanks again !

1 Like