How to find, label, and filter out spam NFTs

Spam collections are a significant problem plaguing NFT collectors and builders alike. Identifying spam (and, often filtering it out) is an important step developers can take to keep users safe from scams while also providing the best possible user experience. That said, it is increasingly difficult to accurately and comprehensively identify spam, especially given how many NFT collections there are and how sophisticated some of the tactics employed by bad actors and spammy collections are today.

Luckily, Mnemonic’s got you covered. Our team has developed proprietary spam detection capabilities powered by machine learning that detect even the sneakiest of spam collections and spam NFTs. We’ve brought our cutting-edge spam detection capabilities to our Ethereum API and our Polygon API to help you create safer, even more delightful user experiences by flagging, or even filtering out completely, NFTs from spam collections.

Let’s take a closer look at how easy it is to use Mnemonic’s API to identify and filter out spem in your wallet, shall we?

To get started, you’ll need a Mnemonic API key and the ENS name or wallet address you’d like to explore.

See which NFTs in your wallet are spam

Let’s say you’re creating a wallet experience and you want to have the option of enabling your users to see everything they own, but want to flag the items that are spam. We’ve made this very easy to do with our get NFTs by owner endpoint, which not only returns a list of all the NFTs in a wallet, but also labels NFTs from spam collections.

Our Wallet Intelligence NFTs Owned endpoint allows you to retrieve a list of all tokens in a given wallet. The response includes a field indicating whether each token returned is spam. You can use this to flag spam in your end user experience.

Here's how it works:

First, we'll call the Tokens by Owner endpoint like this:

curl -i -X GET \
'https://ethereum-rest.api.mnemonichq.com/wallets/v1beta2/bored.eth/nfts' \
 -H 'X-API-Key: YOUR_API_KEY_HERE'

The result will look something like this:

{
  "tokens": [
    {
      "contractAddress": "0x00c396383400a1ef2eb401052dbf5d989b2da481",
      "tokenId": "2884",
      "metadata": {
        "metadataUri": {
          "uri": "https://api.cyphercity.io/2884",
          "mimeType": "application/json"
        },
        "name": "2884",
        "description": "A collection of 8,888 randomly generated NFT Cyphers. Owning a Cypher gains its holder access to exclusive events and to explore Cypher City.",
        "image": {
          "uri": "https://ethereum.cdn.mnemonichq.com/0x00c396383400a1ef2eb401052dbf5d989b2da481/2884/f0184fee18b301dc54d9d80c2fb1bbb83af76928621908c14f534f3d83135e77.png",
          "uriOriginal": "ipfs://QmaPT8rpPDCJsWmaUz9AnXsRqXfM9vgmxTeenwd9H9gZqY/2884.png",
          "mimeType": "image/png"
        }
      },
      "quantity": "1",
      "spam": false
    },
    {
      "contractAddress": "0x00c396383400a1ef2eb401052dbf5d989b2da481",
      "tokenId": "8401",
      "metadata": {
        "metadataUri": {
          "uri": "https://api.cyphercity.io/8401",
          "mimeType": "application/json"
        },
        "name": "8401",
        "description": "A collection of 8,888 randomly generated NFT Cyphers. Owning a Cypher gains its holder access to exclusive events and to explore Cypher City.",
        "image": {
          "uri": "https://ethereum.cdn.mnemonichq.com/0x00c396383400a1ef2eb401052dbf5d989b2da481/8401/b1ceed7ad3ef6e89d81cbbd52432f9475ee999f6c44dc58bf8660c25686ffb75.png",
          "uriOriginal": "ipfs://QmaPT8rpPDCJsWmaUz9AnXsRqXfM9vgmxTeenwd9H9gZqY/8401.png",
          "mimeType": "image/png"
        }
      },
      "quantity": "1",
      "spam": false
    },
    {
      "contractAddress": "0x01a0d1ed6d12e7f425dd26df7b5ebdd72eeef109",
      "tokenId": "8",
      "metadata": {
        "metadataUri": {
          "uri": "https://lockedkongs.net/json/8",
          "mimeType": "application/json"
        },
        "name": "Locked Kongs #8",
        "description": "[Unlock the kongs](https://lockedkongs.net) for new NFT [https://lockedkongs.net](https://lockedkongs.net). Supremekongs are locked by hunters.You can't sell before unlock him.You have kingkong nft with keys at his neck to open that. The kongs will give you upgraded nft to save his life.Visit our site and watch what will happen! ▶[Lockedkongs Official Website](https://lockedkongs.net).[Free the kongs at the site.](https://lockedkongs.net)",
        "image": {
          "uri": "https://ethereum.cdn-proxy.mnemonichq.com/0x01a0d1ed6d12e7f425dd26df7b5ebdd72eeef109/8",
          "uriOriginal": "https://lockedkongs.net/kong.jpg",
          "mimeType": "image/jpeg"
        }
      },
      "quantity": "1",
      "spam": false
    },
    {
      "contractAddress": "0x01e1c1cb7e5de465d7e6294b8c25c9967627347e",
      "tokenId": "285",
      "metadata": {
        "metadataUri": {
          "uri": "https://chumchums.site/ipfs/285",
          "mimeType": "application/json"
        },
        "name": "Chum Chum #285",
        "description": "A collection of 1,000 cute NFTs bringing 'chums' together, putting a smile on everyone's faces & evoking a sense of nostalgia through fun and friendly artwork. Visit [Website](https://chumchums.site) and Let us all SMILE!",
        "image": {
          "uri": "https://ethereum.cdn-proxy.mnemonichq.com/0x01e1c1cb7e5de465d7e6294b8c25c9967627347e/285",
          "uriOriginal": "ipfs://QmXcSqfgLDPWaZBxrM3fxWenaE9nTDQGGtC59twFsphf92/2601.png",
          "mimeType": "image/png"
        }
      },
      "quantity": "1",
      "spam": true
    },
    <results trimmed>

Filter out spam NFTs from your wallet

You’ve just seen how labeling spam NFTs can help keep your users informed regarding what’s in their wallets. But what if you want to create an experience that’s not haunted by spam NFTs? This can easily be accomplished using filters to exclude spam in the response.

Here's how it would look:

curl -i -X GET \
'https://ethereum-rest.api.mnemonichq.com/wallets/v1beta2/bored.eth/nfts?spam=SPAM_FILTER_EXCLUDE' \
 -H 'X-API-Key: YOUR_API_KEY_HERE'

And the response would look the same as the example above, just without any tokens labeled as spam.

If you’re super curious about spam, you can generate a list of ONLY spam NFTs to take a closer look at them, just change your filter to SPAM_ONLY as shown below

curl -i -X GET \
'https://ethereum-rest.api.mnemonichq.com/wallets/v1beta2/bored.eth/nfts?spam=SPAM_FILTER_ONLY' \
 -H 'X-API-Key: YOUR_API_KEY_HERE'

Curious about whether you have spam in your own wallet? You might be surprised. Run the query yourself to find out. ;)

After you've completed this tutorial, let us know about your experience or if you have any feedback by tagging us on Twitter @mnemonichq or reaching out directly to our [email protected]!