🔍Search Social Profiles

Learn how to use Airstack to search for social profiles on Farcaster that fulfills the given regex patterns, filters or sort variables the API offered.

Airstack provides easy-to-use Socials API for searching social profiles on Farcaster easily by using RegEx patterns.

With this, you can build your very own social profile search engine easily and plug it into your application.

Table Of Contents

In this guide you will learn how 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 All Farcaster Users Starting With Given Words

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

show me all Farcaster users starting with "a"

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 Containing Given Words

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

Try Demo

show me all Farcaster users containing with "abc"

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

Get All Farcaster Users That Has Certain Number of Letters

You can fetch all Farcaster users that has certain number of letters in its profile name by providing "^.{min_number_of_letters, max_number_of_letters}$" directly to the _regex operator in Socials API, where the minimum should always be less than or equal to the maximum:

Try Demo

show me all Farcaster users that has 3 letters or less

Code

query MyQuery {
  Socials(
    input: {
      filter: {
        # This regex pattern search all Farcaster users that have 1-3
        # letters in its profile name
        profileName: {_regex: "^.{1,3}$"}
        dappName: {_eq: farcaster}
      },
      blockchain: ethereum
    }
  ) {
    Social {
      dappName
      profileName
    }
  }
}

Developer Support

If you have any questions or need help regarding searching for social profiles on Lens and Farcaster, please join our Airstack's Telegram group.

More Resources

Last updated

Was this helpful?

#946:

Change request updated