tcgplayer

package
v0.4.54 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2024 License: MIT Imports: 21 Imported by: 2

Documentation

Index

Constants

View Source
const (
	SellersPageURL     = "https://shop.tcgplayer.com/sellers"
	SellerInventoryURL = "https://mp-search-api.tcgplayer.com/v1/search/request?q=&isList=true&mpfev=1953"
	SellerListingURL   = "https://mp-search-api.tcgplayer.com/v1/product/%d/listings"

	DefaultSellerRequestSize = 50

	MaxGlobalScrapingValue = 8000
)
View Source
const (
	BaseProductURL    = "https://www.tcgplayer.com/product/"
	PartnerProductURL = "https://tcgplayer.pxf.io/c/%s/1830156/21018"
)
View Source
const (
	SYPCSVURL = "https://store.tcgplayer.com/admin/direct/ExportSYPList?categoryid=1&setNameId=All&conditionId=All"
)

Variables

View Source
var SKUConditionMap = map[int]string{
	1: "NM",
	2: "SP",
	3: "MP",
	4: "HP",
	5: "PO",
}

Functions

func CreateCartKey added in v0.4.48

func CreateCartKey(userId string) (string, error)

func DirectPriceAfterFees added in v0.4.34

func DirectPriceAfterFees(price float64) float64

func EditionMap added in v0.4.45

func EditionMap(tcg *tcgplayer.Client, category int) (map[int]tcgplayer.Group, error)

func GenerateProductURL added in v0.4.48

func GenerateProductURL(productId int, printing, affiliate, condition, language string, isDirect bool) string

func GetProductNameAndVariant added in v0.4.45

func GetProductNameAndVariant(tcgp *tcgplayer.Product) (string, string)

func GetProductNumber added in v0.4.45

func GetProductNumber(tcgp *tcgplayer.Product) string

func LatestSales added in v0.4.48

func LatestSales(tcgProductId string, flags ...bool) (*latestSalesResponse, error)

func LoadTCGSKUs

func LoadTCGSKUs(reader io.Reader) (mtgjson.AllTCGSkus, error)

func Preprocess

func Preprocess(product *tcgplayer.Product, editions map[int]string) (*mtgmatcher.InputCard, error)

func SellerKeyExists added in v0.4.22

func SellerKeyExists(sellerKey string) bool

func SellerName2ID added in v0.3.16

func SellerName2ID(sellerName string) (string, error)

Types

type AddressConfig added in v0.4.48

type AddressConfig struct {
	FirstName                 string `json:"firstName"`
	LastName                  string `json:"lastName"`
	AddressLine1              string `json:"addressLine1"`
	AddressLine2              string `json:"addressLine2"`
	City                      string `json:"city"`
	ZipCode                   string `json:"zipCode"`
	StateProvinceRegion       string `json:"stateProvinceRegion"`
	Phone                     string `json:"phone"`
	IsDefaultAddress          bool   `json:"isDefaultAddress"`
	SaveAddressOnPaymentSave  bool   `json:"saveAddressOnPaymentSave"`
	ExternalUserID            string `json:"externalUserId"`
	CountryCode               string `json:"countryCode"`
	ID                        int    `json:"id"`
	EasyPostShippingAddressID string `json:"easyPostShippingAddressId"`
	IsEasyPostVerified        bool   `json:"isEasyPostVerified"`
	CreatedAt                 string `json:"createdAt"`
	LastUsedAt                string `json:"lastUsedAt"`
}

type CookieClient added in v0.4.37

type CookieClient struct {
	// contains filtered or unexported fields
}

func NewCookieClient added in v0.4.37

func NewCookieClient(authKey string) *CookieClient

func NewCookieSetClient added in v0.4.48

func NewCookieSetClient(cookies map[string]string) *CookieClient

func (*CookieClient) Delete added in v0.4.54

func (tcg *CookieClient) Delete(link string) (*http.Response, error)

func (*CookieClient) EmptyCart added in v0.4.54

func (tcg *CookieClient) EmptyCart(cartKey string) error

func (*CookieClient) Get added in v0.4.48

func (tcg *CookieClient) Get(link string) (*http.Response, error)

func (*CookieClient) GetUserData added in v0.4.37

func (tcg *CookieClient) GetUserData() (*UserData, error)

func (*CookieClient) Post added in v0.4.48

func (tcg *CookieClient) Post(link, contentType string, body io.Reader) (*http.Response, error)

func (*CookieClient) SetAddress added in v0.4.48

func (tcg *CookieClient) SetAddress(address AddressConfig) error

type LatestSalesData

type LatestSalesData struct {
	Condition       string    `json:"condition"`
	Variant         string    `json:"variant"`
	Language        string    `json:"language"`
	Quantity        int       `json:"quantity"`
	Title           string    `json:"title"`
	ListingType     string    `json:"listingType"`
	CustomListingID string    `json:"customListingId"`
	PurchasePrice   float64   `json:"purchasePrice"`
	ShippingPrice   float64   `json:"shippingPrice"`
	OrderDate       time.Time `json:"orderDate"`
}

