What's the best way to retrieve NFT collection names using Etherscan API?

I’m trying to build a project that needs NFT data and I’m stuck on something basic.

I need to fetch collection names for different NFT tokens but I’m not sure how to do this properly. I’ve been looking at Etherscan but there are so many endpoints and I can’t figure out which one gives me the collection info.

Has anyone worked with NFT data extraction before? I’m specifically looking for:

  • Collection names for tokens
  • Maybe some other basic metadata

I’ve tried a few approaches but nothing seems to work correctly. Some people mentioned using the blockchain directly but that sounds complicated. Is there a simpler way to get this information?

// Something like this maybe?
const apiKey = 'YOUR_API_KEY';
const contractAddress = '0x1234...';

function fetchCollectionData(address) {
    // What endpoint should I use here?
    const url = `https://api.etherscan.io/api?module=???`;
    return fetch(url);
}

Any help would be great!

hmm this is interesting! i’ve been messing around with similar stuff lately and ran into the same roadblocks. quick question though - are you trying to get collection names for specific contracts you already know about, or are you looking to discover collections dynamically?

if you already have the contract addresses, there’s actually a pretty straightforward approach using etherscan that the others didn’t mention. you can use the module=proxy&action=eth_call endpoint to directly call the contract’s name() function. something like:

const getData = async (contractAddr) => {
    const functionSig = '0x06fdde03'; // name() function signature
    const url = `https://api.etherscan.io/api?module=proxy&action=eth_call&to=${contractAddr}&data=${functionSig}&tag=latest&apikey=${apiKey}`;
    // then decode the hex response
}

but what kind of project are you building exactly? depending on your use case, you might need more than just collection names. are you planning to track specific collections over time or just need a one-time data pull?

also, have you considered rate limiting issues? etherscan can be pretty strict about that stuff, especially on the free tier. might be worth thinking about caching strategies early on.

what’s your experience level with web3 stuff in general? wondering if there are other approaches that might work better for your specific situation!

etherscan’s api doesn’t return collection names directly. you’ll need to hit the contract endpoint for basic info, then call the contract’s name() function. use module=contract&action=getsourcecode with your contract address - gets you the verified contract details. but honestly? just use opensea’s api or alchemy instead. way easier for nft data.

Unfortunately, Etherscan’s API is not intended for retrieving NFT metadata like collection names. You’ll be able to access general contract information through their token endpoints, but that won’t suffice for your needs. Based on my own experience, using dedicated NFT APIs is the way to go for this type of data. OpenSea’s API, for instance, provides endpoints specifically for collections, which include names and detailed metadata. Alternatively, you can use Moralis, which simplifies the process even further. If you’re considering the blockchain approach, you can call the contract’s name() function with web3 or ethers.js; however, for comprehensive metadata that includes IPFS lookups, specialized NFT APIs will serve you much better.