πŸ”ŽSearch POAPs

Learn how to use Airstack RegEx Filter to search for POAPs that fulfill the given criteria

Airstack provides easy-to-use APIs for enriching POAP applications and for integrating POAP on-chain data indexed directly from both Ethereum and Gnosis.

Using the _regex operator in PoapEvents API, now you can search for POAPs easily with any standard regex patterns and build your very own POAP search engine into your application.

Table Of Contents

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

Keep in mind that you can combine the regex from each of these use cases into your query to build more complex search feature that suits your app use cases.

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.

πŸ€– AI Natural Language​

Airstack provides an AI solution for you to build GraphQL queries to fulfill your use case easily. You can find the AI prompt of each query in the demo's caption or title for yourself to try.

Best Practices

Here are some best practices to keep in mind to use the _regex filter optimally:

  1. Case Insensitivity

If case insensitivity is not necessary, avoid using the case-insensitive flag (i) in your regex, as it may slow down the query.

If you need case-insensitive search, it is best practice that you use (?i)devcon pattern instead of other patterns (e.g. [Dd]evcon) for most optimal response time.

  1. Avoid Wildcard

Structure your regex pattern as specific as possible and avoid using wildcard (.*) in your regex if possible, as it can lead to more extensive scans and longer response times.

Search All POAPs Starting With Given Words

You can search all POAP events that start with given word by using the PoapEvents API:

Try Demo

Code

query MyQuery {
  PoapEvents(
    input: {
      filter: {
        eventName: {_regex: "^ETHGlobal"} # ^ to indicate starts with in regex
      },
      blockchain: ALL
    }
  ) {
    PoapEvent {
      eventName
      eventId
    }
  }
}

Search All POAPs In Case Insensitive Manner

You can search all POAP events that contain a given word in a case-insensitive manner by using the PoapEvents API:

When doing case-insensitive search, it is best practice that you use (?i)devcon pattern instead of others (e.g. [Dd]evcon).

Try Demo

Search all POAPs that contain devcon (case insensitive)

Code

query MyQuery {
  PoapEvents(
    input: {
      filter: {
        # Regex to search all POAP containing 'devcon' in case insensitive manner
        eventName: {_regex: "(?i)devcon"}
      },
      blockchain: ALL
    }
  ) {
    PoapEvent {
      eventName
      eventId
    }
  }
}

Search All POAPs That Does Not Contain Given Words

You can search all POAP events that DOES NOT contain a given word in by using the PoapEvents API:

Try Demo

Search all POAPs that does not contain "Devconnect"

Code

query MyQuery {
  PoapEvents(
    input: {
      filter: {
        # This regex excludes all POAPs that contain "Devconnect" in their name
        eventName: {_regex: "^(?!Devconnect).*"}
      },
      blockchain: ALL
    }
  ) {
    PoapEvent {
      eventName
      eventId
    }
  }
}

Developer Support

If you have any questions or need help regarding search POAP events using RegEx, please join our Airstack's Telegram group.

More Resources

Last updated

Was this helpful?