type ListingData added in v0.4.38

type ListingData struct {
	ProductId       int     `json:"product_id"`
	SkuId           int     `json:"sku_id"`
	Quantity        int     `json:"quantity"`
	SellerKey       string  `json:"seller_key"`
	Price           float64 `json:"price"`
	DirectInventory int     `json:"direct_inventory"`
	ConditionFull   string  `json:"condition_full"`
	Condition       string  `json:"condition"`
	Printing        string  `json:"printing"`
	Foil            bool    `json:"foil"`
}

func GetDirectQtysForProductId added in v0.4.38

func GetDirectQtysForProductId(productId int, onlyDirect bool) []ListingData

type SellerClient added in v0.4.48

type SellerClient struct {
	// contains filtered or unexported fields
}

func NewSellerClient added in v0.4.48

func NewSellerClient() *SellerClient

func (*SellerClient) InventoryForSeller added in v0.4.48

func (tcg *SellerClient) InventoryForSeller(sellerKeys []string, size, page int, useDirect bool, finishes []string, sets ...string) (*sellerInventoryResponse, error)

func (*SellerClient) InventoryListing added in v0.4.48

func (tcg *SellerClient) InventoryListing(productId, size, page int, useDirect bool) ([]SellerListing, error)

type SellerInventoryResult added in v0.3.16

type SellerInventoryResult struct {
	FoilOnly                bool    `json:"foilOnly"`
	ImageCount              float64 `json:"imageCount"`
	LowestPrice             float64 `json:"lowestPrice"`
	LowestPriceWithShipping float64 `json:"lowestPriceWithShipping"`
	MarketPrice             float64 `json:"marketPrice"`
	MaxFulfillableQuantity  float64 `json:"maxFulfillableQuantity"`
	NormalOnly              bool    `json:"normalOnly"`
	ProductID               float64 `json:"productId"`
	ProductLineID           float64 `json:"productLineId"`
	ProductLineName         string  `json:"productLineName"`
	ProductLineURLName      string  `json:"productLineUrlName"`
	ProductName             string  `json:"productName"`
	ProductStatusID         float64 `json:"productStatusId"`
	ProductTypeID           float64 `json:"productTypeId"`
	ProductTypeName         string  `json:"productTypeName"`
	ProductURLName          string  `json:"productUrlName"`
	RarityName              string  `json:"rarityName"`
	Score                   float64 `json:"score"`
	Sealed                  bool    `json:"sealed"`
	SellerListable          bool    `json:"sellerListable"`
	Sellers                 float64 `json:"sellers"`
	SetCode                 string  `json:"setCode"`
	SetID                   float64 `json:"setId"`
	SetName                 string  `json:"setName"`
	SetURLName              string  `json:"setUrlName"`
	ShippingCategoryID      float64 `json:"shippingCategoryId"`
	TotalListings           float64 `json:"totalListings"`
	CustomAttributes        struct {
		Number string `json:"number"`
	} `json:"customAttributes"`
	Listings []SellerListing `json:"listings"`
}

type SellerListing added in v0.4.21

type SellerListing struct {
	ChannelID            float64 `json:"channelId"`
	Condition            string  `json:"condition"`
	ConditionID          float64 `json:"conditionId"`
	DirectInventory      float64 `json:"directInventory"`
	DirectProduct        bool    `json:"directProduct"`
	DirectSeller         bool    `json:"directSeller"`
	ForwardFreight       bool    `json:"forwardFreight"`
	GoldSeller           bool    `json:"goldSeller"`
	Language             string  `json:"language"`
	LanguageAbbreviation string  `json:"languageAbbreviation"`
	LanguageID           float64 `json:"languageId"`
	ListingID            float64 `json:"listingId"`
	ListingType          string  `json:"listingType"`
	Price                float64 `json:"price"`
	Printing             string  `json:"printing"`
	ProductConditionID   float64 `json:"productConditionId"`
	ProductID            float64 `json:"productId"`
	Quantity             float64 `json:"quantity"`
	RankedShippingPrice  float64 `json:"rankedShippingPrice"`
	Score                float64 `json:"score"`
	SellerID             string  `json:"sellerId"`
	SellerKey            string  `json:"sellerKey"`
	SellerName           string  `json:"sellerName"`
	SellerRating         float64 `json:"sellerRating"`
	SellerSales          string  `json:"sellerSales"`
	SellerShippingPrice  float64 `json:"sellerShippingPrice"`
	ShippingPrice        float64 `json:"shippingPrice"`
	VerifiedSeller       bool    `json:"verifiedSeller"`
}

