đ NFT DetailsLearn how to fetch ERC721 & ERC1155 NFT details data, which includes name, symbol, NFT images (original & resized), metadata from a specific NFT or an NFT collection.
Airstack provides easy-to-use NFT APIs for enriching Web3 applications with onchain and offchain NFT data from Ethereum, Base, Degen Chain, and other Airstack-supported chains.
Table Of Contents
In this guide you will learn how to use Airstack to:
Pre-requisites
Basic knowledge of GraphQL
Get Started
JavaScript/TypeScript/Python
If you are using JavaScript/TypeScript or Python, Install the Airstack SDK:
npm yarn pnpm pip
React
Copy npm install @airstack/airstack-react
Node
Copy npm install @airstack/node
React
Copy yarn add @airstack/airstack-react
Node
Copy yarn add @airstack/node
React
Copy pnpm install @airstack/airstack-react
Node
Copy pnpm install @airstack/node
Then, add the following snippets to your code:
React Node Python
Copy 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 >;
}
};
Copy import { init , fetchQuery } from "@airstack/node" ;
init ( "YOUR_AIRSTACK_API_KEY" );
const query = `YOUR_QUERY` ; // Replace with GraphQL Query
const { data , error } = await fetchQuery (query);
console .log ( "data:" , data);
console .log ( "error:" , error);
Copy 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 ())
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 NFT Collection Total Supply
You can fetch an NFT collection's total supply by using the totalSupply
field from Tokens
API by providing NFT collection address
as an input:
Try Code
Demo
Query Response
Copy query TotalSupply {
Tokens(
input: {
filter : { address : { _eq : "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D" } }
blockchain : ethereum
}
) {
Token {
totalSupply
}
}
}
Copy {
"data" : {
"Tokens" : {
"Token" : [
{
"totalSupply" : "10000"
}
]
}
}
}
Get NFT Name & Symbol
You can fetch an NFT collection's name and symbol by using the name
and symbol
fields from Tokens
API by providing NFT collection address
as an input:
Try Demo
Code
Query Response
Copy query MyQuery {
Tokens(
input: {
filter : { address : { _eq : "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D" } }
blockchain : ethereum
}
) {
Token {
name
symbol
}
}
}
Copy {
"data" : {
"Tokens" : {
"Token" : [
{
"name" : "BoredApeYachtClub" ,
"symbol" : "BAYC"
}
]
}
}
}
Get NFT Metadata of Specific NFT
You can fetch an NFT's metadata (both raw and formatted version) by using the TokenNfts
API by specifying NFT collection address
and the NFT tokenId
as an input:
Try Demo
Code
Query Response
Copy query MyQuery {
TokenNfts(
input: {
filter : {
address : { _eq : "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D" }
tokenId : { _eq : "0" }
}
blockchain : ethereum
}
) {
TokenNft {
tokenId
rawMetaData
metaData {
name
description
image
attributes {
trait_type
value
}
}
}
pageInfo {
nextCursor
prevCursor
}
}
}
Copy {
"data" : {
"TokenNfts" : {
"TokenNft" : [
{
"tokenId" : "0" ,
"rawMetaData" : {
"attributes" : [
{
"trait_type" : "Earring" ,
"value" : "Silver Hoop"
} ,
{
"trait_type" : "Background" ,
"value" : "Orange"
} ,
{
"trait_type" : "Fur" ,
"value" : "Robot"
} ,
{
"trait_type" : "Clothes" ,
"value" : "Striped Tee"
} ,
{
"trait_type" : "Mouth" ,
"value" : "Discomfort"
} ,
{
"trait_type" : "Eyes" ,
"value" : "X Eyes"
}
] ,
"image" : "ipfs://QmRRPWG96cmgTn2qSzjwr2qvfNEuhunv6FNeMFGa9bx6mQ"
} ,
"metaData" : {
"name" : "" ,
"description" : "" ,
"image" : "ipfs://QmRRPWG96cmgTn2qSzjwr2qvfNEuhunv6FNeMFGa9bx6mQ" ,
"attributes" : [
{
"trait_type" : "Earring" ,
"value" : "Silver Hoop"
} ,
{
"trait_type" : "Background" ,
"value" : "Orange"
} ,
{
"trait_type" : "Fur" ,
"value" : "Robot"
} ,
{
"trait_type" : "Clothes" ,
"value" : "Striped Tee"
} ,
{
"trait_type" : "Mouth" ,
"value" : "Discomfort"
} ,
{
"trait_type" : "Eyes" ,
"value" : "X Eyes"
}
]
}
}
] ,
"pageInfo" : {
"nextCursor" : "" ,
"prevCursor" : ""
}
}
}
}
Get NFT Metadata of An NFT Collection
You can fetch all NFTs' metadata (both raw and formatted version) in an NFT collection by using the TokenNfts
API by providing NFT collection address
as an input:
Try Demo
Code
Query Response
Copy query MyQuery {
TokenNfts(
input: {
filter : { address : { _eq : "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D" } }
blockchain : ethereum
}
) {
TokenNft {
tokenId
rawMetaData
metaData {
name
description
image
attributes {
trait_type
value
}
}
}
pageInfo {
nextCursor
prevCursor
}
}
}
Copy {
"data" : {
"TokenNfts" : {
"TokenNft" : [
{
"tokenId" : "0" ,
"rawMetaData" : {
"attributes" : [
{
"trait_type" : "Earring" ,
"value" : "Silver Hoop"
} ,
{
"trait_type" : "Background" ,
"value" : "Orange"
} ,
{
"trait_type" : "Fur" ,
"value" : "Robot"
} ,
{
"trait_type" : "Clothes" ,
"value" : "Striped Tee"
} ,
{
"trait_type" : "Mouth" ,
"value" : "Discomfort"
} ,
{
"trait_type" : "Eyes" ,
"value" : "X Eyes"
}
] ,
"image" : "ipfs://QmRRPWG96cmgTn2qSzjwr2qvfNEuhunv6FNeMFGa9bx6mQ"
} ,
"metaData" : {
"name" : "" ,
"description" : "" ,
"image" : "ipfs://QmRRPWG96cmgTn2qSzjwr2qvfNEuhunv6FNeMFGa9bx6mQ" ,
"attributes" : [
{
"trait_type" : "Earring" ,
"value" : "Silver Hoop"
} ,
{
"trait_type" : "Background" ,
"value" : "Orange"
} ,
{
"trait_type" : "Fur" ,
"value" : "Robot"
} ,
{
"trait_type" : "Clothes" ,
"value" : "Striped Tee"
} ,
{
"trait_type" : "Mouth" ,
"value" : "Discomfort"
} ,
{
"trait_type" : "Eyes" ,
"value" : "X Eyes"
}
]
}
}
// other NFTs
] ,
"pageInfo" : {
"nextCursor" : "" ,
"prevCursor" : ""
}
}
}
}
Get NFT Images of Specific NFT
You can fetch an NFT's image (both original and resized version) by using the TokenNfts
API by specifying NFT collection address
and the NFT tokenId
as an input:
Try Demo
Resized NFT images size guide:
Code
Query Response
Copy query MyQuery {
TokenNfts(
input: {
filter : {
address : { _eq : "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D" }
tokenId : { _eq : "0" }
}
blockchain : ethereum
}
) {
TokenNft {
contentValue {
image {
extraSmall
small
medium
large
original # Original size of the NFT image
}
}
}
}
}
Copy {
"data" : {
"TokenNfts" : {
"TokenNft" : [
{
"contentValue" : {
"image" : {
"extraSmall": "https://assets.airstack.xyz/image/nft/D+0AQrSsYYaYPkhHjNpMvNeST+YQ2SI7M2u7bB7tjmI6xynU3spMwkuRVDM/9nYZ/extra_small.png",
"small": "https://assets.airstack.xyz/image/nft/D+0AQrSsYYaYPkhHjNpMvNeST+YQ2SI7M2u7bB7tjmI6xynU3spMwkuRVDM/9nYZ/small.png",
"medium": "https://assets.airstack.xyz/image/nft/D+0AQrSsYYaYPkhHjNpMvNeST+YQ2SI7M2u7bB7tjmI6xynU3spMwkuRVDM/9nYZ/medium.png",
"large": "https://assets.airstack.xyz/image/nft/D+0AQrSsYYaYPkhHjNpMvNeST+YQ2SI7M2u7bB7tjmI6xynU3spMwkuRVDM/9nYZ/large.png",
"original": "https://assets.airstack.xyz/image/nft/D+0AQrSsYYaYPkhHjNpMvNeST+YQ2SI7M2u7bB7tjmI6xynU3spMwkuRVDM/9nYZ/original_image.png"
}
}
}
]
}
}
}
Get NFT Images of An NFT Collection
You can fetch all NFTs' images (both original and resized version) in an NFT collection by using the TokenNfts
API by providing NFT collection address
as an input:
Try Demo
Resized NFT images size guide:
Code
Query Response
Copy query MyQuery {
TokenNfts(
input: {
filter : { address : { _eq : "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D" } }
blockchain : ethereum
}
) {
TokenNft {
tokenId
contentValue {
image {
extraSmall
small
medium
large
original # Original size of the NFT image
}
}
}
pageInfo {
nextCursor
prevCursor
}
}
}
Copy {
"data" : {
"TokenNfts" : {
"TokenNft" : [
{
"tokenId" : "0" ,
"contentValue" : {
"image" : {
"extraSmall": "https://assets.airstack.xyz/image/nft/D+0AQrSsYYaYPkhHjNpMvNeST+YQ2SI7M2u7bB7tjmI6xynU3spMwkuRVDM/9nYZ/extra_small.png",
"small": "https://assets.airstack.xyz/image/nft/D+0AQrSsYYaYPkhHjNpMvNeST+YQ2SI7M2u7bB7tjmI6xynU3spMwkuRVDM/9nYZ/small.png",
"medium": "https://assets.airstack.xyz/image/nft/D+0AQrSsYYaYPkhHjNpMvNeST+YQ2SI7M2u7bB7tjmI6xynU3spMwkuRVDM/9nYZ/medium.png",
"large": "https://assets.airstack.xyz/image/nft/D+0AQrSsYYaYPkhHjNpMvNeST+YQ2SI7M2u7bB7tjmI6xynU3spMwkuRVDM/9nYZ/large.png",
"original": "https://assets.airstack.xyz/image/nft/D+0AQrSsYYaYPkhHjNpMvNeST+YQ2SI7M2u7bB7tjmI6xynU3spMwkuRVDM/9nYZ/original_image.png"
}
}
}
// other NFTs
]
}
}
}
Get Specific NFT in An NFT Collection
You can fetch all individual NFTs' details in an NFT collection by using the TokenNfts
API by providing NFT collection address
and the NFT tokenId
as an input:
Try Demo
Resized NFT images size guide:
Code
Query Response
Copy query MyQuery {
TokenNfts(
input: {
filter : {
address : { _eq : "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D" }
tokenId : { _eq : "0" }
}
blockchain : ethereum
}
) {
TokenNft {
tokenURI
rawMetaData
metaData {
animationUrl
attributes {
displayType
maxValue
trait_type
value
}
backgroundColor
description
externalUrl
image
imageData
name
youtubeUrl
}
contentValue {
image {
extraSmall
small
medium
large
original # Original size of the NFT image
}
}
}
}
}
Copy {
"data" : {
"TokenNfts" : {
"TokenNft" : [
{
"tokenURI" : "ipfs://QmeSjSinHpPnmXmspMjwiXyN6zS4E9zccariGR3jxcaWtq/0" ,
"rawMetaData" : {
"attributes" : [
{
"trait_type" : "Earring" ,
"value" : "Silver Hoop"
} ,
{
"trait_type" : "Background" ,
"value" : "Orange"
} ,
{
"trait_type" : "Fur" ,
"value" : "Robot"
} ,
{
"trait_type" : "Clothes" ,
"value" : "Striped Tee"
} ,
{
"trait_type" : "Mouth" ,
"value" : "Discomfort"
} ,
{
"trait_type" : "Eyes" ,
"value" : "X Eyes"
}
] ,
"image" : "ipfs://QmRRPWG96cmgTn2qSzjwr2qvfNEuhunv6FNeMFGa9bx6mQ"
} ,
"metaData" : {
"animationUrl" : "" ,
"attributes" : [
{
"displayType" : null ,
"maxValue" : null ,
"trait_type" : "Earring" ,
"value" : "Silver Hoop"
} ,
{
"displayType" : null ,
"maxValue" : null ,
"trait_type" : "Background" ,
"value" : "Orange"
} ,
{
"displayType" : null ,
"maxValue" : null ,
"trait_type" : "Fur" ,
"value" : "Robot"
} ,
{
"displayType" : null ,
"maxValue" : null ,
"trait_type" : "Clothes" ,
"value" : "Striped Tee"
} ,
{
"displayType" : null ,
"maxValue" : null ,
"trait_type" : "Mouth" ,
"value" : "Discomfort"
} ,
{
"displayType" : null ,
"maxValue" : null ,
"trait_type" : "Eyes" ,
"value" : "X Eyes"
}
] ,
"backgroundColor" : "" ,
"description" : "" ,
"externalUrl" : "" ,
"image" : "ipfs://QmRRPWG96cmgTn2qSzjwr2qvfNEuhunv6FNeMFGa9bx6mQ" ,
"imageData" : "" ,
"name" : "" ,
"youtubeUrl" : ""
} ,
"contentValue" : {
"image" : {
"extraSmall": "https://assets.airstack.xyz/image/nft/D+0AQrSsYYaYPkhHjNpMvNeST+YQ2SI7M2u7bB7tjmI6xynU3spMwkuRVDM/9nYZ/extra_small.png",
"small": "https://assets.airstack.xyz/image/nft/D+0AQrSsYYaYPkhHjNpMvNeST+YQ2SI7M2u7bB7tjmI6xynU3spMwkuRVDM/9nYZ/small.png",
"medium": "https://assets.airstack.xyz/image/nft/D+0AQrSsYYaYPkhHjNpMvNeST+YQ2SI7M2u7bB7tjmI6xynU3spMwkuRVDM/9nYZ/medium.png",
"large": "https://assets.airstack.xyz/image/nft/D+0AQrSsYYaYPkhHjNpMvNeST+YQ2SI7M2u7bB7tjmI6xynU3spMwkuRVDM/9nYZ/large.png",
"original": "https://assets.airstack.xyz/image/nft/D+0AQrSsYYaYPkhHjNpMvNeST+YQ2SI7M2u7bB7tjmI6xynU3spMwkuRVDM/9nYZ/original_image.png"
}
}
}
]
}
}
}
Get All NFT In An NFT Collection
You can fetch all individual NFTs' details in an NFT collection by using the TokenNfts
API by providing NFT collection address
as an input:
Try Demo
Resized NFT images size guide:
Code
Query Response
Copy query MyQuery {
TokenNfts(
input: {
filter : { address : { _eq : "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D" } }
blockchain : ethereum
}
) {
TokenNft {
tokenId
tokenURI
rawMetaData
metaData {
animationUrl
attributes {
displayType
maxValue
trait_type
value
}
backgroundColor
description
externalUrl
image
imageData
name
youtubeUrl
}
contentValue {
image {
extraSmall
small
medium
large
original # Original size of the NFT image
}
}
}
pageInfo {
nextCursor
prevCursor
}
}
}
Copy {
"data" : {
"TokenNfts" : {
"TokenNft" : [
{
"tokenId" : "0" ,
"tokenURI" : "ipfs://QmeSjSinHpPnmXmspMjwiXyN6zS4E9zccariGR3jxcaWtq/0" ,
"rawMetaData" : {
"attributes" : [
{
"trait_type" : "Earring" ,
"value" : "Silver Hoop"
} ,
{
"trait_type" : "Background" ,
"value" : "Orange"
} ,
{
"trait_type" : "Fur" ,
"value" : "Robot"
} ,
{
"trait_type" : "Clothes" ,
"value" : "Striped Tee"
} ,
{
"trait_type" : "Mouth" ,
"value" : "Discomfort"
} ,
{
"trait_type" : "Eyes" ,
"value" : "X Eyes"
}
] ,
"image" : "ipfs://QmRRPWG96cmgTn2qSzjwr2qvfNEuhunv6FNeMFGa9bx6mQ"
} ,
"metaData" : {
"animationUrl" : "" ,
"attributes" : [
{
"displayType" : null ,
"maxValue" : null ,
"trait_type" : "Earring" ,
"value" : "Silver Hoop"
} ,
{
"displayType" : null ,
"maxValue" : null ,
"trait_type" : "Background" ,
"value" : "Orange"
} ,
{
"displayType" : null ,
"maxValue" : null ,
"trait_type" : "Fur" ,
"value" : "Robot"
} ,
{
"displayType" : null ,
"maxValue" : null ,
"trait_type" : "Clothes" ,
"value" : "Striped Tee"
} ,
{
"displayType" : null ,
"maxValue" : null ,
"trait_type" : "Mouth" ,
"value" : "Discomfort"
} ,
{
"displayType" : null ,
"maxValue" : null ,
"trait_type" : "Eyes" ,
"value" : "X Eyes"
}
] ,
"backgroundColor" : "" ,
"description" : "" ,
"externalUrl" : "" ,
"image" : "ipfs://QmRRPWG96cmgTn2qSzjwr2qvfNEuhunv6FNeMFGa9bx6mQ" ,
"imageData" : "" ,
"name" : "" ,
"youtubeUrl" : ""
} ,
"contentValue" : {
"image" : {
"extraSmall": "https://assets.airstack.xyz/image/nft/D+0AQrSsYYaYPkhHjNpMvNeST+YQ2SI7M2u7bB7tjmI6xynU3spMwkuRVDM/9nYZ/extra_small.png",
"small": "https://assets.airstack.xyz/image/nft/D+0AQrSsYYaYPkhHjNpMvNeST+YQ2SI7M2u7bB7tjmI6xynU3spMwkuRVDM/9nYZ/small.png",
"medium": "https://assets.airstack.xyz/image/nft/D+0AQrSsYYaYPkhHjNpMvNeST+YQ2SI7M2u7bB7tjmI6xynU3spMwkuRVDM/9nYZ/medium.png",
"large": "https://assets.airstack.xyz/image/nft/D+0AQrSsYYaYPkhHjNpMvNeST+YQ2SI7M2u7bB7tjmI6xynU3spMwkuRVDM/9nYZ/large.png",
"original": "https://assets.airstack.xyz/image/nft/D+0AQrSsYYaYPkhHjNpMvNeST+YQ2SI7M2u7bB7tjmI6xynU3spMwkuRVDM/9nYZ/original_image.png"
}
}
}
] ,
"pageInfo" : {
"nextCursor": "eyJMYXN0VmFsdWVzTWFwIjp7Il9pZCI6eyJWYWx1ZSI6IjEweGJjNGNhMGVkYTc2NDdhOGFiN2MyMDYxYzJlMTE4YTE4YTkzNmYxM2QxMDQxIiwiRGF0YVR5cGUiOiJzdHJpbmcifX0sIlBhZ2luYXRpb25EaXJlY3Rpb24iOiJORVhUIn0=",
"prevCursor" : ""
}
}
}
}
Developer Support
If you have any questions or need help regarding fetching NFT details data, please join our Airstack's Telegram group.
More Resources