This an API wrapper library for the OpenSea API written in Python 3.

Overview

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-10-07, NOT including the Orderbook and Rinkeby API):

Installation

Install with pip:

pip install opensea-api

Usage

Get data about a single asset

from opensea import Asset
api = Asset(asset_contract_address="0x495f947276749Ce646f68AC8c248420045cb7b5e",
            token_id="66406747123743156841746366950152533278033835913591691491127082341586364792833")
print(api.fetch())

Get data about a single asset contract

from opensea import Contract
api = Contract(asset_contract_address="0x495f947276749Ce646f68AC8c248420045cb7b5e")
print(api.fetch())

Get data about a single collection

from opensea import Collection
api = Collection(collection_slug="cryptopunks")
print(api.fetch())

Get collection stats

from opensea import CollectionStats
api = CollectionStats(collection_slug="cryptopunks")
print(api.fetch())

Get data about multiple assets

This example fetches three NFTs that Snoop Dogg owns:

from opensea import Assets
api = Assets()
print(api.fetch(owner="0xce90a7949bb78892f159f428d0dc23a8e3584d75",
                limit=3))

Get data about multiple collections

This example creates a JSON file with 3 collections where Snoop Dogg is an owner:

from opensea import Collections
api = Collections()
print(api.fetch(asset_owner="0xce90a7949bb78892f159f428d0dc23a8e3584d75",
                limit=3,
                export_file_name='snoop_collections.json'))

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 Events
from opensea import utils
api = Events()
period_start = utils.datetime_utc(2021, 11, 6, 14, 25)
period_end = utils.datetime_utc(2021, 11, 6, 14, 30)
print(api.fetch(occurred_after=period_start,
                occurred_before=period_end,
                limit=10,
                export_file_name='events.json'))

Get data about multiple bundles

from opensea import Bundles
api = Bundles()
print(api.fetch(limit=3))

Documentation

