NFT Ownership API
The NFT Ownership API can be used to retrieve information about the ownership of a specific NFT ( Non-Fungible Token ) on the supported blockchain. For instance using this we can access the owners of an NFT including their addresses and associated metadata and also we can retrieve a list of the top holders of a particular NFT.
Get NFT Owners
This query fetches the most recent owner of the NFT. It reads the latest transfer of token ID 9996 from the Transfers cube; the Receiver of that transfer is the current owner.
query MyQuery {
EVM(dataset: combined, network: eth) {
Transfers(
orderBy: { descending: Block_Time }
limit: { count: 1 }
where: {
Transfer: {
Id: { eq: "9996" }
Currency: {
Fungible: false
SmartContract: { is: "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e" }
}
}
}
) {
Transfer {
Receiver
Amount
Id
Currency {
Name
SmartContract
}
}
Block {
Number
Date
}
}
}
}
Parameters
network: This specifies the Ethereum network to use.dataset: This specifies the dataset to use. In this case, the dataset is combined.limit: Specifies the maximum results to return. In this query, the limit is 1.orderBy: Results are in descending order by Block_Time.where: This parameter allows you to filter the results based on specific conditions. In this case, the token ID is "9996" and the Currency is non-fungible, with the Smart Contract being0x8a90cab2b38dba80c64b7734e58ee1db38b8992e.
Returned Data
Transfer:Receiveris the current owner of the NFT. It also has the amount, token ID and the NFT currency (Name,SmartContract).Block: Includes the block number and date of the latest transfer.
Top Holders of an NFT
Let's see an example showcasing the retrieval of the top 10 holders for a particular NFT, with their balances.
query MyQuery {
EVM(dataset: combined, network: eth) {
Balances(
orderBy: { descending: Balance_Amount }
limit: { count: 10 }
where: {
Currency: {
SmartContract: { is: "0x7dD4F223D9155F412790D696Fa30923489d4Ad34" }
}
}
) {
Balance {
Address
Amount(selectWhere: { gt: "0" })
}
}
}
}
In this query, you'll need to replace 0x7dD4F223D9155F412790D696Fa30923489d4Ad34 with the contract address of the NFT you'd like to retrieve top holders for.
Parameters
dataset: Specifies combined dataset that includes both realtime & archive data.network: Specifies that the Ethereum network is being queried.orderBy: Orders the results based on the "Balance" field in descending order, meaning the holder with highest balance will appear first.limit: Limits the number of results returned to 10.where: It filters the query results based on the NFT smart contract address0x7dD4F223D9155F412790D696Fa30923489d4Ad34.Currency: {SmartContract: {is: ""}}specifies the filter for the smart contract address.
Returned Data
Balance:Addressis the holder of the NFT andAmountis how many tokens of the collection it holds.