What is an NFT API? A developer's guide

GoldRush TeamUpdated 12 min read

What an NFT API returns, how to choose one, and how to use GoldRush to list a wallet's NFTs, check ownership for token gating and find a collection's holders.

What an NFT API is

An NFT API is a web API that returns data about non-fungible tokens: which NFTs a wallet holds, the name, image and traits of each one, who holds a collection, and whether a wallet owns a given token. You call it over HTTPS with an API key and get JSON back, without running a node or an indexer.

You need one because a blockchain doesn't store that data in a form you can query:

  • No contract lists what a wallet holds. An ERC-721 or ERC-1155 contract records who owns each token ID, but the list of NFTs in one wallet across every collection has to be rebuilt from every Transfer event on the chain.
  • The metadata is usually off-chain. A token stores a tokenURI that points to a JSON file on IPFS or a web server, which in turn points to the image. An NFT API fetches, parses and caches both, so your app doesn't wait on slow or broken hosts.
  • Wallets are full of spam. Anyone can airdrop an NFT to any address, so most wallets hold tokens their owner never asked for. A good NFT API flags them.

What NFT APIs return

Most NFT APIs offer some mix of these:

Data Answers Typical use
Holdings Which NFTs does this wallet hold? Wallets, portfolio trackers, profile pages
Metadata and media What is this token: name, image, traits? Galleries, marketplaces, token pages
Ownership checks Does this wallet hold this collection or token? Token gating, allowlists, games
Holders Who holds this collection? Airdrops, community analytics
Transfers When did this token move, and between whom? Activity feeds, provenance
Market data Floor price, sales, volume Pricing, marketplace analytics

The GoldRush NFT API covers the first four directly: holdings come with metadata, cached images and spam flags in one response, and ownership checks and collection holders each have their own endpoint. Transfers come from the collection's event logs. For market data, each collection in a wallet's holdings carries a floor price (floor_price_quote), but GoldRush has no NFT sales or volume endpoint; use a marketplace API for those.

How to choose an NFT API

  • Chains. Check that the API covers every chain your users hold NFTs on, and which endpoints are limited to fewer chains.
  • ERC-1155 as well as ERC-721. Many collections, game items and editions are ERC-1155, where one token ID can have many holders.
  • Spam filtering. Without it, a wallet view fills with scam airdrops.
  • Media you can show. Cached, resized images load faster and keep working when the original host doesn't.
  • A light response option. A wallet with thousands of NFTs needs a way to list token IDs without the metadata.
  • Pricing you can predict. Per-call credits make a page view's cost easy to work out.

Before you start: API key, wallet, chain and Node.js

  • A GoldRush API key in the GOLDRUSH_API_KEY environment variable. Sign up for the 14-day free trial, which includes 25,000 credits.
  • A wallet address, or an ENS name, which resolves automatically. This guide uses vitalik.eth.
  • The chain name, such as eth-mainnet or base-mainnet.
  • Node.js 18 or later for the JavaScript, which uses the built-in fetch. The JavaScript blocks build on each other: put them in one file, in order, and save it as nfts.mjs, so Node runs it as an ES module and top-level await works (node nfts.mjs).

Step 1: List the NFTs a wallet holds

To get all NFTs for an address, call NFTs for an address (balances_nft). It returns every ERC-721 and ERC-1155 token a wallet holds on one chain, grouped by collection, so a wallet that holds NFTs on several chains takes one call per chain. Add no-spam=true to drop suspected spam:

API=https://api.covalenthq.com/v1 curl "$API/eth-mainnet/address/vitalik.eth/balances_nft/?no-spam=true" \  -H "Authorization: Bearer $GOLDRUSH_API_KEY"

Each item is one collection, with the wallet's tokens from it in nft_data. Here is one, a POAP from 2018, as the API returned it on 19 November 2026, abridged:

