OpenSea Python API Tutorial

This tutorial aims to be a quick guide to get you started using the OpenSea API integrated into messari’s python library.

[1]:
from messari.nfts import OpenSea
os = OpenSea()
[2]:
collections = ['doodles-official','phrocks']
# punks, bayc
contracts = ['0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb', '0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D']
assets = ['6529', '555']

API Structure

The OpenSea Python client contains a number of functions that wrap some of OpenSea’s API endpoints. These include:

Functions

  • get_asset

  • get_contract

  • get_collection

  • get_events

  • get_bundle

  • get_collection_stats

  • get_orders

Below are a few examples to showcase the functionality and types of data each function generates.

Functions

get_asset

Used to fetch more in-depth information about an individual asset

[7]:
asset = os.get_asset(contracts_in=contracts, assets_in=assets)
asset
[7]:
0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb 0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D
6529 555 6529 555
id 178276 525304 23139224 23113937
token_id 6529 555 6529 555
num_sales 1 1 3 1
background_color None None None None
image_url https://lh3.googleusercontent.com/5B85At9ud33G... https://lh3.googleusercontent.com/V9c-ZER2iciQ... https://lh3.googleusercontent.com/2BPAh0dbtVcU... https://lh3.googleusercontent.com/rBFqDumiA3rH...
image_preview_url https://lh3.googleusercontent.com/5B85At9ud33G... https://lh3.googleusercontent.com/V9c-ZER2iciQ... https://lh3.googleusercontent.com/2BPAh0dbtVcU... https://lh3.googleusercontent.com/rBFqDumiA3rH...
image_thumbnail_url https://lh3.googleusercontent.com/5B85At9ud33G... https://lh3.googleusercontent.com/V9c-ZER2iciQ... https://lh3.googleusercontent.com/2BPAh0dbtVcU... https://lh3.googleusercontent.com/rBFqDumiA3rH...
image_original_url https://www.larvalabs.com/cryptopunks/cryptopu... https://www.larvalabs.com/cryptopunks/cryptopu... https://ipfs.io/ipfs/QmTm77YMPadyHNUHaU1eTrken... https://ipfs.io/ipfs/QmX2nxPPe3MdfVag4XK7mKrzL...
animation_url None None None None
animation_original_url None None None None
name CryptoPunk #6529 CryptoPunk #555 None None
description None None None None
external_link https://www.larvalabs.com/cryptopunks/details/... https://www.larvalabs.com/cryptopunks/details/555 None None
asset_contract {'address': '0xb47e3cd837ddf8e4c57f05d70ab865d... {'address': '0xb47e3cd837ddf8e4c57f05d70ab865d... {'address': '0xbc4ca0eda7647a8ab7c2061c2e118a1... {'address': '0xbc4ca0eda7647a8ab7c2061c2e118a1...
permalink https://opensea.io/assets/0xb47e3cd837ddf8e4c5... https://opensea.io/assets/0xb47e3cd837ddf8e4c5... https://opensea.io/assets/0xbc4ca0eda7647a8ab7... https://opensea.io/assets/0xbc4ca0eda7647a8ab7...
collection {'payment_tokens': [{'id': 13689077, 'symbol':... {'payment_tokens': [{'id': 13689077, 'symbol':... {'payment_tokens': [{'id': 13689077, 'symbol':... {'payment_tokens': [{'id': 13689077, 'symbol':...
decimals None None 0 0
token_metadata https://ipfs.io/ipfs/QmeSjSinHpPnmXmspMjwiXyN6... https://ipfs.io/ipfs/QmeSjSinHpPnmXmspMjwiXyN6...
owner {'user': {'username': '6529Museum'}, 'profile_... {'user': {'username': 'yilinhut'}, 'profile_im... {'user': {'username': 'JimmyDankoVault'}, 'pro... {'user': {'username': 'Block_Merchant'}, 'prof...
sell_orders None None None None
creator {'user': None, 'profile_img_url': 'https://sto... {'user': None, 'profile_img_url': 'https://sto... {'user': {'username': 'BoredApeYachtClub'}, 'p... {'user': {'username': 'BoredApeYachtClub'}, 'p...
traits [{'trait_type': 'type', 'value': 'Male', 'disp... [{'trait_type': 'type', 'value': 'Male', 'disp... [{'trait_type': 'Fur', 'value': 'Dark Brown', ... [{'trait_type': 'Background', 'value': 'New Pu...
last_sale {'asset': {'token_id': '6529', 'decimals': Non... {'asset': {'token_id': '555', 'decimals': None... {'asset': {'token_id': '6529', 'decimals': 0},... {'asset': {'token_id': '555', 'decimals': 0}, ...
top_bid None None None None
listing_date None None None None
is_presale False False False False
transfer_fee_payment_token None None None None
transfer_fee None None None None
related_assets [] [] [] []
orders [] [] [] []
auctions [] [] [] []
supports_wyvern False False True True
top_ownerships [{'owner': {'user': {'username': '6529Museum'}... [{'owner': {'user': {'username': 'yilinhut'}, ... [{'owner': {'user': {'username': 'JimmyDankoVa... [{'owner': {'user': {'username': 'Block_Mercha...
ownership None None None None
highest_buyer_commitment None None None None

get_contract

Used to fetch more in-depth information about an contract asset

[8]:
contract = os.get_contract(contracts_in=contracts)
contract
[8]:
0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb ... 0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D
collection address asset_contract_type created_date name nft_version opensea_version owner schema_name symbol ... image_url default_to_fiat dev_buyer_fee_basis_points dev_seller_fee_basis_points only_proxied_transfers opensea_buyer_fee_basis_points opensea_seller_fee_basis_points buyer_fee_basis_points seller_fee_basis_points payout_address
banner_image_url https://lh3.googleusercontent.com/48oVuDyfe_xh... 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
chat_url None 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
created_date 2019-04-26T22:13:09.691572 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
default_to_fiat False 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
description CryptoPunks launched as a fixed set of 10,000 ... 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
dev_buyer_fee_basis_points 0 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
dev_seller_fee_basis_points 0 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
discord_url https://discord.gg/tQp4pSE 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
display_data {'card_display_style': 'cover'} 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
external_url https://www.larvalabs.com/cryptopunks 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
featured False 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
featured_image_url https://storage.opensea.io/0xb47e3cd837ddf8e4c... 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
hidden False 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
image_url https://lh3.googleusercontent.com/BdxvLseXcfl5... 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
instagram_username None 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
is_subject_to_whitelist False 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
large_image_url https://lh3.googleusercontent.com/QB2kKuQEw04X... 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
medium_username None 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
name CryptoPunks 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
only_proxied_transfers False 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
opensea_buyer_fee_basis_points 0 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
opensea_seller_fee_basis_points 250 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
payout_address 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
require_email False 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
safelist_request_status verified 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
short_description None 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
slug cryptopunks 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
telegram_url None 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
twitter_username larvalabs 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1
wiki_url None 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb non-fungible 2018-01-23T04:51:38.832339 CryptoPunks unsupported None None CRYPTOPUNKS PUNK ... https://lh3.googleusercontent.com/Ju9CkWtV-1Ok... False 0 250 False 0 250 0 500 0xaae7ac476b117bccafe2f05f582906be44bc8ff1

30 rows × 46 columns

get_collection

Used for retrieving more in-depth information about individual collections, including real time statistics like floor price

[4]:
collection = os.get_collection(collections_in=collections)
collection
[4]:
doodles-official phrocks
collection collection
banner_image_url https://lh3.googleusercontent.com/svc_rQkHVGf3... https://lh3.googleusercontent.com/hF9Co2A2c69m...
chat_url None None
created_date 2021-10-17T13:00:47.419945 2021-08-26T04:14:43.335895
default_to_fiat False False
description A community-driven collectibles project featur... They're phrocks.\n\nhttps://etherphrock.com/
dev_buyer_fee_basis_points 0 0
dev_seller_fee_basis_points 500 0
discord_url https://discord.gg/doodles None
display_data {'card_display_style': 'contain'} {'card_display_style': 'contain'}
editors [0x0239769a1adf4def9f07da824b80b9c4fcb59593, 0... [0x0239769a1adf4def9f07da824b80b9c4fcb59593, 0...
external_url https://doodles.app https://etherphrock.com/
featured False False
featured_image_url https://lh3.googleusercontent.com/svc_rQkHVGf3... https://lh3.googleusercontent.com/hF9Co2A2c69m...
hidden False False
image_url https://lh3.googleusercontent.com/7B0qai02OdHA... https://lh3.googleusercontent.com/hF9Co2A2c69m...
instagram_username None None
is_subject_to_whitelist False False
large_image_url https://lh3.googleusercontent.com/svc_rQkHVGf3... https://lh3.googleusercontent.com/hF9Co2A2c69m...
medium_username None None
name Doodles Phrocks
only_proxied_transfers False False
opensea_buyer_fee_basis_points 0 0
opensea_seller_fee_basis_points 250 250
payment_tokens [{'id': 4645681, 'symbol': 'WETH', 'address': ... [{'id': 4645681, 'symbol': 'WETH', 'address': ...
payout_address 0xdcd382be6cc4f1971c667ffda85c7a287605afe4 None
primary_asset_contracts [{'address': '0x8a90cab2b38dba80c64b7734e58ee1... [{'address': '0x364ce4e74a1ddd42e6f96a5ee69280...
require_email False False
safelist_request_status verified not_requested
short_description None None
slug doodles-official phrocks
stats {'one_day_volume': 1854.2732000000003, 'one_da... {'one_day_volume': 0.95, 'one_day_change': 0.0...
telegram_url None None
traits {'background': {'blue': 726, 'blue space': 1, ... {'Facing': {'right': 78}, 'Rock': {'yes': 78}}
twitter_username doodles None
wiki_url None None

get_collection_stats

Fetch stats for a specific collection, including realtime floor price statistics

[3]:
collection_stats = os.get_collection_stats(collections)
collection_stats
[3]:
doodles-official phrocks
average_price 3.818139 4.665000
count 10000.000000 78.000000
floor_price 14.150000 0.490000
market_cap 130241.020634 74.100000
num_owners 5933.000000 60.000000
num_reports 6.000000 0.000000
one_day_average_price 16.409497 0.950000
one_day_change 0.056728 0.000000
one_day_sales 113.000000 1.000000
one_day_volume 1854.273200 0.950000
seven_day_average_price 13.024102 0.950000
seven_day_change 0.662375 0.000000
seven_day_sales 473.000000 1.000000
seven_day_volume 6160.400276 0.950000
thirty_day_average_price 12.509946 0.950000
thirty_day_change 1.850069 1.878788
thirty_day_sales 2685.000000 1.000000
thirty_day_volume 33589.205642 0.950000
total_sales 18732.000000 8.000000
total_supply 10000.000000 78.000000
total_volume 71521.375860 37.320000