Package: opensea-api
OpenSea NFT API Python 3 wrapperThis an API wrapper library for theOpenSea APIwritten in Python 3.The library provides a simplified interface to fetch a diverse set of NFT data points from OpenSea.Supported endpointsThe wrapper covers the following OpenSea API endpoints: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)PrerequisiteYou need to have anAPI keyto use the OpenSea API, and thus
you need one to use this wrapper too.You can request a key here.NOTE: The API key can take over 4-7 days to be delivered. It also requires you to show the project you are working on.InstallationInstall with pip:virtualenvenv&&sourceenv/bin/activate
pipinstallopensea-apiUpgradepipinstallopensea-api-UUsage examples# import the OpenseaAPI object from the opensea modulefromopenseaimportOpenseaAPI# create an object to interact with the Opensea API (need an api key)api=OpenseaAPI(apikey="YOUR APIKEY")# fetch a single assetcontract_address="0x495f947276749Ce646f68AC8c248420045cb7b5e"token_id="66406747123743156841746366950152533278033835913591691491127082341586364792833"result=api.asset(asset_contract_address=contract_address,token_id=token_id)# fetch multiple assetsresult=api.assets(owner="0xce90a7949bb78892f159f428d0dc23a8e3584d75",limit=3)# fetch a single contractresult=api.contract(asset_contract_address="0x495f947276749Ce646f68AC8c248420045cb7b5e")# fetch a single collectionresult=api.collection(collection_slug="cryptopunks")# fetch multiple collectionsresult=api.collections(asset_owner="0xce90a7949bb78892f159f428d0dc23a8e3584d75",limit=3)# fetch collection statsresult=api.collection_stats(collection_slug="cryptopunks")# fetch multiple eventsfromopenseaimportutilsasopensea_utilsperiod_end=opensea_utils.datetime_utc(2021,11,6,14,30)result=api.events(occurred_before=period_end,limit=10,export_file_name="events.json",)# fetch multiple bundlesresult=api.bundles(limit=2)# paginate the events endpoint (cursors are handled internally)fromdatetimeimportdatetime,timezonestart_at=datetime(2021,10,5,3,25,tzinfo=timezone.utc)finish_at=datetime(2021,10,5,3,20,tzinfo=timezone.utc)event_generator=api.events_backfill(start=start_from,until=finish_at,event_type="successful")foreventinevent_generator:ifeventisnotNone:print(event)# or do other things with the event dataHere's a demo video showcasing the basics.DocumentationWrapper documentationOpenSea API documentationHistory0.1.7 (2022-03-26)Add support forasset listingsandasset offersendpointsAddoccured_afterandcollection_editorarguments to events endpointHandle SSL error when making requestsDocs: add example to paginate the events endpoint (usingevents_backfill())0.1.6 (2022-02-25)Fix /events endpoint pagination (events_backfill()function) by
passing onlythe cursor hashand not the full URL to the next request.0.1.5 (2022-02-17)Ability to override base_url with any other URLSupport for cursor-based pagination for /events endpoint (and removed deprecated arguments)New function to help paginate the /events endpointIntroducing a temporary function to fix thenexturl problem until OpenSea addresses this issueMinor docs updates and cleanup0.1.3 (2021-12-03)Ability to reach all endpoints from oneOpenseaAPIobjectAPI key support (Opensea requires it from now on)0.1.0 (2021-11-07)First release on PyPI.