đŸ–ŧī¸Profile Image

Learn how to use Airstack API to fetch ENS profile image data in various sizes.

Airstack provides easy-to-use APIs for enriching Web3 applications and integrating on-chain and off-chain data from ENS.

In this guide you will learn how to use Airstack to get ENS profile image in various sizes.

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.

Get ENS Profile Image

You can provide the domain name, e.g. vitalik.eth, into the name input filter and fetch the ENS profile image from the response with the tokenNft.contentValue.image field:

The images returned will already be resized by Airstack and can be used directly within your application:

  • extra_small: 125x125px

  • small: 250x250px

  • medium: 500x500px

  • large: 750x750px

Try Demo

Code

query MyQuery {
  Domains(
    input: { filter: { name: { _eq: "vitalik.eth" } }, blockchain: ethereum }
  ) {
    Domain {
      tokenNft {
        contentValue {
          image {
            extraSmall
            small
            medium
            large
            original
          }
        }
      }
    }
  }
}

Developer Support

If you have any questions or need help regarding fetching ENS profile images data, please join our Airstack's Telegram group.

More Resources

Last updated

Was this helpful?