{    "contract_name": "POAP",    "contract_address": "0x22c1f6050e56d2876009903609a2cc3fef83b415",    "supports_erc": ["erc165", "erc721"],    "is_spam": false,    "balance": "1",    "type": "nft",    "nft_data": [        {            "token_id": "245",            "token_url": "https://api.poap.tech/metadata/7/245",            "original_owner": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",            "external_data": {                "name": "EDCON",                "description": "Community Ethereum Development Conference",                "image": "https://nftassets.covalenthq.com/dc603a9f….png",                "image_256": "https://nftassets.covalenthq.com/cdn-cgi/image/width=256,fit/dc603a9f….png",                "attributes": [                    { "trait_type": "city", "value": "Toronto" },                    { "trait_type": "country", "value": "Canada" }                ]            },            "image_cached": true        }    ]}
  • supports_erc says whether the collection is ERC-721 or ERC-1155. balance is how many tokens the wallet holds from it.
  • token_url is the token's own metadata URL, and external_data is that metadata, parsed: name, description, image and attributes (the traits).
  • image is the token's image, served from the GoldRush CDN once it is cached. image_256, image_512 and image_1024 are resized copies, 256, 512 and 1,024 pixels wide. image_cached is true when the image is there.
  • asset_url is the token's main media file, which is not always a still image: asset_mime_type (such as image/gif or video/mp4) and asset_file_extension say what it is, and asset_cached is true when it is on the CDN.
  • animation_url is the metadata's own animation link, when the token has one: a video, an audio file or an HTML page.
  • is_spam flags suspected spam. no-spam=true removes those collections, on the Foundational chains.
  • floor_price_quote (with pretty_floor_price_quote and floor_price_native_quote) is the collection's floor price: the lowest sale price in the last 30 days across the markets it trades on, in your quote currency and in the chain's native token.

The same call in JavaScript, keeping each token's name and thumbnail for a gallery. The goldrush helper is reused by every later block:

const API = "https://api.covalenthq.com/v1";const headers = {    Authorization: `Bearer ${process.env.GOLDRUSH_API_KEY}`,}; // One GoldRush call, returning its data. Errors come back as { data: null, error: true, error_code,// error_message }; a request with no Authorization header gets an HTML 401 from the edge instead.async function goldrush(path) {    const res = await fetch(`${API}${path}`, { headers });    const body = await res.json().catch(() => null);    if (!res.ok || !body || body.error) {        throw new Error(`GoldRush ${body?.error_code ?? res.status}: ${body?.error_message ?? res.statusText}`);    }    return body.data;} // The NFTs a wallet holds on one chain, spam removed, as gallery tiles.async function getNfts(chain, wallet) {    const data = await goldrush(`/${chain}/address/${wallet}/balances_nft/?no-spam=true`);    return data.items.flatMap((collection) =>        collection.nft_data.map((nft) => ({            collection: collection.contract_name,            contract: collection.contract_address,            tokenId: nft.token_id,            name: nft.external_data?.name,            image: nft.external_data?.image_256,        }))    );} const nfts = await getNfts("eth-mainnet", "vitalik.eth");console.log(nfts.length, "NFTs");

Render images, video and animated NFTs

A gallery that drops image_256 into an <img> tag shows most NFTs, but not all of them. Video NFTs, GIFs and generative pieces that run as an HTML page need a different element, and some tokens have no cached image yet. Choose what to render per token:

  • Pick the size for the view. Use image_256 for grid thumbnails and lists, image_512 for cards and medium views, and image_1024 for a token's detail page. Use the full-size image only when the user opens the original.
  • Check the media type before you render. If asset_mime_type is text/html, show a sandboxed <iframe>; if it starts with video/, show a <video> with the image as its poster. If only animation_url is set, check what it points to (video, audio or HTML) before you choose the element. A GIF plays in an <img> tag; use asset_url when you want the original file rather than a resized copy.
  • Fall back when nothing is cached. When image_cached is false, there may be no CDN copy yet. Use external_data.image if it is set, or fetch token_url and read the image field from the original metadata. Show a placeholder when both are empty.

Add this to the same file; it takes one item of a collection's nft_data:

// Decide how to show one token from balances_nft: what element, which URL, and the poster image.function nftMedia(nft, view = "thumbnail") {    const meta = nft.external_data ?? {};    const size = { thumbnail: "image_256", card: "image_512", detail: "image_1024" }[view];    const image = (nft.image_cached && meta[size]) || meta.image || null;    const mime = meta.asset_mime_type ?? "";     if (mime === "text/html") {        return { kind: "iframe", src: meta.asset_url ?? meta.animation_url, poster: image };    }    if (mime.startsWith("video/")) {        return { kind: "video", src: meta.asset_url ?? meta.animation_url, poster: image };    }    // An animation_url can be a video, an audio file or an HTML page: check its type before choosing the element.    if (meta.animation_url) return { kind: "animation", src: meta.animation_url, poster: image };    if (image) return { kind: "image", src: image };    // Nothing cached and no image in the parsed metadata: read the original from token_url.    return { kind: "fetch-metadata", src: nft.token_url ?? null };}

For an animation result, check the URL's extension or fetch its Content-Type header to choose between <video>, <audio> and a sandboxed <iframe>. Never render text/html assets inline.

For a wallet with thousands of NFTs, add no-nft-asset-metadata=true: the response is then only collections and token IDs, without metadata or images, and comes back faster.

NFTs for an address works on 12 chains: Ethereum, Polygon, BNB Smart Chain (BSC), Arbitrum, Optimism, Base, Mantle, Linea, zkSync Era, Gnosis, Scroll, and ApeChain.

Step 2: Check ownership for token gating

To gate content, a Discord role or a mint behind a collection, you only need to know whether the wallet holds it. Check ownership in an NFT collection answers that in one call, and returns the tokens it holds. Add this to the same file:

// Does this wallet hold anything in the collection?async function holdsCollection(chain, wallet, collection) {    const data = await goldrush(`/${chain}/address/${wallet}/collection/${collection}/`);    return data.items.length > 0;} const POAP = "0x22c1f6050e56d2876009903609a2cc3fef83b415";console.log(await holdsCollection("eth-mainnet", "vitalik.eth", POAP));
  • One token: to check a single token ID, call Check ownership for a specific token at …/collection/{collection}/token/{tokenId}/.
  • One trait: to gate on a trait, such as every holder of a "Gold" background, add traits-filter and values-filter. Both are case-sensitive and must be URL-encoded.

The ownership checks work on 6 chains: Ethereum, Polygon, Base, Optimism, BNB Smart Chain (BSC), and Gnosis.

Step 3: Find every holder of a collection

The other direction, from a collection to the wallets that hold it, is the Token Holders API. Pass an ERC-721 collection's address to token_holders_v2 and it returns every address that holds at least one token, 1,000 per page:

# Every address holding a Bored Ape Yacht Club NFTAPI=https://api.covalenthq.com/v1BAYC=0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d curl "$API/eth-mainnet/tokens/$BAYC/token_holders_v2/?page-size=1000" \  -H "Authorization: Bearer $GOLDRUSH_API_KEY"

Add date or block-height for the holders at a past block, which is what an airdrop snapshot needs. How to get token holder data pages through the whole list and takes snapshots step by step.

Step 4: Read a collection's transfers

For an activity feed or a token's history, read the collection's Transfer events with log events by contract address (events/address). Each event comes back decoded into its parameters (the sender, the recipient and the token ID), with the transaction and block it happened in. Pass starting-block and ending-block to bound the range. Add this to the same file:

// The Transfer events a collection emitted between two blocks (first page, up to 100 events).async function collectionTransfers(chain, collection, fromBlock, toBlock) {    const qs = new URLSearchParams({ "starting-block": String(fromBlock), "ending-block": String(toBlock) });    const data = await goldrush(`/${chain}/events/address/${collection}/?${qs}`);    return data.items        .filter((log) => log.decoded?.name === "Transfer")        .map((log) => ({            block: log.block_height,            tx: log.tx_hash,            // The decoded parameters by name: for an ERC-721 Transfer, the sender, the recipient and the token ID.            ...Object.fromEntries((log.decoded.params ?? []).map((p) => [p.name, p.value])),        }));} const BAYC = "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d";console.table(await collectionTransfers("eth-mainnet", BAYC, 26_450_000, 26_455_000));

Each event's decoded object has the event name, its signature and a params array of name, type, indexed and value; raw_log_topics and raw_log_data hold the undecoded log. Log events cost 0.01 credits per event returned, and pagination.has_more says when to ask for the next page-number.

Handle errors from the GoldRush NFT API

A failed request returns the same envelope as a successful one, with data set to null, and goldrush throws on it. The error handling docs show this body for a chain the API doesn't serve:

{ "data": null, "error": true, "error_message": "Chain nosuchchain-mainnet not supported.", "error_code": 501 }

A 501 is a stable answer: the chain or endpoint can't serve the request, so retrying it unchanged returns the same error. The NFT endpoints are limited to the chains listed under each step, so check the chain name there. A request with no Authorization header is refused by the edge proxy with an HTML 401 page rather than JSON, which is why goldrush doesn't assume the body parses. Error responses cost no credits.

What the GoldRush NFT endpoints cost in credits

NFTs for an address costs 1 credit per call, whatever the wallet holds. The two ownership checks cost 1 credit per call each. Token holders cost 0.02 credits per holder returned, and log events 0.01 credits per event. The pricing calculator estimates a month of calls.

Frequently asked questions

What is an NFT API?

A web API that returns data about NFTs: the tokens a wallet holds, each token's metadata and image, the holders of a collection, and ownership checks. It indexes the chain and fetches off-chain metadata so your app doesn't have to.

How do I get all NFTs owned by an address?

Call NFTs for an address (balances_nft) once for each chain the wallet uses, with no-spam=true to drop spam collections. It returns every ERC-721 and ERC-1155 token the wallet holds on that chain, with metadata and images. For a wallet with thousands of NFTs, add no-nft-asset-metadata=true to get only collections and token IDs, faster.

How do I display NFT videos and animated NFTs?

Check each token's asset_mime_type and animation_url before rendering. Show a <video> for video, a sandboxed <iframe> for HTML, and the cached image otherwise; when only animation_url is set, check what it points to first. Use image_256 for thumbnails and image_1024 for detail views, and fall back to external_data.image or the metadata at token_url when image_cached is false.

Is there a free NFT API?

GoldRush's 14-day free trial includes 25,000 credits, enough for 25,000 calls to NFTs for an address at 1 credit each.

Does the GoldRush NFT API support ERC-1155?

Yes. NFTs for an address and both ownership checks return ERC-721 and ERC-1155 tokens. supports_erc on each collection says which standard it uses.

Which chains does the GoldRush NFT API support?

NFTs for an address works on 12 chains, including Ethereum, Base, Polygon, Arbitrum and ApeChain. The ownership checks work on 6 chains, and Token Holders on 16.

How do I filter spam NFTs?

Add no-spam=true to NFTs for an address. Suspected spam collections are removed on the Foundational chains, and every collection carries an is_spam flag. The spam lists are also published as an open-source npm package.

Can I get NFT floor prices or sales from GoldRush?

Floor prices, yes: each collection returned by NFTs for an address carries floor_price_quote, the lowest sale price in the last 30 days across the markets it trades on. Sales history and volume, no: GoldRush has no NFT sales endpoint, so use a marketplace API for those.

Next steps

Get new guides by email

New tutorials and best practices for building with blockchain data, sent as they're published.