MOXIE Farcaster NOTA EarningsLearn how to fetch Farcaster NOTA earnings from different Farcaster users and channels. In addition, learn how to sort by the earnings to get the top earners of NOTA.
Table Of Contents
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.
Get NOTA Earning For Certain User
You can fetch the NOTA earnings for a certain user by specifying entityType
as USER
and add the FID of the user in entityId
:
Try Demo
Code
Query Response
Copy query MyQuery {
FarcasterNotaEarningStats(
input: {
timeframe: LIFETIME,
blockchain: ALL,
filter: {
# specify entity as USER
entityType: {_eq: USER},
# specify the FID of the user
entityId: {_eq: "3"}
}
}
) {
FarcasterNotaEarningStat {
allEarningsAmount
allEarningsAmountInWei
castEarningsAmount
castEarningsAmountInWei
entityId
entityType
frameDevEarningsAmount
frameDevEarningsAmountInWei
otherEarningsAmount
otherEarningsAmountInWei
timeframe
}
}
}
Copy {
"data": {
"FarcasterNotaEarningStats": {
"FarcasterNotaEarningStat": [
{
"allEarningsAmount": 6434663.061487857,
"allEarningsAmountInWei": "6434663061487857000000000",
"castEarningsAmount": 6434663.061487857,
"castEarningsAmountInWei": "6434663061487857000000000",
"entityId": "3",
"entityType": "USER",
"frameDevEarningsAmount": 0,
"frameDevEarningsAmountInWei": "0",
"otherEarningsAmount": 0,
"otherEarningsAmountInWei": "0",
"timeframe": "LIFETIME"
}
]
}
}
}
Get NOTA Earning For Certain Channel
You can fetch the NOTA earnings for a certain channel by specifying entityType
as CHANNEL
and add the channel ID in entityId
:
Try Demo
Code
Query Response
Copy query MyQuery {
FarcasterNotaEarningStats(
input: {
timeframe: LIFETIME,
blockchain: ALL,
filter: {
# Specify entity as CHANNEL
entityType: {_eq: CHANNEL},
# Specify the channel ID of the Farcaster channel
entityId: {_eq: "airstack"}
}
}
) {
FarcasterNotaEarningStat {
allEarningsAmount
allEarningsAmountInWei
castEarningsAmount
castEarningsAmountInWei
entityId
entityType
frameDevEarningsAmount
frameDevEarningsAmountInWei
otherEarningsAmount
otherEarningsAmountInWei
timeframe
}
}
}
Copy {
"data": {
"FarcasterNotaEarningStats": {
"FarcasterNotaEarningStat": [
{
"allEarningsAmount": 102340.89672629537,
"allEarningsAmountInWei": "102340896726295370000000",
"castEarningsAmount": 84181.52016860196,
"castEarningsAmountInWei": "84181520168601950000000",
"entityId": "airstack",
"entityType": "CHANNEL",
"frameDevEarningsAmount": 16410,
"frameDevEarningsAmountInWei": "16410000000000000000000",
"otherEarningsAmount": 1749.3765576934104,
"otherEarningsAmountInWei": "1749376557693410500000",
"timeframe": "LIFETIME"
}
]
}
}
}
Top NOTA Earning Entities Based On Highest NOTA Earnings
You can fetch the top NOTA earners by specifying order.allEarnings
to DESC
:
Try Demo
Code
Query Response
Copy query MyQuery {
FarcasterNotaEarningStats(
input: {
timeframe: LIFETIME,
blockchain: ALL,
filter: {
entityType: {_eq: USER} # alternatively can be CHANNEL
},
# Order by All earning for sorting by total earnings in
# descending order
order: {allEarnings: DESC}
}
) {
FarcasterNotaEarningStat {
allEarningsAmount
allEarningsAmountInWei
castEarningsAmount
castEarningsAmountInWei
entityId
entityType
frameDevEarningsAmount
frameDevEarningsAmountInWei
otherEarningsAmount
otherEarningsAmountInWei
timeframe
}
}
}
Copy {
"data": {
"FarcasterNotaEarningStats": {
"FarcasterNotaEarningStat": [
{
"allEarningsAmount": 10136643.391825985,
"allEarningsAmountInWei": "10136643391825986000000000",
"castEarningsAmount": 51821.7356651616,
"castEarningsAmountInWei": "51821735665161600000000",
"entityId": "336022",
"entityType": "USER",
"frameDevEarningsAmount": 0,
"frameDevEarningsAmountInWei": "0",
"otherEarningsAmount": 10084821.656160824,
"otherEarningsAmountInWei": "10084821656160823000000000",
"timeframe": "LIFETIME"
},
// Other top Farcaster user with most NOTA earned
]
}
}
}
Developer Support
If you have any questions or need help regarding fetching NOTA earnings data, please join our Airstack's Telegram group.
More Resources
Last updated 7 months ago