Python 3 wrapper for the OpenSea NFT API
Project description
OpenSea NFT API Python 3 wrapper
This an API wrapper library for the OpenSea API written in Python 3.
The library provides a simplified interface to fetch a diverse set of NFT data points from OpenSea.
Supported endpoints
The wrapper covers all of the OpenSea API endpoints (as of 2021-12-02, NOT including the Orderbook and Rinkeby API):
- Single asset (/asset)
- Single asset contract (/asset_contract)
- Single collection (/collection)
- Collection stats (/collection/{slug}/stats)
- Multiple assets (/assets)
- Multiple collections (/collections)
- Multiple events (/events)
- Multiple bundles (/bundles)
Prerequisite
As of Dec 2, 2021 you need to have an API key to use the OpenSea API, and thus you need one to use this wrapper too. You can request a key here.
Installation
Install with pip:
virtualenv env && source env/bin/activate
pip install opensea-api
Usage examples
Get data about a single asset
from opensea import OpenseaAPI
api = OpenseaAPI(apikey="<APIKEY>")
result = api.asset(asset_contract_address="0x495f947276749Ce646f68AC8c248420045cb7b5e",
token_id="66406747123743156841746366950152533278033835913591691491127082341586364792833")
print(result)
Get data about a single asset contract
from opensea import OpenseaAPI
api = OpenseaAPI(apikey="<APIKEY>")
result = api.contract(asset_contract_address="0x495f947276749Ce646f68AC8c248420045cb7b5e")
print(result)
Get data about a single collection
from opensea import OpenseaAPI
api = OpenseaAPI(apikey="<APIKEY>")
result = api.collection(collection_slug="cryptopunks")
print(result)
Get collection stats
from opensea import OpenseaAPI
api = OpenseaAPI(apikey="<APIKEY>")
result = api.collection_stats(collection_slug="cryptopunks")
print(result)
Get data about multiple assets
This example fetches three NFTs that Snoop Dogg owns:
from opensea import OpenseaAPI
api = OpenseaAPI(apikey="<APIKEY>")
result = api.assets(owner="0xce90a7949bb78892f159f428d0dc23a8e3584d75",
limit=3)
print(result)
Get data about multiple collections
This example creates a JSON file with 3 collections where Snoop Dogg is an owner:
from opensea import OpenseaAPI
api = OpenseaAPI(apikey="<APIKEY>")
result = api.collections(asset_owner="0xce90a7949bb78892f159f428d0dc23a8e3584d75",
limit=3,
export_file_name='snoop_collections.json')
print(result)
Get data about multiple events
This example creates a JSON file with 10 events that happened between the
defined time period (UTC timezone) between 2021-11-06 14:25
and 2021-11-06 14:30
from opensea import OpenseaAPI
from opensea import utils
api = OpenseaAPI(apikey="<APIKEY>")
period_start = utils.datetime_utc(2021, 11, 6, 14, 25)
period_end = utils.datetime_utc(2021, 11, 6, 14, 30)
result = api.events(occurred_after=period_start,
occurred_before=period_end,
limit=10,
export_file_name='events.json')
print(result)
Get data about multiple bundles
from opensea import OpenseaAPI
api = OpenseaAPI(apikey="<APIKEY>")
result = api.bundles(limit=3)
print(result)
Documentation
- Wrapper documentation (work in progress)
- OpenSea API documentation
History
0.1.3 (2021-12-03)
- Ability to reach all endpoints from one
OpenseaAPI
object - API key support (Opensea requires it from now on)
0.1.0 (2021-11-07)
- First release on PyPI.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for opensea_api-0.1.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4e0ae5639cb3a65751ce270f02bd2f66ff0bcf292ef725322c64ddf2f53f629 |
|
MD5 | 7d522e5172132bdde98bdc98dbfa412c |
|
BLAKE2b-256 | 4fecc8a45270851e8836eae891bbecfc78c3195543a934fdf8076f3d9ecf659d |