How to surface newly-minted collections in real-time

Did you know that there are over 10,000 new NFT collections minted every month on Ethereum alone? That averages out to about 14 new collections per hour. 🤯

Surfacing new collections as they are minted can be valuable for many applications including but not limited to trading insights tools, marketplaces, and general NFT discovery experiences. However, given the quantity of new collections appearing on chain, manually surfacing and tracking newly-minted collections would be extremely time-consuming and tedious work. Keeping up with new collections in real-time could easily be a full time job, but it doesn't have to be.

Mnemonic's APIs make it extremely easy to surface new collections in real-time so you can build discovery, tracking, and analytics experiences with ease.

Our data is updated every 2 minutes on average, or as soon as the data is validated on the blockchain, meaning we can provide instant access to all historical and new collections on the blockchain. Since our data encompasses the entire blockchain, we can surface all collections regardless of which marketplace they are listed on.

Mnemonic indexes contracts not just at the metadata and standards implementation level, but at the bytecode level too. This allows us to more accurately detect various contract types and other properties of the contracts.

Read more about the contract types and standards Mnemonic currently supports here.

In this tutorial we'll show you how to identify new collections with just a single API call.

Get new NFT collections

To get newly-minted collections we will use the All Contracts endpoint. This endpoint is available on Polygon as well.

This endpoint, by default, returns all contract types, including ERC20 contracts. So, we'll need to reduce our result to include only NFT collections. We can do this by using one of the following types:

  • TOKEN_TYPE_ERC721
  • TOKEN_TYPE_ERC1155
  • TOKEN_TYPE_ERC721_LEGACY
  • TOKEN_TYPE_CRYPTOPUNKS

The default sorting key for collections is mint timestamp. By using sortDirection you can specify the direction of the sorting to get the most recent or the oldest collections.

curlpythongo
Copy
Copied
curl -i -X GET \
  'https://ethereum.rest.mnemonichq.com/contracts/v1beta1/all?limit=10&offset=0&sortDirection=SORT_DIRECTION_DESC&contractTypes=TOKEN_TYPE_ERC721' \
  -H 'X-API-Key: YOUR_API_KEY_HERE'
Copy
Copied
import requests # requires `pip install requests`

result = requests.get(
    'https://ethereum.rest.mnemonichq.com/contracts/v1beta1/all?limit=10&offset=0&sortDirection=SORT_DIRECTION_DESC&contractTypes=TOKEN_TYPE_ERC721',
    headers={'x-api-key': 'YOUR_API_KEY_HERE'}
).json()
Copy
Copied
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {
  reqUrl := "https://ethereum.rest.mnemonichq.com/contracts/v1beta1/all"
  req, _ := http.NewRequest("GET", reqUrl, nil)

  query := req.URL.Query()
  query.Add("limit", "10")
  query.Add("offset", "0")
  query.Add("sortDirection", "SORT_DIRECTION_DESC")
  query.Add("contractTypes", "TOKEN_TYPE_ERC721")
  req.URL.RawQuery = query.Encode()

  req.Header.Add("X-API-Key", "YOUR_API_KEY_HERE")
  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}

We can use the blockTimestampGt request parameter to get collections minted after a certain timestamp. This is especially useful for continuous tracking by using exclusive greater comparison.

The result will look something like this:

