opensea

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

README

opensea-go

Go Reference codecov golangci-lint Go Report Card License

Golang's library for OpenSea APIs (https://docs.opensea.io/reference).

Get Started

Get it
go get -u github.com/pinealctx/opensea-go
Use it
package main

import (
	"context"
	"github.com/pinealctx/opensea-go"
	"log"
)

func main() {
	var cli = opensea.New(opensea.WithTestNets(true))
	var asset, err = cli.Asset(context.Background(), &opensea.AssetRequest{
		AssetContractAddress: "0x66583bd73a27c9245b723ff6a58f872234c3a50a",
		TokenID:              "3",
	})
	if err != nil {
		log.Fatalln(err)
		return
	}
	log.Println(asset)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound        = errors.New("resource.not.found")
	ErrTooManyRequests = errors.New("too.many.requests")
	ErrInternalServer  = errors.New("internal.server.error")
)

Functions

func ParseRsp

func ParseRsp(rsp restgo.IResponse, i interface{}) error

func WrapperCountContext added in v0.1.0

func WrapperCountContext(ctx context.Context, count int) context.Context

Types

type AssetRequest

type AssetRequest struct {
	// The NFT contract address for the assets
	AssetContractAddress string `path:"asset_contract_address,required"`
	// Address of the contract for this NFT
	TokenID string `path:"token_id,required"`
	// Address of an owner of the token.
	// If you include this, the response will include an ownership object that includes
	// the number of tokens owned by the address provided instead of the top_ownerships object
	// included in the standard response, which provides the number of tokens owned by each of
	// the 10 addresses with the greatest supply of the token.
	AccountAddress string `query:"account_address"`
}

type AssetsRequest

type AssetsRequest struct {
	// The address of the owner of the assets
	Owner string `query:"owner"`
	// An array of token IDs to search for (e.g. ?token_ids=1&token_ids=209).
	// Will return a list of assets with token_id matching any of the IDs in this array.
	TokenIDs []string `query:"token_ids"`
	// The NFT contract address for the assets
	AssetContractAddress string `query:"asset_contract_address"`
	// An array of contract addresses to search for (e.g. ?asset_contract_addresses=0x1...&asset_contract_addresses=0x2...).
	// Will return a list of assets with contracts matching any of the addresses in this array.
	// If "token_ids" is also specified, then it will only return assets that match each (address, token_id) pairing, respecting order.
	AssetContractAddresses []string `query:"asset_contract_addresses"`
	// How to order the assets returned. By default, the API returns the fastest ordering.
	// Options you can set are sale_date (the last sale's transaction's timestamp),
	// sale_count (number of sales), and sale_price (the last sale's total_price)
	OrderBy string `query:"order_by"`
	// Can be asc for ascending or desc for descending
	OrderDirection string `query:"order_direction,required"`
	// Offset
	Offset int32 `query:"offset"`
	// Limit
	Limit int32 `query:"limit,required"`

	//Cursor A cursor pointing to the page to retrieve
	Cursor string `query:"cursor"`

	// Limit responses to members of a collection.
	// Case-sensitive and must match the collection slug exactly.
	// Will return all assets from all contracts in a collection.
	// For more information on collections, see our collections documentation.
	Collection string `query:"collection"`

	// Limit responses to members of a collection.
	// Case sensitive and must match the collection slug exactly.
	// Will return all assets from all contracts in a collection.
	// For more information on collections,
	CollectionSlug string `query:"collection_slug"`

	// CollectionEditor
	CollectionEditor string `query:"collection_editor"`

	// A flag determining if order information should be included in the response.
	IncludeOrders bool `query:"include_orders"`
}

type AssetsResponse

type AssetsResponse struct {
	Assets   []*model.Asset `opensea:"assets"`
	Next     string         `opensea:"next"`
	Previous string         `opensea:"previous"`
}

type BundlesRequest