type TCGAutoClient added in v0.3.34

type TCGAutoClient struct {
	// contains filtered or unexported fields
}

func NewTCGAutoClient added in v0.3.34

func NewTCGAutoClient(cartId string) *TCGAutoClient

func (*TCGAutoClient) AddProductToCart added in v0.3.34

func (tcg *TCGAutoClient) AddProductToCart(sellerKey string, skuId, qty int, isDirect bool) (*TCGAutocartResponse, error)

type TCGAutocartRequest added in v0.3.34

type TCGAutocartRequest struct {
	SKU               int    `json:"sku"`
	SellerKey         string `json:"sellerKey"`
	ChannelID         int    `json:"channelId"`
	RequestedQuantity int    `json:"requestedQuantity"`
	Price             int    `json:"price"`
	IsDirect          bool   `json:"isDirect"`
}

type TCGAutocartResponse added in v0.3.34

type TCGAutocartResponse struct {
	Errors []struct {
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"errors"`
	Results []struct {
		IsDirect                bool    `json:"isDirect"`
		SellerQuantityAvailable int     `json:"sellerQuantityAvailable"`
		ItemQuantityInCart      int     `json:"itemQuantityInCart"`
		CurrentPrice            float64 `json:"currentPrice"`
		Status                  int     `json:"status"`
	}
}

type TCGLorcana added in v0.4.42

type TCGLorcana struct {
	LogCallback mtgban.LogCallbackFunc

	Affiliate      string
	MaxConcurrency int
	// contains filtered or unexported fields
}

func NewLorcanaScraper added in v0.4.42

func NewLorcanaScraper(publicId, privateId string) (*TCGLorcana, error)

func (*TCGLorcana) Info added in v0.4.42

func (tcg *TCGLorcana) Info() (info mtgban.ScraperInfo)

func (*TCGLorcana) Inventory added in v0.4.42

func (tcg *TCGLorcana) Inventory() (mtgban.InventoryRecord, error)

type TCGLorcanaIndex added in v0.4.42

type TCGLorcanaIndex struct {
	LogCallback mtgban.LogCallbackFunc

	Affiliate      string
	MaxConcurrency int
	// contains filtered or unexported fields
}

func NewLorcanaIndex added in v0.4.42

func NewLorcanaIndex(publicId, privateId string) (*TCGLorcanaIndex, error)

func (*TCGLorcanaIndex) Info added in v0.4.42

func (tcg *TCGLorcanaIndex) Info() (info mtgban.ScraperInfo)

func (*TCGLorcanaIndex) InfoForScraper added in v0.4.48

func (tcg *TCGLorcanaIndex) InfoForScraper(name string) mtgban.ScraperInfo

func (*TCGLorcanaIndex) Inventory added in v0.4.42

func (tcg *TCGLorcanaIndex) Inventory() (mtgban.InventoryRecord, error)

func (*TCGLorcanaIndex) MarketNames added in v0.4.42

func (tcg *TCGLorcanaIndex) MarketNames() []string

type TCGPlayerGeneric

type TCGPlayerGeneric struct {
	LogCallback mtgban.LogCallbackFunc

	Affiliate      string
	MaxConcurrency int
	// contains filtered or unexported fields
}

func NewScraperGeneric

func NewScraperGeneric(publicId, privateId string, category int, productTypes ...string) (*TCGPlayerGeneric, error)

func (*TCGPlayerGeneric) Info

func (tcg *TCGPlayerGeneric) Info() (info mtgban.ScraperInfo)

func (*TCGPlayerGeneric) Inventory

func (tcg *TCGPlayerGeneric) Inventory() (mtgban.InventoryRecord, error)

type TCGPlayerIndex

type TCGPlayerIndex struct {
	LogCallback mtgban.LogCallbackFunc

	Affiliate      string
	MaxConcurrency int
	// contains filtered or unexported fields
}

func NewScraperIndex

func NewScraperIndex(publicId, privateId string) *TCGPlayerIndex

func (*TCGPlayerIndex) Info

func (tcg *TCGPlayerIndex) Info() (info mtgban.ScraperInfo)

func (*TCGPlayerIndex) InfoForScraper added in v0.4.48

func (tcg *TCGPlayerIndex) InfoForScraper(name string) mtgban.ScraperInfo

func (*TCGPlayerIndex) Inventory

func (tcg *TCGPlayerIndex) Inventory() (mtgban.InventoryRecord, error)

func (*TCGPlayerIndex) MarketNames

func (tcg *TCGPlayerIndex) MarketNames() []string

type TCGPlayerMarket

type TCGPlayerMarket struct {
	LogCallback mtgban.LogCallbackFunc

	Affiliate      string
	MaxConcurrency int

	// The cache data defining SKU data, if not set it will be loaded
	// from the default location on mtgjson website.
	SKUsData map[string][]mtgjson.TCGSku
	// contains filtered or unexported fields
}

func NewScraperMarket

func NewScraperMarket(publicId, privateId string) *TCGPlayerMarket

func (*TCGPlayerMarket) Buylist

func (tcg *TCGPlayerMarket) Buylist() (mtgban.BuylistRecord, error)

func (*TCGPlayerMarket) Info

func (tcg *TCGPlayerMarket) Info() (info mtgban.ScraperInfo)

func (*TCGPlayerMarket) InfoForScraper added in v0.4.48

func (tcg *TCGPlayerMarket) InfoForScraper(name string) mtgban.ScraperInfo

func (*TCGPlayerMarket) Inventory

func (tcg *TCGPlayerMarket) Inventory() (mtgban.InventoryRecord, error)

func (*TCGPlayerMarket) MarketNames

func (tcg *TCGPlayerMarket) MarketNames() []string

func (*TCGPlayerMarket) TraderNames added in v0.4.49

func (tcg *TCGPlayerMarket) TraderNames() []string

type TCGPlayerSealed

type TCGPlayerSealed struct {
	LogCallback    mtgban.LogCallbackFunc
	Affiliate      string
	MaxConcurrency int

	SKUsData map[string][]mtgjson.TCGSku
	// contains filtered or unexported fields
}

func NewScraperSealed

func NewScraperSealed(publicId, privateId string) *TCGPlayerSealed

func (*TCGPlayerSealed) Info

func (tcg *TCGPlayerSealed) Info() (info mtgban.ScraperInfo)

func (*TCGPlayerSealed) Inventory

func (tcg *TCGPlayerSealed) Inventory() (mtgban.InventoryRecord, error)

type TCGSYP added in v0.4.30

type TCGSYP struct {
	SkuId       int
	MarketPrice float64
	MaxQty      int
}

func LoadSyp added in v0.4.30

func LoadSyp(auth string) ([]TCGSYP, error)

type TCGSYPList

type TCGSYPList struct {
	LogCallback mtgban.LogCallbackFunc
	Affiliate   string
	// contains filtered or unexported fields
}

func NewScraperSYP

func NewScraperSYP(auth string) *TCGSYPList

func (*TCGSYPList) Buylist added in v0.4.33

func (tcg *TCGSYPList) Buylist() (mtgban.BuylistRecord, error)

func (*TCGSYPList) Info

func (tcg *TCGSYPList) Info() (info mtgban.ScraperInfo)

type TCGSellerInventory added in v0.3.16

type TCGSellerInventory struct {
	LogCallback    mtgban.LogCallbackFunc
	MaxConcurrency int
	Affiliate      string
	// contains filtered or unexported fields
}

func NewScraperForSeller added in v0.3.16

func NewScraperForSeller(sellerName string, onlyDirect bool) (*TCGSellerInventory, error)

func NewScraperForSellerIds added in v0.3.42

func NewScraperForSellerIds(sellerKeys []string, onlyDirect bool) *TCGSellerInventory

func (*TCGSellerInventory) Info added in v0.3.16

func (tcg *TCGSellerInventory) Info() (info mtgban.ScraperInfo)

func (*TCGSellerInventory) Inventory added in v0.3.16

func (tcg *TCGSellerInventory) Inventory() (mtgban.InventoryRecord, error)

type UserData added in v0.4.48

type UserData struct {
	UserName                string `json:"userName"`
	UserID                  int    `json:"userId"`
	UserKey                 string `json:"userKey"`
	IsSubscriber            bool   `json:"isSubscriber"`
	LastUsedShippingAddress struct {
		FirstName string `json:"firstName"`
		LastName  string `json:"lastName"`
		Address1  string `json:"address1"`
		Address2  string `json:"address2"`
		City      string `json:"city"`
		State     string `json:"state"`
		Zipcode   string `json:"zipcode"`
		Country   string `json:"country"`
		Phone     string `json:"phone"`
	} `json:"lastUsedShippingAddress"`
	ShippingCountry     string `json:"shippingCountry"`
	CreatedAt           string `json:"createdAt"`
	ExternalUserID      string `json:"externalUserId"`
	IsGuest             any    `json:"isGuest"`
	IsValidated         bool   `json:"isValidated"`
	CartKey             string `json:"cartKey"`
	SaveForLaterKey     string `json:"saveForLaterKey"`
	ProductLineAffinity any    `json:"productLineAffinity"`
	Traits              struct {
		ProductLineAffinityMostViewed any `json:"product_line_affinity_most_viewed"`
		Apv                           int `json:"apv"`
	} `json:"traits"`
	SellerKeys []string `json:"sellerKeys"`
}

type UserResponse added in v0.4.48

type UserResponse struct {
	Errors []struct {
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"errors"`
	Results []UserData `json:"results"`
}

Jump to

Keyboard shortcuts

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