Copy
Copied
{
    "contracts": [
        {
            "type": "TOKEN_TYPE_ERC721",
            "mintEvent": {
                "blockTimestamp": "2022-07-10T23:15:16Z",
                "txHash": "0x0d81248958c7d7c803cec3b7809bacfdf3cf86872dcbae6b34b26511b80f38e2",
                "minterAddress": "0xc5c0f482b561cf2ff5e2206b4e21ec749111ab63"
            },
            "name": "SAUDIBIRDS",
            "symbol": "SB",
            "decimals": 0,
            "address": "0xc07f748b65456b37d5fb3cebcfbd4bcd42589565",
            "types": [
                "TOKEN_TYPE_ERC721"
            ]
        },
        {
            "type": "TOKEN_TYPE_ERC721",
            "mintEvent": {
                "blockTimestamp": "2022-07-10T23:14:55Z",
                "txHash": "0xcdf5fb45b678d3e991f6ef4ee7dc2db2bf1703129e4e7e5462f3426add0360c3",
                "minterAddress": "0x4ecbac578acd7f9928a3d0f7e0b7ec0d54a7e3b5"
            },
            "name": "RamenDAO by CNC",
            "symbol": "RAMEN",
            "decimals": 0,
            "address": "0x9fda027e32446fc9eba720446efa98beba62d9dc",
            "types": [
                "TOKEN_TYPE_ERC721"
            ]
        },
        {
            "type": "TOKEN_TYPE_ERC721",
            "mintEvent": {
                "blockTimestamp": "2022-07-10T23:14:16Z",
                "txHash": "0x309e554c39287b01f854c7859f3d0058cd452552fe52f89038554b73faf0d3f4",
                "minterAddress": "0x8636fa411113d1b40b5d76f6766d16b3aa829d30"
            },
            "name": "Gregs (ETH)",
            "symbol": "GREG",
            "decimals": 0,
            "address": "0x7ffe2672c100bfb0094ad0b4d592dd9f9416f1ac",
            "types": [
                "TOKEN_TYPE_ERC721"
            ]
        },
        {
            "type": "TOKEN_TYPE_ERC721",
            "mintEvent": {
                "blockTimestamp": "2022-07-10T22:58:10Z",
                "txHash": "0xe13ba35cf8e197fce4406d27f26d4f161819249d01f6d8677cfdca85ef1e146f",
                "minterAddress": "0x4db337964306805972a7dfef9a4ccc24206c5311"
            },
            "name": "Influencer Punks",
            "symbol": "IPKS",
            "decimals": 0,
            "address": "0xda2287704b1f1be690fbe5bf33bf13dc2af1ace4",
            "types": [
                "TOKEN_TYPE_ERC721"
            ]
        },
        {
            "type": "TOKEN_TYPE_ERC721",
            "mintEvent": {
                "blockTimestamp": "2022-07-10T22:58:10Z",
                "txHash": "0x3ebca0a6822a568e35553bb6682391586378784b80905901424f67e86d84df12",
                "minterAddress": "0xbc8f7b371f64fee0186c6ee4a838940365b69609"
            },
            "name": "HomelessFriends",
            "symbol": "HomelessFriends",
            "decimals": 0,
            "address": "0x47de46c0d4d178ded8eda96927405dad26d11ba1",
            "types": [
                "TOKEN_TYPE_ERC721"
            ]
        },
        {
            "type": "TOKEN_TYPE_ERC721",
            "mintEvent": {
                "blockTimestamp": "2022-07-10T22:55:49Z",
                "txHash": "0xf2e477ea92908153c56fb53219986c9915b9ed8124b49fbcb8ff19736de6e6ec",
                "minterAddress": "0x70b71dc811b55e0c914cc326e025ef159da211ab"
            },
            "name": "EMRE2'S",
            "symbol": "EMRE2",
            "decimals": 0,
            "address": "0x836954e67e3b3c7d2d7f00c82313e0dec80c52f3",
            "types": [
                "TOKEN_TYPE_ERC721"
            ]
        },
        {
            "type": "TOKEN_TYPE_ERC721",
            "mintEvent": {
                "blockTimestamp": "2022-07-10T22:52:38Z",
                "txHash": "0x4c3c379de84944cdf35c22a455cd42a5c6f267d1d8fc1df22df5acc55b7c5eb2",
                "minterAddress": "0x263ec9e189d5e15b806670203e3914780d2cadbf"
            },
            "name": "RektPepeRenaissance",
            "symbol": "RPR",
            "decimals": 0,
            "address": "0xc507e905f71605488c506f5c4b531d6db7fb0862",
            "types": [
                "TOKEN_TYPE_ERC721"
            ]
        },
        {
            "type": "TOKEN_TYPE_ERC721",
            "mintEvent": {
                "blockTimestamp": "2022-07-10T22:48:44Z",
                "txHash": "0xc9f35ea6206e26325e40c4c21515b9f595f8c049beef235f76ece1f874ca6487",
                "minterAddress": "0x24bcda4af1321ce993bb11832c5a17872a5ccf24"
            },
            "name": "MONSTERS",
            "symbol": "MONSTERS",
            "decimals": 0,
            "address": "0x90005f3155fd9df3fefd9c397d5af3adda7aa371",
            "types": [
                "TOKEN_TYPE_ERC721"
            ]
        },
        {
            "type": "TOKEN_TYPE_ERC721",
            "mintEvent": {
                "blockTimestamp": "2022-07-10T22:31:13Z",
                "txHash": "0x912e130ddeb676406795a0679011007de01a071f619310af467470f210a006ca",
                "minterAddress": "0xb473055711531843b20badc43a00563879333080"
            },
            "name": "BoredSword",
            "symbol": "BRSD",
            "decimals": 0,
            "address": "0x3a835b59ce2bd13ef7251901dce23dc95c86e492",
            "types": [
                "TOKEN_TYPE_ERC721"
            ]
        },
        {
            "type": "TOKEN_TYPE_ERC721",
            "mintEvent": {
                "blockTimestamp": "2022-07-10T22:30:30Z",
                "txHash": "0x7c92023e471655dba8e64cb51e374db15756e6d647887f895e6ab6c562030d53",
                "minterAddress": "0xe354127e1b7fc1b153281a914147991a8b312aab"
            },
            "name": "Pixel Portrait Art",
            "symbol": "PPART",
            "decimals": 0,
            "address": "0xcffd0f354e38f3bfcea7ad9d7d3754aca029414b",
            "types": [
                "TOKEN_TYPE_ERC721"
            ]
        }
    ]
}