Comments
  • feat: Support page cursor in assets request

    feat: Support page cursor in assets request

    The API endpoint for fetching a collection's assets also supports page cursors (better for fetching entire collections than using offset/limit). Added "cursor" as an optional parameter in the assets fetching API wrapper.

    opened by louisstewart 5
  • No module named 'opensea'

    No module named 'opensea'

    When you copy the code directly from the Get data about a single asset section the following error is given:

    Traceback (most recent call last):
      File "C:\Users\antho\Desktop\nft-py\index.py", line 1, in <module>
        from opensea import Asset
    ModuleNotFoundError: No module named 'opensea'
    
    opened by AnthonyRodriguez726 4
  • Error getting collection_stats with incorrect name

    Error getting collection_stats with incorrect name

    I'm trying to find collection stats for not existing collection and i recive

    api = OpenseaAPI() api.collection_stats(collection_slug="asd")

    Traceback (most recent call last):
      File "/home/m4xx1m/jp3g3r/venv/lib/python3.10/site-packages/requests/models.py", line 910, in json
        return complexjson.loads(self.text, **kwargs)
      File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
        return _default_decoder.decode(s)
      File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
      File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
        raise JSONDecodeError("Expecting value", s, err.value) from None
    json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
    
    During handling of the above exception, another exception occurred:
    Traceback (most recent call last):
      File "/usr/lib/python3.10/code.py", line 90, in runcode
        exec(code, self.locals)
      File "<input>", line 1, in <module>
      File "/home/m4xx1m/jp3g3r/venv/lib/python3.10/site-packages/opensea/opensea_api.py", line 236, in collection_stats
        return self._make_request(endpoint, export_file_name=export_file_name)
      File "/home/m4xx1m/jp3g3r/venv/lib/python3.10/site-packages/opensea/opensea_api.py", line 67, in _make_request
        return response.json()
      File "/home/m4xx1m/jp3g3r/venv/lib/python3.10/site-packages/requests/models.py", line 917, in json
        raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
    requests.exceptions.JSONDecodeError: [Errno Expecting value] : 0 
    

    image

    opened by m4xx1m 3
  • Thanks very much

    Thanks very much

    when I use the api funciton, I have a error like this: requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.opensea.io', port=443): Max retries exceeded with url: /api/v1/collection/cryptopunks (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0000010A51A36D90>: Failed to establish a new connection

    I had check my web and vpn.

    opened by kaifeitudou 2
  • SSL Cert error

    SSL Cert error

    If you see an error like this:

    json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
    

    And the returned data is like this:

    <!DOCTYPE html>
    <html>
      <head>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta charset="utf-8">
        <title>SSL certificate error</title>
        <style media="screen">
          html,body,iframe {
            margin: 0;
            padding: 0;
          }
    
          html,body {
            height: 100%;
            overflow: hidden;
          }
    
          iframe {
            width: 100%;
            height: 100%;
            border: 0;
          }
        </style>
      </head>
      <body>
        <iframe src="//www.herokucdn.com/error-pages/ssl-cert-error.html"></iframe>
      <script defer src="https://static.cloudflareinsights.com/beacon.min.js/v652eace1692a40cfa3763df669d7439c1639079717194" integrity="sha512-Gi7xpJR8tSkrpF7aordPZQlW2DLtzUlZcumS8dMQjwDHEnw9I7ZLyiOj/6tZStRBGtGgN6ceN6cMH8z7etPGlw==" data-cf-beacon='{"rayId":"6f0993997f0377f5","token":"96047490de144c8b91be74ba7605ab69","version":"2021.12.0","si":100}' crossorigin="anonymous"></script>
    </body>
    </html>
    

    Then it's likely a bug with the opensea API that happens intermittently... it has been mentioned many times on their discord, hope it will get fixed soon.

    bug good first issue 
    opened by zseta 2
  • ConnectionError: The server blocked access.

    ConnectionError: The server blocked access.

    I wonder if this issue is coming from the library or opensea itself? I scanned through discord and saw a comment of this error a couple months ago with some similarity, pasted below.

    "does the api require a key? on the docs it says you dont but when i try to use the opensea python api wrapper i get ConnectionError: The server blocked access."

    opened by Luca-Blight 2
  • Some collections crash api

    Some collections crash api

    I'm trying to get a pixelmon collection but this collection breaks the script [photo], this collection may be banned or removed because other non-existing collections work. P.S. I'm use free api without token.

    image

    Where script crash: image

    opened by m4xx1m 2
  • ModuleNotFoundError: No module named 'OpenseaAPI'

    ModuleNotFoundError: No module named 'OpenseaAPI'

    I pip installed opensea-api, and opensea. I don't get an error when I import opensea. I get an error when I import OpenseaAPI. Attached screenshot that shows it has been successfully installed. Screen Shot 2022-02-23 at 7 43 29 PM

    opened by itsuzef 1
  • The API might not work without APIKEY

    The API might not work without APIKEY

    Just noticed that you can get blocked (403) if you don't have an APIKEY from OpenSea (it's a new thing previously they didn't block you at all). It should be supported to add your APIKEY in case you have one (and with APIKEY you are good to go)

    opened by zseta 1
  • Bump wheel from 0.33.6 to 0.38.1

    Bump wheel from 0.33.6 to 0.38.1

    Bumps wheel from 0.33.6 to 0.38.1.

    Changelog

    Sourced from wheel's changelog.

    Release Notes

    UNRELEASED

    • Updated vendored packaging to 22.0

    0.38.4 (2022-11-09)

    • Fixed PKG-INFO conversion in bdist_wheel mangling UTF-8 header values in METADATA (PR by Anderson Bravalheri)

    0.38.3 (2022-11-08)

    • Fixed install failure when used with --no-binary, reported on Ubuntu 20.04, by removing setup_requires from setup.cfg

    0.38.2 (2022-11-05)

    • Fixed regression introduced in v0.38.1 which broke parsing of wheel file names with multiple platform tags

    0.38.1 (2022-11-04)

    • Removed install dependency on setuptools
    • The future-proof fix in 0.36.0 for converting PyPy's SOABI into a abi tag was faulty. Fixed so that future changes in the SOABI will not change the tag.

    0.38.0 (2022-10-21)

    • Dropped support for Python < 3.7
    • Updated vendored packaging to 21.3
    • Replaced all uses of distutils with setuptools
    • The handling of license_files (including glob patterns and default values) is now delegated to setuptools>=57.0.0 (#466). The package dependencies were updated to reflect this change.
    • Fixed potential DoS attack via the WHEEL_INFO_RE regular expression
    • Fixed ValueError: ZIP does not support timestamps before 1980 when using SOURCE_DATE_EPOCH=0 or when on-disk timestamps are earlier than 1980-01-01. Such timestamps are now changed to the minimum value before packaging.

    0.37.1 (2021-12-22)

    • Fixed wheel pack duplicating the WHEEL contents when the build number has changed (#415)
    • Fixed parsing of file names containing commas in RECORD (PR by Hood Chatham)

    0.37.0 (2021-08-09)

    • Added official Python 3.10 support
    • Updated vendored packaging library to v20.9

    ... (truncated)

    Commits
    • 6f1608d Created a new release
    • cf8f5ef Moved news item from PR #484 to its proper place
    • 9ec2016 Removed install dependency on setuptools (#483)
    • 747e1f6 Fixed PyPy SOABI parsing (#484)
    • 7627548 [pre-commit.ci] pre-commit autoupdate (#480)
    • 7b9e8e1 Test on Python 3.11 final
    • a04dfef Updated the pypi-publish action
    • 94bb62c Fixed docs not building due to code style changes
    • d635664 Updated the codecov action to the latest version
    • fcb94cd Updated version to match the release
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • 0.1.7

    0.1.7

    • Add support for asset listings and asset offers endpoints
    • Add occured_after and collection_editor arguments to events endpoint
    • Handle SSL error when making requests
    • Docs: add example to paginate the events endpoint (using events_backfill())
    opened by zseta 0
  • Cursor Param for Events

    Cursor Param for Events

    Currently you have events_backfill however when I've used it the result is always a set of 300, but never less than 300 which makes me think it's possibly missing results at the end.

    If there was a cursor query param built into events then I could paginate myself, or maybe there's a reason it's returning only a multiple of 300 instead of all the results within a date range?

    Thanks in advance!

    opened by VillainGuy 1
  • Feature: OpenSea streaming API

    Feature: OpenSea streaming API

    Hey I just implemented the streaming API for a project of mine, maybe you would like to use it as inspiration.

    https://github.com/cojodi/openseapy

    I just tested it a bit, but as a general idea + the objects it suffices so far I think.

    opened by Dimfred 1
  • Find out if asset is marked as

    Find out if asset is marked as "Reported for suspicious activity"

    Thanks for this python API wrapper.

    Is there any way to find out if an asset is "Reported for suspicious activity" ?

    For example such as this one: https://opensea.io/assets/ethereum/0xfcb1315c4273954f74cb16d5b663dbf479eec62e/6234

    opened by Toeplitz 3
Owner
Attila Tóth
Attila Tóth
Opensea-upload-with-recaptcha-solution - Updated opensea uploading solution with recaptcha pass

opensea-upload-with-recaptcha-solution updated opensea uploading solution with r

byeonggeon sim 25 Nov 15, 2022
This an API wrapper library for the OpenSea API written in Python 3.

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 f

Attila Tóth 159 Dec 26, 2022
🚀 An asynchronous python API wrapper meant to replace discord.py - Snappy discord api wrapper written with aiohttp & websockets

Pincer An asynchronous python API wrapper meant to replace discord.py ❗ The package is currently within the planning phase ?? Links |Join the discord

Pincer 125 Dec 26, 2022
Using Streamlit to build a simple UI on top of the OpenSea API

OpenSea API Explorer Using Streamlit to build a simple UI on top of the OpenSea API. ?? Contributing Contributions, issues and feature requests are we

Gavin Capriola 1 Jan 4, 2022
OpenSea Python Bot coded purely in Python3.

OpenSea Python Bot coded purely in Python3. It utilises everything from OpenSea API to continuously monitor NFT's. It can be used to snipe or monitor if something falls below floor value.

OpenSea Elite Sniper 20 Dec 29, 2021
Bulk NFT uploader to OpenSea!

Bulk NFT Uploader Description Simple easy peasy python script which logins to opensea account using metamask and bulk uploads NFT to your default coll

Lakshya Khera 25 May 23, 2022
Automatically download any NFT collection from OpenSea.

OpenSea NFT Stealer The sole purpose of this script is to download any NFT collection from OpenSea. How does it work? Basically, the OpenSea website a

Dan 111 Dec 29, 2022
NFTs Upload to OpenSea CuseEdition

NFTs-Upload-to-OpenSea-CuseEdition YOUTUBE VIDEO -> Soon... Download Python and

Lil Cuse 2 Jan 4, 2022
Async ready API wrapper for Revolt API written in Python.

Mutiny Async ready API wrapper for Revolt API written in Python. Installation Python 3.9 or higher is required To install the library, you can just ru

null 16 Mar 29, 2022
iCloudPy is a simple iCloud webservices wrapper library written in Python

iCloudPy ?? Please star this repository if you end up using the library. It will help me continue supporting this product. ?? iCloudPy is a simple iCl

Mandar Patil 49 Dec 26, 2022
Aws-lambda-requests-wrapper - Request/Response wrapper for AWS Lambda with API Gateway

AWS Lambda Requests Wrapper Request/Response wrapper for AWS Lambda with API Gat

null 1 May 20, 2022
An API wrapper for Discord written in Python.

discord.py A modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python. Key Features Modern Pythonic API using asyn

Danny 12k Jan 8, 2023
The official wrapper for spyse.com API, written in Python, aimed to help developers build their integrations with Spyse.

Python wrapper for Spyse API The official wrapper for spyse.com API, written in Python, aimed to help developers build their integrations with Spyse.

Spyse 15 Nov 22, 2022
An API wrapper for convertio.co written in Python.

An API wrapper for convertio.co written in Python.

Moonrise 9 Sep 27, 2022
A simple API wrapper for Discord written in Python.

AIOCord This project is work in progress not for production use A simple asynchronous API wrapper around Discord API written in Python. Inspiration Th

Izhar Ahmad 3 Dec 7, 2021
A modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python.

A modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python. Key Features Modern Pythonic API using async and await

Senpai Development 4 Nov 5, 2021
A modern,feature-rich, and async ready API wrapper for Discord written in Python

discord.io A modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python. Key Features Modern Pythonic API using asyn

Vincent 18 Jan 2, 2023
Spore API wrapper written in Python

A wrapper for the Spore API that simplifies and complements its functionality

null 1 Nov 25, 2021
A Discord API Wrapper for Userbots/Selfbots written in Python.

DisCum A simple, easy to use, non-restrictive, synchronous Discord API Wrapper for Selfbots/Userbots written in Python. -using requests and websockets

Liam 450 Dec 27, 2022