πŸ”΅All Base Users

Learn how to recommend mints that are trending among all Base users.

In this guide, you will learn how to use Airstack to recommend all trending tokens that are minted by all Base users within a given time frame.

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 mints data:

NameValueDescription

timeFrame

one_hour | two_hours | eight_hours | one_day | two_days | seven_days

Only fetch trending mints within the chosen time frame, e.g. one_hour will fetch trending mints for the last 1 hour.

criteria

unique_wallets | total_mints

This will calculate and sort the tokens based on the chosen criteria: - unique_wallets: Calculate the number of unique wallets minting the trending tokens - total_mints: Calculate the number of times minting occurred on the trending token

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

Try Demo

Code

query MyQuery(
  $timeFrame: TimeFrame!,
  $criteria: TrendingMintsCriteria!
) {
  TrendingMints(
    input: {
      timeFrame: $timeFrame,
      audience: all,
      blockchain: base,
      criteria: $criteria
    }
  ) {
    TrendingMint {
      address
      erc1155TokenID
      criteriaCount
      timeFrom
      timeTo
      token {
        name
        symbol
        type
      }
    }
  }
}

πŸŽ‰ πŸ₯³ Congratulations you've just fetched all the trending tokens minted among all Base users and integrate it into your application!

Developer Support

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

More Resources

Last updated

Was this helpful?