Skip to main content

Fetching Token Holders

This guide explains how to fetch the current holders of a specific token or the owners of a collection using the Enjin Platform API.

Accessing this data is valuable for several purposes:

  • Identify Token Holders: Get a list of addresses that hold your tokens or own items from your collection.
  • Targeted Actions: Use the list to perform actions specifically for your holders or owners, such as distributing rewards or communicating directly.
  • Analyze Distribution: Understand how your tokens or collection items are distributed among users.
What you'll need:

Fetching Token Holders with the Enjin API

Fetching Tokens Limitations

Please note that the GetToken query is limited to tokens from collections that were created via the auth-ed Enjin Platform account.
To get a token that was created elsewhere (via a different Enjin Platform account / NFT.io / Enjin Console / etc.) the collection must be "Tracked" first, or the query response will return an error.
Learn more about tracking a collection in the Tracking Collections section below.

To get holders of a specific token, we use the GetToken query and include the the accounts in the query response:

Query:

query FetchingTokenHolders{
GetToken(
collectionId: 36105 #Specify the collection ID
tokenId: {integer: 0} #Specify the token ID
){
accounts{
edges{
node{
balance
wallet{
account{
address
}
}
}
}
}
}
}

Response:

{
"data": {
"GetToken": {
"accounts": {
"edges": [
{
"node": {
"balance": "4",
"wallet": {
"account": {
"address": "cxLU94nRz1en6gHnXnYPyTdtcZZ9dqBasexvexjArj4V1Qr8f"
}
}
}
},
{
"node": {
"balance": "2",
"wallet": {
"account": {
"address": "cxJXQKFB4ZWJzutwEtZvTQ9KLucdsaWgzyef5pv9R7x98Dmwp"
}
}
}
}
]
}
}
}
}
Using Pagination

The response may be displayed on several pages. To view all of it, you may need to follow steps for pagination which allows you to flip through the pages.

Fetching Collection Holders with the Enjin API

Fetching Collections Limitations

Please note that the GetCollections query is limited to collections that were created via the auth-ed Enjin Platform Cloud account.
To get a collection that was created elsewhere (via a different Enjin Platform Cloud account / NFT.io / Enjin Console / etc.) the collection must be "Tracked" first, or the query response will return an error.
Learn more about tracking a collection in the Tracking Collections section below.

For an NFT collection, we can use the GetCollection query and include the the accounts in the query response to find out how many NFTs from the collection are owned by each address.

Query:

query FetchingCollectionHolders{
GetCollection(collectionId: 36105){ #Specify the collection ID
accounts{
edges{
node{
accountCount
wallet{
account{
address
}
}
}
}
}
}
}

Response:

{
"data": {
"GetCollection": {
"accounts": {
"edges": [
{
"node": {
"accountCount": 3,
"wallet": {
"account": {
"address": "cxLU94nRz1en6gHnXnYPyTdtcZZ9dqBasexvexjArj4V1Qr8f"
}
}
}
},
{
"node": {
"accountCount": 2,
"wallet": {
"account": {
"address": "cxJXQKFB4ZWJzutwEtZvTQ9KLucdsaWgzyef5pv9R7x98Dmwp"
}
}
}
}
]
}
}
}
}
Using Pagination

The response may be displayed on several pages. To view all of it, you may need to follow steps for pagination which allows you to flip through the pages.

Explore More Arguments

For a comprehensive view of all available arguments for queries and mutations, please refer to our API Reference. This resource will guide you on how to use the GraphiQL Playground to explore the full structure and functionality of our API.

Tracking Collections

The GetToken, GetTokens, GetCollection, and GetCollections queries are limited only to collections and tokens that were created via the auth-ed Enjin Platform account. To use these queries with collections / tokens created externally (via a different Enjin Platform account / NFT.io / Enjin Console / etc.) the collection must be "Tracked" first, or the query response will return an error.

To track a collection, head over to the collections page on Enjin Platform: https://platform.enjin.io/collections, click on the "Track" button, insert the collection ID of the collection you want to track and click "Track".

Track Collection

Need to track collections programmatically?

You can use the AddToTracked mutation to track a collection programmatically.