Get full historical & current NFT collection prices

Getting NFT sales data and tracking it over time can be a demanding task. First, you need to establish a way to continuously index and aggregate large volumes of data, then you need to ingest real-time and historical trades across the blockchain while also tackling the complexities of blockchain transaction taxonomy in order to properly calculate price attribution for every NFT sale.

Mnemonic solves these complexities by ingesting all historical and real-time data from across the blockchain (across all marketplaces and protocols from genesis block) and uses state of the art algorithms to aggregate billions of transactions and compute pricing attribution per each NFT sale, making it possible to track NFT sales and pricing with a single API call and a sub-second latency.

Our data is updated every 15 minutes, which means every 15 minutes you get up to date time-series data for every collection and NFT across the entire blockchain no matter where the sale happened.

We provide data as a zero-padded time-series, making it very easy to integrate it directly with your favourite graph charting libraries to create beautiful real-time graphs. See the official World of Women collection dashboard as an example.

In this tutorial, we'll show you how to get NFT pricing data so you can create your own collection pricing charts.

Step 1: Get pricing information for a collection

In this section you will learn how to get the most recent pricing information for a collection.

We will use the CoolCats collection (0x1a92f7381b9f03921564a437210bb9396471050c) as our example in this tutorial and the Prices by contract endpoint to obtain time-series data.

Note: Mnemonic aggregates data from the entire blockchain. As a result, you will likely find more sales and price data than you'd see by looking at any given marketplace alone (such as OpenSea or LooksRare). Our results include all sales across all marketplaces, protocols, and other types of sales (i.e. direct sales or custom contract trading etc).

You can use use theduration, timestampLt, and groupByPeriod parameters to control the time period, starting timestamp, and aggregation to further refine your results.

curlpythongo
Copy
Copied
curl -i -X GET \
  'https://ethereum.rest.mnemonichq.com/pricing/v1beta1/prices/by_contract/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d?duration=DURATION_30_DAYS&groupByPeriod=GROUP_BY_PERIOD_1_DAY' \
  -H 'X-API-Key: YOUR_API_KEY_HERE'
Copy
Copied
import requests # requires `pip install requests`

result = requests.get(
    'https://ethereum.rest.mnemonichq.com/pricing/v1beta1/prices/by_contract/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d?duration=DURATION_30_DAYS&groupByPeriod=GROUP_BY_PERIOD_1_DAY',
    headers={'x-api-key': 'YOUR_API_KEY_HERE'}
).json()
Copy
Copied
type Result struct {
	DataPoints []DataPoint `json:"dataPoints"`
}

type DataPoint struct {
	Timestamp time.Time `json:"timestamp"`
	Min       string    `json:"min"`
	Max       string    `json:"max"`
	Avg       string    `json:"avg"`
}

func getTopCollectionsBySalesVolume() ([]DataPoint, error) {
    // Setup HTTP client.
    var client http.Client

    endpoint := "https://ethereum.rest.mnemonichq.com/pricing/v1beta1/prices/by_contract/0x1a92f7381b9f03921564a437210bb9396471050c?duration=DURATION_30_DAYS&group_by_period=GROUP_BY_PERIOD_1_DAY"

    // Create a request.
    req, err := http.NewRequest("GET", endpoint, nil)
    if err != nil {
      return nil, err
    }

    // Set you API key to make the request.
    req.Header.Add("X-API-Key", "<API-KEY>")

    // Execute the request

    ...

    // Unmarshall the result.
    var result *Result
    if err := json.Unmarshal(body, &result); err != nil {
      return nil, err
    }

    return result.DataPoints, nil
}

Below is a sample response with the collection pricing time series.

Step 2: Get ready to chart pricing data

Now that you have built a simple client to obtain the time series, you can easily chart these data points using one of many libraries.

Note: Pricing data is fully normalized into ETH (or other native coin such as MATIC on Polygon) and encompases all kinds of payments, including ERC20 tokens converted into native currency according to the exchange rate. Mnemonic uses and constantly improves its state of the art algorithms to compute precise price attribution per each NFT sale, which covers cases like bundles, refunds, circular sales, MEV and more.

