How to Render the Image Associated with a Collection

This tutorial explains the steps involved in rendering the image associated with a given collection in the Ethereum Mainnet network.

๐Ÿ“˜

Note!

  • Image URLs are returned for the top popular collections. All images are cached by Blockdaemon for quick access.
  • Blockdaemon collects NFT information and data from various third-party sources (โ€œNFT Contentโ€). We do not create, own or control NFT Content, and we do not routinely monitor NFT Content for violations of these Terms. You acknowledge that Blockdaemon has no responsibility or liability related to NFT Content and agree that you must evaluate, and decide for yourself if you wish to use any NFT Content.

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

  • protocol: ethereum

  • network: mainnet

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

Step 2. Add the following parameter:

  • contract address

    • parameter: contract_address
    • value: e.g. 0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D
    https://svc.blockdaemon.com/nft/v1/ethereum/mainnet/collections?contract_address=0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D
    

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/collections?contract_address=0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D' -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 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="
        }
    }
}

Copy the media path from the logo field:

{
    "id": "4203aedd-7964-5fe1-b932-eb8c4fda7822",
    "name": "Bored Ape Yacht Club",
    "logo": "collection/4203aedd-7964-5fe1-b932-eb8c4fda7822/logo.png",
    "contracts": [
        "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D"
    ],
    "verified": true
}

Step 5. Finally, you can render the image.

Use the media endpoint with the media path (copied in the previous step):
collection/4203aedd-7964-5fe1-b932-eb8c4fda7822/logo.png

https://svc.blockdaemon.com/nft/v1/ethereum/mainnet/media/collection/4203aedd-7964-5fe1-b932-eb8c4fda7822/logo.png
  • In your browser, just use the address bar.

  • In Postman, click on the URL in the response. A tab with a new query will open. Run it, and Postman will render the image.

  • In cURL, run the following code to download the image to your working directory:

    curl -X GET 'https://svc.blockdaemon.com/nft/v1/ethereum/mainnet/media/collection/4203aedd-7964-5fe1-b932-eb8c4fda7822/logo.png' --output YOUR_FILENAME.png -H 'Authorization: Bearer YOUR_API_KEY'
    

๐Ÿ“˜

Note!

In all cases, authentication is required. You need to get an API key and use it as a bearer token or a query parameter when accessing the image. Learn more: Authentication Guide