Skip to content

Latest commit

 

History

History
234 lines (181 loc) · 4.6 KB

poaps.md

File metadata and controls

234 lines (181 loc) · 4.6 KB
description layout
Learn how to fetch POAPs in common from multiple users.
title description tableOfContents outline pagination
visible
true
visible
true
visible
true
visible
visible
true

⚡ POAPs

Airstack provides easy-to-use APIs for enriching dapps and integrating on-chain and off-chain data from various blockchains.

In this tutorial, you will learn how to fetch POAPs in common from multiple users.

In this guide you will learn how to use Airstack to fetch POAPs In Common.

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:

{% tabs %} {% tab title="npm" %} React

npm install @airstack/airstack-react

Node

npm install @airstack/node

{% endtab %}

{% tab title="yarn" %} React

yarn add @airstack/airstack-react

Node

yarn add @airstack/node

{% endtab %}

{% tab title="pnpm" %} React

pnpm install @airstack/airstack-react

Node

pnpm install @airstack/node

{% endtab %}

{% tab title="pip" %}

pip install airstack

{% endtab %} {% endtabs %}

Then, add the following snippets to your code:

{% tabs %} {% tab title="React" %}

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 (loading) {
    return <p>Loading...</p>;
  }

  if (error) {
    return <p>Error: {error.message}</p>;
  }
};

{% endtab %}

{% tab title="Node" %}

import { init, fetchQuery } from "@airstack/airstack-react";

init("YOUR_AIRSTACK_API_KEY");

const query = "YOUR_QUERY"; // Replace with GraphQL Query

const { data, error } = fetchQuery(query);

console.log("data:", data);
console.log("error:", error);

{% endtab %}

{% tab title="Python" %}

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())

{% endtab %} {% endtabs %}

Other Programming Languages

To access the Airstack APIs in other languages, you can use https://api.airstack.xyz/gql as your GraphQL endpoint.

POAPs In Common

You can fetch common POAPs of multiple user(s) provided the user's 0x address, Farcaster name or ID, ENS domains, or Lens profile:

Try Demo

{% embed url="https://app.airstack.xyz/query/0U2I2pZzcp" %} Show common POAPs of two users {% endembed %}

Code

{% tabs %} {% tab title="Query" %}

query MyQuery {
  Poaps(
    input: {
      filter: { owner: { _eq: "0xeaf55242a90bb3289db8184772b0b98562053559" } }
      blockchain: ALL
      limit: 200
    }
  ) {
    Poap {
      poapEvent {
        poaps(
          input: {
            filter: {
              owner: { _eq: "0xB59Aa5Bb9270d44be3fA9b6D67520a2d28CF80AB" }
            }
          }
        ) {
          poapEvent {
            eventName
          }
        }
      }
    }
  }
}

{% endtab %}

{% tab title="Response" %}

{
  "data": {
    "Poaps": {
      "Poap": [
        {
          "poapEvent": {
            "poaps": [
              {
                "poapEvent": {
                  "eventName": "You have met Patricio in April of 2023 (IRL)"
                }
              }
            ]
          }
        },
        {
          "poapEvent": {
            "poaps": [] // owned by 1st address, but not the 2nd address
          }
        }
      ]
    }
  }
}

{% endtab %} {% endtabs %}

Developer Support

If you have any questions or need help regarding fetching common POAPs of multiple users, please join our Airstack's Telegram group.

More Resources