NonFungible Python API Tutorial
This tutorial aims to be a quick guide to get you started using the NonFungible API integrated into messari’s python library.
[1]:
from messari.nfts import NonFungible
nf = NonFungible()
[2]:
collections = ['cryptopunks', 'doodles']
import pandas as pd
API Structure
The NonFungible Python client contains a number of functions that wrap some of NonFungible’s API endpoints. These include:
Functions
get_collection_history
get_collection_stats
get_collection_summary
Below are a few examples to showcase the functionality and types of data each function generates.
Functions
get_collection_history
get collection history,
[6]:
collection_history_df = nf.get_collection_history(collections_in=collections, length=5)
collection_history_df
[6]:
cryptopunks | ... | doodles | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
blockchain | transactionHash | blockNumber | blockTimestamp | assetId | project | nftAddress | nftTicker | marketAddress | usdPrice | ... | totalPrice | totalDecimalPrice | feeUSDPrice | feeTotalPrice | feeTotalDecimalPrice | feeCollectors | saleType | buyer | seller | meta | |
0 | ethereum | 0xaa40b85f4a1a16fe3f6f424ada1a99053335420b167b... | 13912264 | 2021-12-31T09:11:16.000Z | 5902 | cryptopunks | 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb | Ͼ | 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb | 1204673.400 | ... | 200000000000000000000 | 200 | 57190.50000 | 15000000000000000000 | 15.000 | [0x5b3256965e7c3cf26e11fcaf296dfc8807c01073] | secondary | 0xb3b1d2405f16afc27a83fb9a43e1da5102a363d4 | 0xeef9a8b628e22ade70b509c45f6f1db1d43c0dd4 | {'name': 'Doodle #7751', 'artist': ['Burnt Toa... |
1 | ethereum | 0xbfe47e67ab24622b809b80fa357a2e72a8e345543b6b... | 13901896 | 2021-12-29T18:32:33.000Z | 6275 | cryptopunks | 0xb7f7f6c52f2e2fdb1963eab30438024864c313f6 | WPUNKS | 0x4748495153fb86637e4fdd8e50e3c1f611f15930 | 1133475.000 | ... | 150000000000000000000 | 150 | 42918.41250 | 11250000000000000000 | 11.250 | [0x5b3256965e7c3cf26e11fcaf296dfc8807c01073] | secondary | 0x6ec30fd91a504aad948839b985c7263888b2ad68 | 0x0d41f957181e584db82d2e316837b2de1738c477 | {'name': 'Doodle #3954', 'artist': ['Burnt Toa... |
2 | ethereum | 0x3f2066f45f5a48e95a9a87db3f1db1789553cbece2dd... | 13903771 | 2021-12-30T01:29:09.000Z | 7622 | cryptopunks | 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb | Ͼ | 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb | 913227.318 | ... | 120000000000000000000 | 120 | 34460.46000 | 9000000000000000000 | 9.000 | [0x5b3256965e7c3cf26e11fcaf296dfc8807c01073] | secondary | 0x4b4c13434aac5e99645a4d9e59fe497b3318f50f | 0xd7510a925475cb8377bc8d2a7f1c792022b68df8 | {'name': 'Doodle #6343', 'artist': ['Burnt Toa... |
3 | ethereum | 0xee3a243e833cdde3456a3b5bd5b9f95add2438edf737... | 13923097 | 2022-01-02T01:35:03.000Z | 4770 | cryptopunks | 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb | Ͼ | 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb | 822235.500 | ... | 119000000000000000000 | 119 | 33815.30775 | 8925000000000000000 | 8.925 | [0x5b3256965e7c3cf26e11fcaf296dfc8807c01073] | secondary | 0x904778b44bd12a1f7c3f1b95ff3381a952296cd1 | 0xde2b87d1539904f4b37e98c0d5ce383e890006ef | {'name': 'Doodle #1085', 'artist': ['Burnt Toa... |
4 | ethereum | 0xd22f3794e7791e3a53eaefab4cd4a37557fdeab178b2... | 13912355 | 2021-12-31T09:31:42.000Z | 642 | cryptopunks | 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb | Ͼ | 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb | 638379.840 | ... | 100000000000000000000 | 100 | 28554.60000 | 7500000000000000000 | 7.500 | [0x5b3256965e7c3cf26e11fcaf296dfc8807c01073] | secondary | 0x30ae2012d175c6e7945a4350c57fe737d085d470 | 0xbde3fe2c971018a0dfde5030b611e4aeb2ce3933 | {'name': 'Doodle #7802', 'artist': ['Burnt Toa... |
5 rows × 44 columns
can do ’’ to get all collections
[4]:
collection_history_df = nf.get_collection_history(collections_in='')
collection_history_df.head()
[4]:
blockchain | transactionHash | blockNumber | blockTimestamp | assetId | project | nftAddress | nftTicker | marketAddress | usdPrice | ... | totalPrice | totalDecimalPrice | feeUSDPrice | feeTotalPrice | feeTotalDecimalPrice | feeCollectors | saleType | buyer | seller | meta | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | ethereum | 0x21dcce949d7137778294d3b40797b3f0c81928bd8661... | 13928090 | 2022-01-02T20:05:08.000Z | 11 | superrare | 0x41a322b28d0ff354040e2cbc676f0320d8c8850d | SUPR | 0x41a322b28d0ff354040e2cbc676f0320d8c8850d | 6.196021e+06 | ... | 1630000000000000000000 | 1630.0000 | 805482.756000 | 211900000000000000000 | 211.9000 | [0x39cc9c86e67baf2129b80fe3414c397492ea8026, 0... | secondary | 0x63fed38f5d6f6fd6a899451c72322c44b9c5acb0 | 0xb67994792c214039c8328bb3e0835b6a8ea7e373 | {'artist': ['N/A'], 'name': 'All Time High in ... |
1 | ethereum | 0x851d5ec47f2d766278193961c3fd582011af1fda286f... | 13896377 | 2021-12-28T22:17:44.000Z | 3562 | boredapeclub | 0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d | BAYC | 0x24550d7fbe64bfdbce7704251d3fe40b8a136c91 | 1.636232e+06 | ... | 430000000000000000000 | 430.0000 | 81811.585000 | 21500000000000000000 | 21.5000 | [0x5b3256965e7c3cf26e11fcaf296dfc8807c01073] | secondary | 0x020ca66c30bec2c4fe3861a94e4db4a498a35872 | 0xfbe5c1ab13e206688775f117a9a90153d7fdcfd2 | {'name': 'Bored Ape #3562', 'eyes': 'Zombie', ... |
2 | ethereum | 0xaa40b85f4a1a16fe3f6f424ada1a99053335420b167b... | 13912264 | 2021-12-31T09:11:16.000Z | 5902 | cryptopunks | 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb | Ͼ | 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb | 1.204673e+06 | ... | 315000000000000000000 | 315.0000 | NaN | None | NaN | None | secondary | 0x801b68cc9f4fb094a28b30ca25664051e50ad3a9 | 0x1e3685ee600983bac782b182f245efd3bbb26455 | {'tags': ['Hoodie', 'Small Shades', 'Shadow Be... |
3 | ethereum | 0xbfe47e67ab24622b809b80fa357a2e72a8e345543b6b... | 13901896 | 2021-12-29T18:32:33.000Z | 6275 | cryptopunks | 0xb7f7f6c52f2e2fdb1963eab30438024864c313f6 | WPUNKS | 0x4748495153fb86637e4fdd8e50e3c1f611f15930 | 1.133475e+06 | ... | 300000000000000000000 | 300.0000 | NaN | None | NaN | None | primary | 0xd66fe503aebe0a9ca0d0b208453a3d7106b063f2 | 0x0980d5970901349d531c9fd032dfa3132b5bec48 | NaN |
4 | ethereum | 0x44047731eb4993621a7fd0c3b55b46ebb7660fcf2900... | 13935026 | 2022-01-03T21:51:13.000Z | 7009 | superrare | 0xb932a70a57673d89f4acffbe830e8ed7f75fb9e0 | SUPR | 0x8c9f364bf7a56ed058fc63ef81c6cf09c833e656 | 9.397873e+05 | ... | 249970700000000000000 | 249.9707 | 118613.936623 | 31549700000000000000 | 31.5497 | [0x39cc9c86e67baf2129b80fe3414c397492ea8026, 0... | secondary | 0xc46db2d89327d4c41eb81c43ed5e3dff111f9a8f | 0x762da606029d3120735aa1eec15464e265db7a3c | {'artist': ['XCOPY'], 'name': 'Blood Run', 'de... |
5 rows × 22 columns
get_collection_stats
get stats abt collection
[5]:
collection_stats_df = nf.get_collection_stats(collections_in=collections)
collection_stats_df
[5]:
cryptopunks | doodles | |
---|---|---|
count-sale-latest | 99 | 1274 |
count-sale-daily | [[1641340800, 99], [1641254400, 101], [1641168... | [[1641340800, 1290], [1641254400, 1219], [1641... |
count-salesprimary-latest | 8 | 0 |
count-salesprimary-daily | [[1641340800, 8], [1641254400, 9], [1641168000... | [[1641340800, 0], [1641254400, 0], [1641168000... |
count-salessecondary-latest | 91 | 1274 |
count-salessecondary-daily | [[1641340800, 91], [1641254400, 92], [16411680... | [[1641340800, 1290], [1641254400, 1219], [1641... |
sum-usd-latest | 30753514.921924 | 41137137.998815 |
sum-usd-daily | [[1641340800, 30753514.9219242], [1641254400, ... | [[1641340800, 42081062.39701], [1641254400, 38... |
avg-usd-latest | 310641.564868 | 32289.747252 |
avg-usd-daily | [[1641340800, 310641.56486792123], [1641254400... | [[1641340800, 32620.978602333333], [1641254400... |
sum-usdprimary-latest | 2709420.2789 | 0 |
sum-usdprimary-daily | [[1641340800, 2709420.2789], [1641254400, 2709... | [[1641340800, 0], [1641254400, 0], [1641168000... |
sum-usdsecondary-latest | 28044094.643024 | 41137137.998815 |
sum-usdsecondary-daily | [[1641340800, 28044094.6430242], [1641254400, ... | [[1641340800, 42081062.39701], [1641254400, 38... |
sum-feeusd-latest | 242808.561914 | 3092240.852342 |
sum-feeusd-daily | [[1641340800, 242808.56191426094], [1641254400... | [[1641340800, 3178364.757174794], [1641254400,... |
unique-wallets-latest | 125 | 1607 |
unique-wallets-daily | [[1641340800, 125], [1641254400, 127], [164116... | [[1641340800, 1623], [1641254400, 1550], [1641... |
unique-buyer-latest | 65 | 890 |
unique-buyer-daily | [[1641340800, 65], [1641254400, 67], [16411680... | [[1641340800, 902], [1641254400, 859], [164116... |
unique-seller-latest | 71 | 944 |
unique-seller-daily | [[1641340800, 71], [1641254400, 72], [16411680... | [[1641340800, 951], [1641254400, 911], [164116... |
get_collection_summary
Retrieve quick collection summary
[5]:
collection_summary_df = nf.get_collection_summary(collections_in=collections)
collection_summary_df
[5]:
cryptopunks | doodles | |
---|---|---|
name | cryptopunks | doodles |
tickers | [{'project': 'cryptopunks'}] | [{'project': 'doodles'}] |
categories | [Collectible] | [Collectible] |
website | https://www.larvalabs.com/cryptopunks | https://doodles.app/ |
count | 19953 | 26059 |
traders | 5667 | 10823 |
usd | 1884762762.14 | 187226510.81 |
average | 94460.12 | 7184.72 |
currencies | [{'ticker': 'ETH', 'totalDecimalPrice': 651088... | [{'ticker': 'ETH', 'totalDecimalPrice': 46751.... |
daily | None | None |