đ Trending MintsLearn how to recommend mints that are trending among Farcaster users.
In this guide, you will learn how to use Airstack to recommend all trending tokens that are minted by Farcaster users within a given time frame.
Pre-requisites
Basic knowledge of GraphQL
Get Started
JavaScript/TypeScript/Python
If you are using JavaScript/TypeScript or Python, Install the Airstack SDK:
npm yarn pnpm pip
React
Copy npm install @airstack/airstack-react
Node
Copy npm install @airstack/node
React
Copy yarn add @airstack/airstack-react
Node
Copy yarn add @airstack/node
React
Copy pnpm install @airstack/airstack-react
Node
Copy pnpm install @airstack/node
Then, add the following snippets to your code:
React Node Python
Copy 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 >;
}
};
Copy import { init , fetchQuery } from "@airstack/node" ;
init ( "YOUR_AIRSTACK_API_KEY" );
const query = `YOUR_QUERY` ; // Replace with GraphQL Query
const { data , error } = await fetchQuery (query);
console .log ( "data:" , data);
console .log ( "error:" , error);
Copy import asyncio
from airstack . execute_query import AirstackClient
api_client = AirstackClient (api_key = "YOUR_AIRSTACK_API_KEY" )
query = """YOUR_QUERY""" # Replace with GraphQL Query
async def main ():
execute_query_client = api_client . create_execute_query_object (
query = query)
query_response = await execute_query_client . execute_query ()
print (query_response.data)
asyncio . run ( main ())
Other Programming Languages
To access the Airstack APIs in other languages, you can use https://api.airstack.xyz/gql as your GraphQL endpoint.
Fetch Trending Mints Among Farcaster Users
First, define the following parameters to fetch the trending mints data:
Name Value Description 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.
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 to the variables:
Try Demo
Code
Query Variables Response
Copy query MyQuery (
$timeFrame: TimeFrame ! ,
$criteria: TrendingMintsCriteria !
) {
TrendingMints(
input: {
timeFrame : $timeFrame,
audience : farcaster,
blockchain : base,
criteria : $criteria
}
) {
TrendingMints {
address
erc1155TokenID
criteriaCount
timeFrom
timeTo
token {
name
symbol
type
}
}
}
}
Copy {
"timeFrame" : "one_hour" ,
"criteria" : "unique_wallets"
}
Copy {
"data" : {
"TrendingMints" : {
"TrendingMints" : [
{
"address" : "0x83b16258221bfa260ca4f1ef31567241242fec7a" ,
"erc1155TokenID" : "1" ,
"criteriaCount" : 51 ,
"timeFrom" : "2024-03-07T11:39:00Z" ,
"timeTo" : "2024-03-07T12:37:00Z" ,
"token" : {
"name" : "Rainbow Cats" ,
"symbol" : "" ,
"type" : "ERC1155"
}
} ,
// Other trending mints
]
}
}
}
đ đĨŗ Congratulations you've just fetched all the trending tokens minted by Farcaster users and integrate it into your application!
Developer Support
If you have any questions or need help regarding integrating or building trending mints by Farcaster users into your application, please join our Airstack's Telegram group.
More Resources
Airstack Onchain Kit for Farcaster Frames