opensea

package
v0.3.18 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: MIT Imports: 18 Imported by: 0

README

OpenSea 说明

限速问题

API Key申请中。

更新TopN NFT列表

由于OpenSea API没有获取头部Collection的接口,因此离线整理csv文档,手工导入MongoDB进行更新。

mongoimport -d opensea -c projects --drop --type=csv --headerline data/top100.csv
其他问题

collections接口limit最大是300。

Documentation

Index

Constants

View Source
const (
	CollPreferences = "preferences"

	OptionLink       = "link"
	OptionProperties = "properties"
)
View Source
const (
	EventSale      = "Sale"
	EventOffer     = "Offer"
	EventBid       = "Bid"
	EventBidCancel = "Bid Cancel"
	EventTransfer  = "Transfer"
	EventMint      = "Mint"
	EventList      = "List"
)
View Source
const (
	EventTypeTransfer  = "transfer"
	EventTypeList      = "created"
	EventTypeBid       = "bid_entered"
	EventTypeBidCancel = "bid_withdrawn"
	EventTypeSale      = "successful"
	EventTypeOffer     = "offer_entered"
)
View Source
const (
	CollEvent = "events"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	User          User   `json:"user"`
	ProfileImgUrl string `json:"profile_img_url"`
	Address       string `json:"address"`
	Config        string `json:"config"`
}

func (Account) String added in v0.3.18

func (a Account) String() string

type Asset

type Asset struct {
	TokenId       string          `json:"token_id"`
	Name          string          `json:"name"`
	AssetContract AssetContract   `json:"asset_contract"`
	Collection    AssetCollection `json:"collection"`

	ImagePreviewUrl string `json:"image_preview_url"`
}

type AssetCollection

type AssetCollection struct {
	Name string `json:"name"`
}

type AssetContract

type AssetContract struct {
	Address string `json:"address"`
	Name    string `json:"name"`
}

type AssetEvent

type AssetEvent struct {
	Asset Asset `json:"asset"`
	// transfer: Mint或者是真实的Transfer
	// created: List
	// bid_entered: Bid
	// bid_withdrawn: Bid Cancel
	// successful: Sale
	// offer_entered: Offer
	EventType string `json:"event_type"`

	// used when EventType = `bid_entered` or `offer_entered`, means bid price
	BidAmount string `json:"bid_amount"`

	// used when EventType = `created`, means list price.
	EndingPrice string `json:"ending_price"`

	// used when EventType = `successful` or `bid_withdrawn`, means sale or cancel offer
	TotalPrice string `json:"total_price"`

	CreatedDate   string   `json:"created_date"`
	FromAccount   *Account `json:"from_account"`
	ToAccount     *Account `json:"to_account"`
	Owner         *Account `json:"owner"`
	Seller        *Account `json:"seller"`
	WinnerAccount *Account `json:"winner_account"`

	PaymentToken PaymentToken `json:"payment_token"`
}

type Collection

type Collection struct {
	Sugar *zap.SugaredLogger
	// contains filtered or unexported fields
}

func NewCollection

func NewCollection(cfg CollectionConfig) *Collection

func (*Collection) Close

func (c *Collection) Close(ctx context.Context)

func (*Collection) Init

func (c *Collection) Init(ctx context.Context) error

func (*Collection) RetrieveCollections

func (c *Collection) RetrieveCollections(ctx context.Context, offset, limit int) ([]Item, error)

RetrieveCollections call OpenSea API to retrieve collections. Request like this:

curl --request GET \
    --url 'https://api.opensea.io/api/v1/collections?offset=0&limit=300'

func (*Collection) UpdateAll

func (c *Collection) UpdateAll(ctx context.Context) error

UpdateAll run once, update all collections and save to MongoDB.

func (*Collection) UpdateDaemon

func (c *Collection) UpdateDaemon(ctx context.Context) error

func (*Collection) UpdateOnce

func (c *Collection) UpdateOnce(ctx context.Context) error

type CollectionConfig

type CollectionConfig struct {
	Mongo    hs.MongoConf
	Log      hs.LogConf
	Interval string
	Top      int
}

type Config

type Config struct {
	Mongo    hs.MongoConf
	Log      hs.LogConf
	Interval string
	Discord  Discord
	Robots   []hs.BroadcastConf
	Telegram TelegramConf
}

type Configuration added in v0.2.9

type Configuration struct {
	Bot      string        `bson:"bot"` // bot username
	ChatId   int64         `bson:"chatId"`
	Projects []ProjectConf `bson:"projects"`
	Options  Options       `bson:"options"`
	Filter   []interface{} `bson:"filter"`
	ExpireAt time.Time     `bson:"expireAt"` // membership
}

type Discord

