1inch API help - alternatives

I’m unable to access the 1inch api since it seems that they have changed the URL or turned it into an enterprise solution. Are there any alternatives we can use to follow with the tutorial?

I am referring to the “Displaying Quotes” section of the course (which is under Asnyc Programming).

Hey @zk-janzi, hope you are well.

The 1inch pluging is working properly for my side, is still a free plugin to use, so no enterprise solution for it.

Could you please describe the issue you are facing with the pluging?

Carlos Z

The coinpaprika api did not work for me so I changed it to coingecko.
I can get the top 10 coins from coingecko but when I getTickerData from 1inch I get no result.

Can some one help me what goes wrong?

async function getTop10Tokens() {
    const response = await fetch('https://api.coingecko.com/api/v3/coins/markets?vs_currency=eur&order=market_cap_desc&per_page=100&page=1&sparkline=false');
    const tokens = await response.json();
    return tokens
        .filter(token => token.market_cap_rank >= 1 && token.market_cap_rank <= 10)
        .map(token => token.symbol);

  async function getTickerData(tickerList) {
      const response = await fetch('https://api.1inch.exchange/v3.0/137/tokens');
      const tokens = await response.json();
      const tokenList = Object.values(tokens.tokens);

      return tokenList.filter(token => tickerList.includes(tokens.tokens));

getTop10Tokens() is working flawlessly. However, it gives you this data structure: ['btc', 'eth', 'usdt', 'bnb', 'usdc', 'ada', 'sol', 'xrp', 'luna', 'dot'].

The 1inch call in getTicker data gives you an array of values like this:


In the return value of getTickerData, you are comparing strings to objects, which will never succeed, so you are destined to get an empty array as a result. Also note, if you used the symbol key of the latter object, it’d be in upper case, while coingecko gave you lower case results. Hint: google toUpperCase()