How to Get All the NFTs in a Collection, Sorted by Rarity Rank

Follow this tutorial to learn how to get all the NFTs in a collection, sorted by rarity rank.

This tutorial explains the steps in getting a list of all the NFTs in any Ethereum Mainnet collection, sorted by rarity rank from the highest to the lowest.

Step 1. Use the collections or collections search endpoint to get an NFT collection or a list of collections.

Step 2. Copy a collection ID from the id field:

{
    "id": "4203aedd-7964-5fe1-b932-eb8c4fda7822",
    "name": "Bored Ape Yacht Club",
    ...more properties...
}

Step 3. Use the assets with rarity endpoint with the following details:

  • protocol: ethereum

  • network: mainnet

  • collection ID: 4203aedd-7964-5fe1-b932-eb8c4fda7822 (copied in the previous step)

    https://svc.blockdaemon.com/nft/v1/ethereum/mainnet/assets/rarity/4203aedd-7964-5fe1-b932-eb8c4fda7822
    

Step 4. Add the following parameter:

  • sorting method

    • parameter: sort_by
    • value: rarity_rank
    https://svc.blockdaemon.com/nft/v1/ethereum/mainnet/assets/rarity/4203aedd-7964-5fe1-b932-eb8c4fda7822?sort_by=rarity_rank
    

Step 5. 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/rarity/4203aedd-7964-5fe1-b932-eb8c4fda7822' -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

Step 6. 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",
            "rarity": [
                {
                    "model": "open_rarity",
                    "score": 0.9954297307820068,
                    "rank": "5327"
                }
            ]
        },
        {...more assets...}
    ],
    "meta": {
        "paging": {
            "next_page_token": "eyJ0b2tlbl9pZCI6OTgyOCwidWlkIjoiNjMzOWIzMWYtNjg1Yi01ZDA1LWIyNmYtNDliNTc2M2E0ZDUzIn0="
        }
    }
}

👋 Need Help?

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