Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

opensea-stream

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opensea-stream

A python SDK for receiving updates from the OpenSea Stream API - pushed over websockets

  • 0.1.0
  • Source
  • PyPI
  • Socket score

Maintainers
1

OpenSea Stream API - python SDK

A python SDK for receiving updates from the OpenSea Stream API - pushed over websockets. We currently support the following event types on a per-collection basis:

  • Item Listed
  • Item Sold
  • Item Transferred
  • Item Metadata updates
  • Item Cancelled
  • Item Received offer
  • Item Received bid

Documentation: https://docs.opensea.io/reference/stream-api-overview

Installation

This module requires Python 3 or later. Python 3

pip install opensea_sdk

Getting Started

Authentication

In order to make onboarding easy, we've integrated the OpenSea Stream API with our existing API key system. The API keys you have been using for the REST API should work here as well. If you don't already have one, request an API key from us here.

Simple example

from opensea_sdk import *

api_key = '' # Your opensea api key

def callback(payload: dict):
    # handle event
    return

Client = OpenseaStreamClient(api_key, Network.MAINNET)
Client.onItemListed('collection-slug', callback)
Client.onItemSold('collection-slug', callback)

Client.startListening()

You can also optionally pass in:

  • a network if you would like to access testnet networks.
    • The default value is Network.MAINNET, which represents the following blockchains: Ethereum, Polygon mainnet, Klaytn mainnet, and Solana mainnet
    • Can also select Network.TESTNET, which represents the following blockchains: Rinkeby, Polygon testnet (Mumbai), and Klaytn testnet (Baobab).

Available Networks

The OpenSea Stream API is available on the following networks:

Mainnet

wss://stream.openseabeta.com/socket

Mainnet support events from the following blockchains: Ethereum, Polygon mainnet, Klaytn mainnet, and Solana mainnet.

Testnet

wss://testnets-stream.openseabeta.com/socket

Testnet support events from the following blockchains: Rinkeby, Polygon testnet (Mumbai), and Klaytn testnet (Baobab).

To create testnet instance of the client, you can create it with the following arguments:

from opensea_sdk import *

api_key = '' # Opensea api key

def callback(payload: dict):
    # handle event
    return

Client = OpenseaStreamClient(api_key, Network.TESTNET)

Manually connecting to the socket (optional)

The client will automatically connect to the socket as soon as you subscribe to the first channel. If you would like to connect to the socket manually (before that), you can do so:

Client.connect()

After successfully connecting to our websocket it is time to listen to specific events you're interested in!

Streaming metadata updates

We will only send out metadata updates when we detect that the metadata provided in tokenURI has changed from what OpenSea has previously cached.

Client.onItemMetadataUpdated('collection-slug', callback)

Streaming item listed events

Client.onItemListed('collection-slug', callback)

Streaming item sold events

Client.onItemSold('collection-slug', callback)

Streaming item transferred events

Client.onItemTransferred('collection-slug', callback)

Streaming bids and offers

Client.onItemReceivedBid('collection-slug', callback)

Client.onItemReceivedOffer('collection-slug', callback)

Streaming order cancellation events

Client.onItemCancelled('collection-slug', callback)

Streaming multiple event types and multiple collections

Client.onEvents(
    ['collection-slug', 'collection_slug']
    [EventTypes.ITEM_RECEIVED_OFFER, EventTypes.ITEM_TRANSFERRED],
    callback
    )

Subscribing to events from all collections

If you'd like to listen to an event from all collections use wildcard * for the slug parameter.

Types

Types are included to make working with our event payload objects easier.

Webhook

You might want to use our predefined but fully Customizable discord webhook management

from opensea_sdk import *
from discord_webhook import DiscordWebhook

webhook = DiscordWebhook(url='') # Webhook Url
api_key = '' # Opensea api key

Client = OpenseaStreamClient(api_key, Network.MAINNET)

Client.onItemListed('collection-slug', Webhook(webhook).send)

Client.startListening()

You can change the color, the footer and the thumbnail of the webhook with the following arguments:

from opensea_sdk import *
from discord_webhook import DiscordWebhook

webhook = DiscordWebhook(url='') # Webhook Url
api_key = '' # Opensea api key

custom_footer = 'My custom footer'
custom_thumbnail = '' # Image url
color_ = '' # Hexadecimal color e.g ff0000 (red)

Client = OpenseaStreamClient(api_key, Network.MAINNET)

Client.onItemListed('collection-slug', Webhook(webhook, color=color_,     thumbnail=custom_thumbnail, footer=custom_footer).send)

Client.startListening()

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc