💡Activate Kit for Farcaster Auth Kit

Airstack Activate Kit enables you to execute a series of API calls to activate Farcaster users after they connect with Farcaster Auth Kit.

Farcaster Auth Kit enables your users to login to your app with their Farcaster custody address. Airstack Activate Kit is the next immediate step.

With Airstack Activate you can immediately fetch all of the user's:

  • Registration details from Optimism and Hubs

  • Profile details including bio, profile image

  • Connected addresses

  • Following

  • Followers

You can also use Airstack regex search to enable auto-complete search for Farcaster users in your app.

Table Of Contents

In this guide, you will learn to use Airstack to:

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.

Get Farcaster User Details

You can fetch the Farcaster user details of a 0x address by using the Socials API and provide the 0x address to the identity filter input:

Try Demo

Code

query MyQuery {
  Socials(
    input: {
      filter: {
        identity: { _eq: "0x182327170fC284cAaA5b1bC3e3878233f529D741" }
        dappName: { _eq: farcaster }
      }
      blockchain: ethereum
      limit: 200
    }
  ) {
    Social {
      profileName
      fnames
      userId
      profileImage
      profileImageContentValue {
        image {
          medium
        }
      }
    }
  }
}

Get Farcaster User's Connected Addresses

You can fetch the Farcaster profile's connected addresses of a 0x address by using the Socials API and provide the 0x address to the identity filter input and all the connected addresses will be returned in the userAssociatedAddresses field:

Try Demo

Code

query MyQuery {
  Socials(
    input: {
      filter: {
        identity: { _eq: "0x182327170fC284cAaA5b1bC3e3878233f529D741" }
        dappName: { _eq: farcaster }
      }
      blockchain: ethereum
      limit: 200
    }
  ) {
    Social {
      userAssociatedAddresses
    }
  }
}

Get Farcaster User's Followers and Following Counts

You can fetch the Farcaster profile's connected addresses of a 0x address by using the Socials API and provide the 0x address to the identity filter input.

The number of people following and people followed by the given Farcaster profile will be returned in the followerCount and followingCount, respectively:

Try Demo

Code

query MyQuery {
  Socials(
    input: {
      filter: {
        identity: { _eq: "0x182327170fC284cAaA5b1bC3e3878233f529D741" }
        dappName: { _eq: farcaster }
      }
      blockchain: ethereum
      limit: 200
    }
  ) {
    Social {
      followerCount
      followingCount
    }
  }
}

Get Farcaster User's Followers

You can fetch all the users following 0x address on Farcaster by using the SocialFollowers API and provide the 0x address to the identity filter input:

Try Demo

Code

query MyQuery {
  SocialFollowers(
    input: {
      filter: {
        dappName: { _eq: farcaster }
        identity: { _eq: "0x182327170fC284cAaA5b1bC3e3878233f529D741" }
      }
      blockchain: ALL
      limit: 200
    }
  ) {
    Follower {
      followerAddress {
        addresses
        socials(input: { filter: { dappName: { _eq: farcaster } } }) {
          profileName
          userId
        }
      }
    }
  }
}

Get Farcaster User's Followings

You can fetch all the users being followed by 0x address on Farcaster by using the SocialFollowings API and provide the 0x address to the identity filter input:

Try Demo

Code

query MyQuery {
  SocialFollowings(
    input: {
      filter: {
        dappName: { _eq: farcaster }
        identity: { _eq: "0x182327170fC284cAaA5b1bC3e3878233f529D741" }
      }
      blockchain: ALL
      limit: 200
    }
  ) {
    Following {
      followingAddress {
        addresses
        socials(input: { filter: { dappName: { _eq: farcaster } } }) {
          profileName
          userId
        }
      }
    }
  }
}

Get All Farcaster Users Whose Names Start With Certain Terms (auto-complete)

You can fetch all Farcaster users that starts with given words by providing the regex pattern "^<given-words>" to the _regex operator in Socials API:

Try Demo

Code

query MyQuery {
  Socials(
    input: {
      filter: {
        # This regex pattern will search all Farcaster users
        # starting with "a"
        profileName: {_regex: "^a"},
        dappName: {_eq: farcaster}
      },
      blockchain: ethereum
    }
  ) {
    Social {
      dappName
      profileName
    }
  }
}

Get All Farcaster Users Whose Names Contain Certain Terms (auto-complete)

You can fetch all Farcaster users that contains given words by providing "<given-words>" directly to the _regex operator in Socials API:

Try Demo

Code

query MyQuery {
  Socials(
    input: {
      filter: {
        # This regex pattern will search all Farcaster users
        # containing "abc"
        profileName: {_regex: "abc"},
        dappName: {_eq: farcaster}
      },
      blockchain: ethereum
    }
  ) {
    Social {
      dappName
      profileName
    }
  }
}

Developer Support

If you have any questions or need help regarding the activate kit for Farcaster Auth Kit, please join our Airstack's Telegram group.

More Resources

Last updated

Was this helpful?