πŸ’œFarcaster Users

Learn how to recommend ERC-20 tokens that are trending amongst Farcaster users.

In this guide, you will learn how to use Airstack to recommend all trending tokens among Farcaster users within a given time frame. This API makes use of Airstack Abstractions to calculate the results in milliseconds; no compute or backend database required on your end.

TrendingTokens API is currently available for the Base and Degen L3 blockchains.

Pre-requisites

  • An Airstack account

  • Basic knowledge of GraphQL

Get Started

JavaScript/TypeScript/Python

If you are using JavaScript/TypeScript or Python, Install the Airstack SDK:

React

npm install @airstack/airstack-react

Node

npm install @airstack/node

Then, add the following snippets to your code:

import { init, useQuery } from "@airstack/airstack-react";

init("YOUR_AIRSTACK_API_KEY");

const query = `YOUR_QUERY`; // Replace with GraphQL Query

const Component = () => {
  const { data, loading, error } = useQuery(query);

  if (data) {
    return <p>Data: {JSON.stringify(data)}</p>;
  }

  if (loading) {
    return <p>Loading...</p>;
  }

  if (error) {
    return <p>Error: {error.message}</p>;
  }
};

Other Programming Languages

To access the Airstack APIs in other languages, you can use https://api.airstack.xyz/gql as your GraphQL endpoint.

First, define the following parameters to fetch the trending tokens data:

Once you have the parameters prepared, simply use the query below and add the parameters as variables:

Try Demo

Code

query MyQuery(
  $transferType: TrendingTokensTransferType!,
  $timeFrame: TimeFrame!,
  $criteria: TrendingTokensCriteria!,
  $swappable: Boolean,
  $blockchain: TrendingBlockchain!
) {
  TrendingTokens(
    input: {
      transferType: $transferType,
      timeFrame: $timeFrame,
      audience: farcaster,
      blockchain: $blockchain,
      criteria: $criteria,
      swappable: { _eq: $swappable }
    }
  ) {
    TrendingToken {
      address
      criteriaCount
      timeFrom
      timeTo
      token {
        name
        symbol
        type
      }
    }
  }
}

Developer Support

If you have any questions or need help regarding integrating or building trending tokens into your application, please join our Airstack's Telegram group.

More Resources

Last updated

Was this helpful?