type Discord struct {
	Token         string
	SaleChannels  []string `json:"saleChannels"`
	OfferChannels []string `json:"offerChannels"`
	BidChannels   []string `json:"bidChannels"`
	OtherChannels []string `json:"otherChannels"`
	RobotChannels []string `json:"robotChannels"`
}

type Item

type Item struct {
	Name    string  `bson:"name"`
	Address string  `bson:"address"`
	Stats   RawStat `bson:"stats"`
}

Item is collection for project. One Item is one collection on OpenSea.

type OpenSea

type OpenSea struct {
	Sugar *zap.SugaredLogger
	// contains filtered or unexported fields
}

func New

func New(cfg Config) *OpenSea

func (*OpenSea) Close

func (s *OpenSea) Close(ctx context.Context)

func (*OpenSea) Init

func (s *OpenSea) Init(ctx context.Context) error

func (*OpenSea) Monitor

func (s *OpenSea) Monitor(ctx context.Context) error

type Options added in v0.2.9

type Options = map[string]bool

type PaymentToken

type PaymentToken struct {
	Symbol   string `json:"symbol"`
	Decimals int    `json:"decimals"`
}

type Project

type Project struct {
	Index   int    `bson:"index"`
	Name    string `bson:"name"`
	Address string `bson:"address"`
}

Project is a collection saved in MongoDB

type ProjectConf added in v0.2.9

type ProjectConf struct {
	Name    string `bson:"name"`
	Address string `bson:"address"`
}

type RawAssetContract

type RawAssetContract struct {
	Address string
	Name    string
}

type RawCollection

type RawCollection struct {
	Name                  string
	Description           string
	PrimaryAssetContracts []RawAssetContract `json:"primary_asset_contracts"`
	Stats                 RawStat            `json:"stats"`
	CreatedDate           string             `json:"created_date"`
}

RawCollection is the `collection` structure in ResponseCollections, the response of `/collection` API. It's different from the ResponseEvent.

type RawStat

type RawStat struct {
	OneDayVolume       float64 `json:"one_day_volume" bson:"oneDayVolume"`
	OneDayChange       float64 `json:"one_day_change" bson:"oneDayChange"`
	OneDaySales        float64 `json:"one_day_sales" bson:"oneDaySales"`
	OneDayAveragePrice float64 `json:"one_day_average_price" bson:"oneDayAveragePrice"`

	SevenDayVolume       float64 `json:"seven_day_volume" bson:"sevenDayVolume"`
	SevenDayChange       float64 `json:"seven_day_change" bson:"sevenDayChange"`
	SevenDaySales        float64 `json:"seven_day_sales" bson:"sevenDaySales"`
	SevenDayAveragePrice float64 `json:"seven_day_average_price" bson:"sevenDayAveragePrice"`

	ThirtyDayVolume       float64 `json:"thirty_day_volume" bson:"thirtyDayVolume"`
	ThirtyDayChange       float64 `json:"thirty_day_change" bson:"thirtyDayChange"`
	ThirtyDaySales        float64 `json:"thirty_day_sales" bson:"thirtyDaySales"`
	ThirtyDayAveragePrice float64 `json:"thirty_day_average_price" bson:"thirtyDayAveragePrice"`

	TotalVolume float64 `json:"total_volume" bson:"totalVolume"`
	TotalSales  float64 `json:"total_sales" bson:"totalSales"`
	TotalSupply float64 `json:"total_supply" bson:"totalSupply"`

	Count        float64 `json:"count" bson:"count"`
	NumOwners    float64 `json:"num_owners" bson:"numOwners"`
	AveragePrice float64 `json:"average_price" bson:"averagePrice"`
	NumReports   float64 `json:"num_reports" bson:"numReports"`
	MarketCap    float64 `json:"market_cap" bson:"marketCap"`
	FloorPrice   float64 `json:"floor_price" bson:"floorPrice"`
}

type Record

type Record struct {
	Collection string `json:"collection"` // collection name
	Contract   string `json:"contract"`   // collection contract address
	Name       string `json:"name"`       // NFT name
	Id         string `json:"id"`
	Event      string `json:"event"`
	Price      string `json:"price"`
	From       string `json:"from"`
	To         string `json:"to"`
	Date       string `json:"date"`

	ImagePreviewUrl string `json:"imagePreviewUrl"` // for Telegram preview

	CreatedAt time.Time `json:"createdAt"`
}

type ResponseCollections

type ResponseCollections struct {
	Collections []RawCollection `json:"collections"`
}

ResponseCollections is response of `/collection` API

type ResponseEvent

type ResponseEvent struct {
	Success     *bool
	AssetEvents []AssetEvent `json:"asset_events"`
}

type TelegramConf added in v0.2.9

type TelegramConf struct {
	Bot   string // bot username
	Token string
}

type User

type User struct {
	Username string `json:"username"`
}

Jump to

Keyboard shortcuts

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