type BundlesRequest struct {
	// If set to true, only show bundles currently on sale.
	// If set to false, only show bundles that have been sold or cancelled.
	OnSale bool `json:"on_sale"`
	// The address of the owner of the assets
	Owner string `query:"owner"`
	// The NFT contract address for the assets
	AssetContractAddress string `query:"asset_contract_address"`
	// An array of contract addresses to search for (e.g. ?asset_contract_addresses=0x1...&asset_contract_addresses=0x2...).
	// Will return a list of assets with contracts matching any of the addresses in this array.
	// If "token_ids" is also specified, then it will only return assets that match each (address, token_id) pairing, respecting order.
	AssetContractAddresses []string `query:"asset_contract_addresses"`
	// An array of token IDs to search for (e.g. ?token_ids=1&token_ids=209).
	// Will return a list of assets with token_id matching any of the IDs in this array.
	TokenIDs []string `query:"token_ids"`
	// Limit
	Limit int32 `query:"limit,required"`
	// Offset
	Offset int32 `query:"offset,required"`
}

type BundlesResponse

type BundlesResponse struct {
	Bundles []*model.Bundle `opensea:"bundles"`
}

type Client

type Client struct {
	*restgo.Client
	// contains filtered or unexported fields
}

func New

func New(fnList ...OptionFn) *Client

func (*Client) Asset

func (c *Client) Asset(ctx context.Context, req *AssetRequest) (*model.Asset, error)

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

func (*Client) Assets

func (c *Client) Assets(ctx context.Context, req *AssetsRequest) (*AssetsResponse, error)

Assets To retrieve assets from our API, call the /assets endpoint with the desired filter parameters.

func (*Client) Bundles

func (c *Client) Bundles(ctx context.Context, req *BundlesRequest) ([]*model.Bundle, error)

Bundles are groups of items for sale on OpenSea. You can buy them all at once in one transaction, and you can create them without any transactions or gas, as long as you've already approved the assets inside.

func (*Client) Collection

func (c *Client) Collection(ctx context.Context, req *CollectionRequest) (*model.Collection, error)

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

func (*Client) CollectionStats

func (c *Client) CollectionStats(ctx context.Context, req *CollectionRequest) (*model.CollectionStats, error)

CollectionStats Use this endpoint to fetch stats for a specific collection, including realtime floor price statistics

func (*Client) Collections

func (c *Client) Collections(ctx context.Context, req *CollectionsRequest) ([]*model.Collection, error)

Collections Use this endpoint to fetch collections on OpenSea

func (*Client) Contract

func (c *Client) Contract(ctx context.Context, req *ContractRequest) (*model.Contract, error)

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

func (*Client) Events

func (c *Client) Events(ctx context.Context, req *EventsRequest) (*EventsResponse, error)

Events The /events endpoint provides a list of events that occur on the assets that OpenSea tracks. The "event_type" field indicates what type of event it is (transfer, successful auction, etc).

func (*Client) Orders

func (c *Client) Orders(ctx context.Context, req *OrderRequest) (*OrderResponse, error)

Orders How to fetch orders from the OpenSea system

type CollectionRequest

type CollectionRequest struct {
	CollectionSlug string `path:"collection_slug,required"`
}

type CollectionResponse

type CollectionResponse struct {
	Collection *model.Collection `opensea:"collection"`
}

type CollectionStatsResponse

type CollectionStatsResponse struct {
	Stats *model.CollectionStats `opensea:"stats"`
}

type CollectionsRequest

type CollectionsRequest struct {
	// A wallet address. If specified, will return collections where the owner owns at least one asset belonging to smart contracts in the collection.
	// The number of assets the account owns is shown as owned_asset_count for each collection.
	AssetOwner string `query:"asset_owner"`
	// Offset
	Offset int32 `query:"offset,required"`
	// Limit
	Limit int32 `query:"limit,required"`
}

type CollectionsResponse

type CollectionsResponse struct {
	Collections []*model.Collection `opensea:"collections"`
}

type ContractRequest

type ContractRequest struct {
	// Address of the contract
	AssetContractAddress string `path:"asset_contract_address,required"`
}

type EventsRequest

