đŸ˜ļFarcaster NOTA Earnings

Learn 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

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.

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 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
    }
  }
}

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 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
    }
  }
}

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 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
    }
  }
}

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

Was this helpful?

Change request #946: