This Python script downloads all NFT images from a specific Solana collection, using the Helius Digital Asset Standard (DAS) API. It's currently configured to download images from the DeGods collection as an example.
- Fetches NFT details using the Helius DAS API (
getAssetsByGroup
method). - Handles pagination to retrieve all assets in a collection.
- Parses metadata to find image URLs (including from
json_uri
and directfiles
entries). - Handles Arweave (
ar://
) image URLs. - Saves images into a structured directory (
nft_images/COLLECTION_NAME/
). - Robust error handling for API requests and image downloads.
- Python 3.7+
- A Helius API Key: You can get one from Helius Developer Portal.
-
Clone the repository (or download the script):
# If you've set up a Git repo: git clone https://github.com/YOUR_USERNAME/NFT-Image-Fetcher.git cd NFT-Image-Fetcher
Alternatively, download
solana_nft_image_downloader.py
directly into a folder on your computer. -
Install the required Python library: The script primarily uses the
requests
library. If you don't have it, install it via pip:pip install requests
-
Navigate to the script's directory: Open your terminal or command prompt and change to the directory where
solana_nft_image_downloader.py
is located. -
Run the script:
python solana_nft_image_downloader.py
-
Enter your Helius API Key: When prompted, enter your Helius API key. The script will attempt to parse the key even if you paste a full Helius RPC URL containing the API key.
This script will download images for the DeGods collection (6XxjKYFbcndh2gDcsUrmZgVEsoDxXMnfsaGY6fpTJzNr). It uses the Helius Digital Asset Standard (DAS) API. Enter your Helius API Key: YOUR_API_KEY_HERE
-
Download Process:
- The script will first fetch the list of all NFTs in the DeGods collection using the Helius API. This may take a few moments depending on the collection size and API response times.
- Once the list is retrieved, it will proceed to download the image for each NFT.
- Images will be saved in a folder named
nft_images/DeGods/
within the same directory as the script. - The console will show progress and any errors encountered.
To adapt this script for a different Solana NFT collection:
-
Find the Collection Mint Address: Locate the verified "Collection Mint" address for the target collection. You can usually find this on Solana explorers like Solscan or NFT marketplaces by looking at the details of an NFT from that collection.
-
Update the Script: Open
solana_nft_image_downloader.py
in a text editor and modify these lines at the top of the script:# DeGods Collection Mint Address (verified collection key) DEGCDS_COLLECTION_MINT_ADDRESS = "NEW_COLLECTION_MINT_ADDRESS_HERE" # ... # In main(): collection_name = "YourNewCollectionName" # For directory naming
- Replace
"NEW_COLLECTION_MINT_ADDRESS_HERE"
with the actual collection mint address. - Change
"DeGods"
in thecollection_name
variable assignment within themain()
function to a suitable name for your collection (this will be used for the output directory).
- Replace
- Helius API Key: A valid Helius API key is essential for this script to function. The free tier should be sufficient for moderate use, but for very large collections or frequent use, consider their paid plans.
- Rate Limiting: While the script includes small delays between paged API requests and image downloads to be considerate to servers, aggressive use might still encounter rate limiting from Helius or the image hosting services.
- Error Handling: The script includes error handling for common issues (network timeouts, HTTP errors, missing image URLs). If an image for a particular NFT cannot be fetched, it will be skipped, and an error message will be printed.
- Disk Space: Ensure you have sufficient disk space, as NFT image collections can be large.
This script is provided for educational and personal use. Always respect the terms of service of any APIs or websites you interact with. The developers are not responsible for any misuse or for any issues arising from its use.