Copy
Copied
{
  "dataPoints": [
    {
      "timestamp": "2022-02-15T00:00:00Z",
      "min": "6.97294264270960365965",
      "max": "50.8331353261580835",
      "avg": "14.79353255385015358496"
    },
    {
      "timestamp": "2022-02-16T00:00:00Z",
      "min": "7.1386253140201578",
      "max": "15.505",
      "avg": "11.7670802909876713"
    },
    {
      "timestamp": "2022-02-17T00:00:00Z",
      "min": "9",
      "max": "12.489305730046385025",
      "avg": "10.870672455112949096"
    },
    {
      "timestamp": "2022-02-18T00:00:00Z",
      "min": "8.5907721568862331931",
      "max": "15.5",
      "avg": "9.8518616465657983891"
    },
    {
      "timestamp": "2022-02-19T00:00:00Z",
      "min": "9.5",
      "max": "51.45",
      "avg": "19.1852"
    },
    {
      "timestamp": "2022-02-20T00:00:00Z",
      "min": "8.99683431974720083794",
      "max": "18.2839276410731593",
      "avg": "11.97278237430084120806"
    },
    {
      "timestamp": "2022-02-21T00:00:00Z",
      "min": "0.607105079061240182",
      "max": "12.999",
      "avg": "9.42521958328160091715"
    },
    {
      "timestamp": "2022-02-22T00:00:00Z",
      "min": "8.5",
      "max": "10.49",
      "avg": "9.26611756595943416057"
    },
    {
      "timestamp": "2022-02-23T00:00:00Z",
      "min": "5.7738916835317326",
      "max": "30.007864173902709",
      "avg": "9.8081656177333211112"
    },
    {
      "timestamp": "2022-02-24T00:00:00Z",
      "min": "5.0630695525010376",
      "max": "12.4999338687156329625",
      "avg": "7.44586680223080615699"
    },
    {
      "timestamp": "2022-02-25T00:00:00Z",
      "min": "7.3335527087279582",
      "max": "15.016318812779348",
      "avg": "9.16426353582465328659"
    },
    {
      "timestamp": "2022-02-26T00:00:00Z",
      "min": "6.4103616915108714",
      "max": "11.7528411855479483",
      "avg": "8.7353449643392925"
    },
    {
      "timestamp": "2022-02-27T00:00:00Z",
      "min": "7.3454679001095772",
      "max": "12.9972063938498704",
      "avg": "8.5959050424105602"
    },
    {
      "timestamp": "2022-02-28T00:00:00Z",
      "min": "6.13690821685845373672",
      "max": "12.7132838857428602",
      "avg": "8.77169867031828102405"
    },
    {
      "timestamp": "2022-03-01T00:00:00Z",
      "min": "7.3",
      "max": "11.6931000659889379",
      "avg": "8.403293136929195"
    },
    {
      "timestamp": "2022-03-02T00:00:00Z",
      "min": "7",
      "max": "22.005",
      "avg": "8.92566533176642713205"
    },
    {
      "timestamp": "2022-03-03T00:00:00Z",
      "min": "5.0709835225515824",
      "max": "12.0185377412944164",
      "avg": "7.7874274509159977176"
    },
    {
      "timestamp": "2022-03-04T00:00:00Z",
      "min": "2.9988329024491092",
      "max": "20.505",
      "avg": "7.66348181904947625864"
    },
    {
      "timestamp": "2022-03-05T00:00:00Z",
      "min": "2.005",
      "max": "12.005",
      "avg": "7.6910781098050575"
    },
    {
      "timestamp": "2022-03-06T00:00:00Z",
      "min": "7.2",
      "max": "17.9923145681694456",
      "avg": "8.9904175895856177338"
    },
    {
      "timestamp": "2022-03-07T00:00:00Z",
      "min": "5.99",
      "max": "9.45",
      "avg": "7.36101548657219523245"
    },
    {
      "timestamp": "2022-03-08T00:00:00Z",
      "min": "5.9",
      "max": "12",
      "avg": "6.9345315754709314328"
    },
    {
      "timestamp": "2022-03-09T00:00:00Z",
      "min": "3.8026821358690152",
      "max": "24.99",
      "avg": "7.4734929809800015"
    },
    {
      "timestamp": "2022-03-10T00:00:00Z",
      "min": "6.89",
      "max": "10.9",
      "avg": "7.9749418382886637"
    },
    {
      "timestamp": "2022-03-11T00:00:00Z",
      "min": "3.4569166010292201",
      "max": "10.002154729671409",
      "avg": "7.7699366195536225"
    },
    {
      "timestamp": "2022-03-12T00:00:00Z",
      "min": "6.3822484038549675",
      "max": "26.0312",
      "avg": "10.8840915779919426"
    },
    {
      "timestamp": "2022-03-13T00:00:00Z",
      "min": "0.1",
      "max": "9.99",
      "avg": "7.81423831932491409828"
    },
    {
      "timestamp": "2022-03-14T00:00:00Z",
      "min": "7.3",
      "max": "15.998331185137052776",
      "avg": "8.368607638060724738"
    },
    {
      "timestamp": "2022-03-15T00:00:00Z",
      "min": "6.2977537121807316",
      "max": "15.9986563649785472",
      "avg": "8.8116094053951534"
    },
    {
      "timestamp": "2022-03-16T00:00:00Z",
      "min": "4.13583784149951186375",
      "max": "23.99",
      "avg": "8.94078146045005597006"
    }
  ]
}

After you 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!