Get collection metadata

Additionally, you can request more detailed information about a contract using the Contract Details endpoint.

Note: Some contracts may implement multiple standards (polymorphic contracts). In these cases, the types field in the response is plural. Read more about polymorphic contracts here.

curlpythongo
Copy
Copied
curl -i -X GET \
  https://ethereum.rest.mnemonichq.com/contracts/v1beta1/by_address/0x5bdf47c6691edf5d2e5f7a156324d88e1478fca6 \
  -H 'X-API-Key: YOUR_API_KEY_HERE'
Copy
Copied
import requests # requires `pip install requests`

result = requests.get(
    'https://ethereum.rest.mnemonichq.com/contracts/v1beta1/by_address/0x5bdf47c6691edf5d2e5f7a156324d88e1478fca6',
    headers={'x-api-key': 'YOUR_API_KEY_HERE'}
).json()
Copy
Copied
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {
  contractAddress := "0x5bdf47c6691edf5d2e5f7a156324d88e1478fca6";
  reqUrl := "https://ethereum.rest.mnemonichq.com/contracts/v1beta1/by_address/" + contractAddress
  req, _ := http.NewRequest("GET", reqUrl, nil)
  req.Header.Add("X-API-Key", "YOUR_API_KEY_HERE")
  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}

The result based on the parameters above will look like:

Copy
Copied
{
    "contract": {
        "type": "TOKEN_TYPE_ERC721",
        "mintEvent": {
            "blockTimestamp": "2022-07-09T00:36:13Z",
            "txHash": "0x9fd267b0375e64460ceb35b18dafc9ae5ac392e424bbbd43e54eefdaf0a27a11",
            "minterAddress": "0x183fed6aa2c50016222ea209cd70ac60781dce2e"
        },
        "name": "Bagner",
        "symbol": "BAG",
        "decimals": 0,
        "address": "0x5bdf47c6691edf5d2e5f7a156324d88e1478fca6",
        "types": [
            "TOKEN_TYPE_ERC721"
        ]
    }
}

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 support@mnemonichq.com!