How to Get NFTs with Given Attributes in a Collection

Follow this tutorial to learn how to get NFTs with given attributes in a collection.

This tutorial explains the steps in getting a list of NFTs from any Ethereum Mainnet collection filtered by given attributes.

Step 1. Use the assets endpoint with the following details:

  • protocol: ethereum

  • network: mainnet

    https://svc.blockdaemon.com/nft/v1/ethereum/mainnet/assets
    

Step 2. Add the following parameters:

  • collection name
    • parameter: collection_name
    • value: e.g. Bored Ape Yacht Club
  • attribute 1
    • parameter: attributes
    • value: a key:value pair, e.g. Background:Purple
  • attribute 2
    • parameter: attributes
    • value: a key:value pair, e.g. Earring:Gold Hoop

Note: The attributes filter is case insensitive.

https://svc.blockdaemon.com/nft/v1/ethereum/mainnet/assets?collection_name=Bored Ape Yacht Club&attributes=Background:Purple&attributes=Earring:Gold Hoop

Step 3. Execute the query.

For example, in cURL, you should run the following code:

curl -X GET 'https://svc.blockdaemon.com/nft/v1/ethereum/mainnet/assets?collection_name=Bored%20Ape%20Yacht%20Club&attributes=Background:Purple&attributes=Earring:Gold%20Hoop' -H 'Authorization: Bearer YOUR_API_KEY'

📘

Note!

  • To authorize your request, you need to get an API key and use it as a bearer token or a query parameter. Learn more: Authentication Guide
  • Sometimes collection names and attributes contain whitespaces. When using cURL, replace them with %20.

Step 4. Your results will look something like this:

{
    "data": [
        {
            "id": "5e1f4454-34ff-5118-9987-96b481625128",
            "token_id": "9999",
            "image_url": "token/0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D/5e1f4454-34ff-5118-9987-96b481625128.png",
            "name": "#9999",
            "contract_address": "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D",
            "wallets": [],
            "burned": false
        },
        {...more assets...}
    ],
    "meta": {
        "paging": {
            "next_page_token": "eyJ0b2tlbl9pZCI6OTgyOCwidWlkIjoiNjMzOWIzMWYtNjg1Yi01ZDA1LWIyNmYtNDliNTc2M2E0ZDUzIn0="
        }
    }
}

This query finds all NFTs with a purple background and a gold hoop earring. The response does not contain attributes, but you can get them with another endpoint:

👋 Need Help?

Contact us through email or our support page for any issues, bugs, or assistance you may need.