APIs & SDKs
Log In
APIs & SDKs

getCollectionTokenCount

🔢 Understanding getCollectionTokenCount

  • getCollectionTokenCount retrieves the number of tokens (NFTs) that belong to a given collection and meet specified conditions, such as having a certain trait or owner address. It takes the following path parameters:

    • chainId - integer.

    • contractAddress - string.

    And the following query parameter:

    • query - JSON string. It's used for filtering or applying a condition to the search.

Query example

const Axios = require("axios");

const projectUuId = 'Your Project Id';
const projectKey = 'Your Project Client Or Server Key';
const chainId = 5; // Goerli
const baseUrl = 'https://api-market.particle.network';
const contractAddress = '0xE860aE9379B1902DC08F67F50de7b9CC066AF0FF';
const url = `${baseUrl}/chains/${chainId}/contractAddress/${contractAddress}/tokens/count`;

(async () => {
    const response = await axios.get(url, {
        params: {
            projectUuid,
            projectKey,
            page: 1,
            limit: 10,
            query: JSON.stringify({
                filter: {
                    attributes: [
                        {
                            trait_type: "HairColor",
                            value: "Orange blonde",
                        },
                    ],
                }
            }),
        },
    });

    console.log(JSON.stringify(response.data));
})();
Language
Click Try It! to start a request and see the response here!