type EventsRequest struct {
	// Restrict to events on OpenSea auctions. Can be true or false
	OnlyOpensea bool `query:"only_opensea"`
	// The token's id to optionally filter by
	TokenID string `query:"token_id"`
	// The NFT contract address for the assets
	AssetContractAddress string `query:"asset_contract_address"`
	// Limit responses to events from a collection. Case sensitive and must match the collection slug exactly.
	// Will return all assets from all contracts in a collection.
	// For more information on collections, see our collections documentation.
	CollectionSlug   string `query:"collection_slug"`
	CollectionEditor string `query:"collection_editor"`
	// A user account's wallet address to filter for events on an account
	AccountAddress string `query:"account_address"`
	// The event type to filter.
	EventType model.EventType `query:"event_type"`
	// Filter by an auction type.
	AuctionType model.AuctionType `query:"auction_type"`
	// Only show events listed before this timestamp. Seconds since the Unix epoch.
	// eg: 2017-07-21T17:32:28Z
	OccurredBefore string `query:"occurred_before"`
	// Only show events listed after this timestamp. Seconds since the Unix epoch.
	// eg: 2017-07-21T17:32:28Z
	OccurredAfter string `query:"occurred_after"`
	// A cursor pointing to the page to retrieve
	Cursor string `query:"cursor"`
}

type EventsResponse

type EventsResponse struct {
	// List of Event Object
	AssetEvents []*model.Event `opensea:"asset_events"`
	// A cursor to be supplied as a query param to retrieve the next page
	Next string `opensea:"next"`
	// A cursor to be supplied as a query param to retrieve the previous page
	Previous string `opensea:"previous"`
}

type OptionFn

type OptionFn func(*option)

func WithAPIKey

func WithAPIKey(apiKey string) OptionFn

func WithRetryWhenFreqLimit added in v0.1.0

func WithRetryWhenFreqLimit(interval time.Duration, count int) OptionFn

func WithTestNets added in v0.1.0

func WithTestNets(test bool) OptionFn

type OrderRequest

type OrderRequest struct {
	// Filter by smart contract address for the asset category.
	// Needs to be defined together with token_id or token_ids.
	AssetContractAddress string `query:"asset_contract_address"`
	// Filter by the address of the smart contract of the payment token that is accepted or offered by the order
	PaymentTokenAddress string `query:"payment_token_address"`
	// Filter by the order maker's wallet address
	Maker string `query:"maker"`
	// Filter by the order taker's wallet address.
	// Orders open for any taker have the null address as their taker.
	Taker string `query:"taker"`
	// Filter by the asset owner's wallet address
	Owner string `query:"owner"`
	// When "true", only show English Auction sell orders,
	// which wait for the highest bidder. When "false", exclude those.
	IsEnglish bool `query:"is_english"`
	// Only show orders for bundles of assets
	Bundled bool `query:"bundled"`
	// Include orders on bundles where all assets in the bundle share the address provided
	// in asset_contract_address or where the bundle's maker is the address provided in owner
	IncludeBundled bool `query:"include_bundled"`
	// Only show orders listed after this timestamp. Seconds since the Unix epoch.
	// eg: 2017-07-21T17:32:28Z
	ListedAfter string `query:"listed_after"`
	// Only show orders listed before this timestamp. Seconds since the Unix epoch.
	// eg: 2017-07-21T17:32:28Z
	ListedBefore string `query:"listed_before"`
	// Filter by the token ID of the order's asset.
	// Needs to be defined together with asset_contract_address.
	TokenID string `query:"token_id"`
	// Filter by a list of token IDs for the order's asset.
	// Needs to be defined together with asset_contract_address.
	TokenIDs []string `query:"token_ids"`
	// Filter by the side of the order.
	// 0 for buy orders and 1 for sale orders.
	Side model.Side `query:"side,required"`
	// Filter by the kind of sell order.
	// 0 for fixed-price sales or min-bid auctions,
	// and 1 for declining-price Dutch Auctions.
	// use only_english=true for filtering for only English Auctions
	SaleKind model.SaleKind `query:"sale_kind"`
	// Limit
	Limit int32 `query:"limit,required"`
	// Offset
	Offset int32 `query:"offset,required"`
	// How to sort the orders. Can be created_date for when they were made,
	// or eth_price to see the lowest-priced orders first (converted to their ETH values).
	// eth_price is only supported when asset_contract_address and token_id are also defined.
	OrderBy string `query:"order_by"`
	// Can be asc or desc for ascending or descending sort.
	// For example, to see the cheapest orders, do order_direction asc and order_by eth_price.
	OrderDirection string `query:"order_direction,required"`
}

type OrderResponse

type OrderResponse struct {
	Count  int32          `opensea:"count"`
	Orders []*model.Order `opensea:"orders"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL