steam

package module
v0.0.0-...-ede876a Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: LGPL-2.1 Imports: 30 Imported by: 0

README

Steam Build Status

Steam is a library for interactions with Steam, it's written in Go.
Steam tries to keep-it-simple and does not add extra non-sense. There are absolutely no internal-polling or such, everything is up to you, all it does is wrap around Steam API.

Why?

  • You don't want a library to be "re-trying" automatically
  • You don't want a library to be doing your homework
  • You are an on-point person and just want stuff that works as-needed

Installation

Make sure you have at least Go 1.6 with a GOPATH set then run:

go get github.com/PuerkitoBio/goquery
go get github.com/NapasP/steam_web

Example

package main

import (
	"log"
	"os"

	"github.com/NapasP/steam_web"
)

func main() {
	log.SetFlags(log.LstdFlags | log.Lshortfile)

	timeTip, err := steam.GetTimeTip()
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("Time tip: %#v\n", timeTip)
	timeDiff := time.Duration(timeTip.Time - time.Now().Unix())
	
	session := steam.NewSession(&http.Client{}, "")
	if err := session.Login(os.Getenv("steamAccount"), os.Getenv("steamPassword"), os.Getenv("steamSharedSecret"), timeDiff); err != nil {
		log.Fatal(err)
	}
	log.Print("Login successful")
}

Find more examples in the examples/ directory. Even better is to read through the source code, it's simple and straight-forward to understand.

Trade offers, inventories and errors (context-aware API)

The functions below take a context.Context, check HTTP status / x-eresult, and return a *steam.SteamError (errors.As) with the HTTP status, the EResult, Steam's message and a Cause (TradeBan, NewDevice, TargetCannotTrade, OfferLimitExceeded, ItemServerUnavailable, NotLoggedIn, PrivateInventory, RateLimited, InvalidTradeURL). Helpers: IsRateLimited, IsTemporary, RetryAfterOf, errors.Is(err, steam.ErrNotLoggedIn / ErrInventoryPrivate / ErrOfferNotFound / ErrTradeNotFound / ErrNoPrice). The library never retries on its own; opt in with steam.Retry(ctx, steam.DefaultRetryPolicy, fn) (exponential backoff with jitter, honours Retry-After).

Function What it does
ParseTradeURL(raw) Validates https://steamcommunity.com/tradeoffer/new/?partner=N&token=T → AccountID, Token, SteamID()
GetUserInventoryContents(ctx, sid, 730, 2, opts) Any user's inventory via /inventory/{steamid}/{app}/{ctx}: pagination, descriptions + asset_properties merged (Float()), private inventory → ErrInventoryPrivate
GetPartnerDetails(ctx, tradeURL) Trade-hold days of both sides from the "new offer" page; invalid token / trade ban → SteamError with a cause
GetTradeHoldDurations(ctx, sid, token) Same through IEconService/GetTradeHoldDurations
SendOffer(ctx, OfferRequest) Creates an offer (json_tradeoffer exactly as the web client sends it, token in trade_offer_create_params); reports NeedsMobileConfirmation
AcceptConfirmationForObject(identitySecret, offerID, now) Confirms the mobile confirmation of one offer
GetOffer(ctx, id) / GetOffers(ctx, opts) IEconService/GetTradeOffer(s) with cursor paging; TradeOfferState has String/IsOpen/IsFinal
CancelOffer / DeclineOffer strError bodies are parsed into EResult + cause
GetTradeStatus(ctx, tradeID) Exchange details (ETradeStatus, assets_received[].new_assetid) to detect rollbacks: IsCompleted / IsPending / IsRolledBack
GetPriceOverview(ctx, 730, currency, name) / ParseMarketPrice Market price in any currency ("1 234,56₴", "$1,234.56" …)
EconomyImageURL(icon, "256fx256f"), (*EconItemDesc).Tag("Rarity") Item helpers

EconItemDesc now accepts both the IEconService (booleans) and the /inventory (0/1) encodings, which also fixes the legacy GetInventory. The legacy GetTradeOffer returns ErrOfferNotFound instead of a nil offer.

tu, err := steam.ParseTradeURL(userInput)
hold, err := session.GetPartnerDetails(ctx, tu) // hold.TheirEscrowDays > 0 → partner has no mobile authenticator
sent, err := session.SendOffer(ctx, steam.OfferRequest{
	Partner: tu.SteamID(), Token: tu.Token, Message: "order NP-123",
	ItemsToReceive: []steam.TradeItem{{AppID: 730, ContextID: 2, AssetID: 123456789}},
})
offer, _, err := session.GetOffer(ctx, sent.ID) // poll; offer.OfferState() == steam.Accepted → offer.ReceiptID is the trade id
ts, err := session.GetTradeStatus(ctx, offer.ReceiptID)
if ts.Status.IsRolledBack() { /* do not pay */ }

Tests run against httptest servers (go test ./...); the examples/ programs are from the upstream fork and are excluded from the build (//go:build ignore).

Authors

License

LGPL 2.1

Documentation

Index

Constants

View Source
const (
	PersonaStateOffline = iota
	PersonaStateOnline
	PersonaStateBusy
	PersonaStateAway
	PersonaStateSnooze
	PersonaStateLookingToTrade
	PersonaStateLookingToPlay
)
View Source
const (
	PersonaStateFlagRichPresence   = 1 << 0
	PersonaStateFlagInJoinableGame = 1 << 1
	PersonaStateFlagWeb            = 1 << 8
	PersonaStateFlagMobile         = 1 << 9
	PersonaStateFlagBigPicture     = 1 << 10
)
View Source
const (
	MessageTypeStatus  = "personastate"
	MessageTypeTyping  = "typing"
	MessageTypeSayText = "saytext"
)
View Source
const (
	ChatUIModeMobile = "mobile" // empty string works too
	ChatUIModeWeb    = "web"
)
View Source
const (
	CauseTradeBan              = "TradeBan"
	CauseNewDevice             = "NewDevice"
	CauseTargetCannotTrade     = "TargetCannotTrade"
	CauseOfferLimitExceeded    = "OfferLimitExceeded"
	CauseItemServerUnavailable = "ItemServerUnavailable"
	CauseNotLoggedIn           = "NotLoggedIn"
	CausePrivateInventory      = "PrivateInventory"
	CauseRateLimited           = "RateLimited"
	CauseInvalidTradeURL       = "InvalidTradeURL"
)

Error causes (SteamError.Cause), mirroring node-steam-tradeoffer-manager's error.cause values.

View Source
const (
	RSAPublicKey      = APIBaseUrl + "/IAuthenticationService/GetPasswordRSAPublicKey/v1"
	AuthSession       = APIBaseUrl + "/IAuthenticationService/BeginAuthSessionViaCredentials/v1"
	UpdateAuthSession = APIBaseUrl + "/IAuthenticationService/UpdateAuthSessionWithSteamGuardCode/v1"
	Poll              = APIBaseUrl + "/IAuthenticationService/PollAuthSessionStatus/v1"

	LoginBaseUrl   = "https://login.steampowered.com"
	FinalizeLogin  = LoginBaseUrl + "/jwt/finalizelogin"
	RefreshSession = LoginBaseUrl + "/jwt/refresh?redir=https%3A%2F%2Fsteamcommunity.com"
)
View Source
const (
	CurrencyUSD = "1"
	CurrencyGBP = "2"
	CurrencyEUR = "3"
	CurrencyCHF = "4"
	CurrencyRUB = "5"
	CurrencyPLN = "6"
	CurrencyBRL = "7"
	CurrencyJPY = "8"
	CurrencyNOK = "9"
	CurrencyIDR = "10"
	CurrencyMYR = "11"
	CurrencyPHP = "12"
	CurrencySGD = "13"
	CurrencyTHB = "14"
	CurrencyVND = "15"
	CurrencyKRW = "16"
	CurrencyTRY = "17"
	CurrencyUAH = "18"
	CurrencyMXN = "19"
	CurrencyCAD = "20"
	CurrencyAUD = "21"
	CurrencyNZD = "22"
	CurrencyCNY = "23"
	CurrencyINR = "24"
	CurrencyCLP = "25"
	CurrencyPEN = "26"
	CurrencyCOP = "27"
	CurrencyZAR = "28"
	CurrencyHKD = "29"
	CurrencyTWD = "30"
	CurrencySAR = "31"
	CurrencyAED = "32"
	CurrencyARS = "34"
	CurrencyILS = "35"
	CurrencyBYN = "36"
	CurrencyKZT = "37"
	CurrencyKWD = "38"
	CurrencyQAR = "39"
	CurrencyCRC = "40"
	CurrencyUYU = "41"
	CurrencyRMB = "9000"
)
View Source
const (
	PrivacyStatePrivate     = 1
	PrivacyStateFriendsOnly = 2
	PrivacyStatePublic      = 3
)
View Source
const (
	CommentSettingSelf    = "commentselfonly"
	CommentSettingFriends = "commentfriendsonly"
	CommentSettingPublic  = "commentanyone"
)
View Source
const (
	UniverseInvalid = iota
	UniversePublic
	UniverseBeta
	UniverseInternal
	UniverseDev
)
View Source
const (
	AccountTypeInvalid = iota
	AccountTypeIndividual
	AccountTypeMultiSeat
	AccountTypeGameServer
	AccountTypeAnonymousGameServer
	AccountTypePending
	AccountTypeContentServer
	AccountTypeClan
	AccountTypeChat
	AccountTypeP2PSuperSeeder
	AccountTypeAnonymous
)
View Source
const (
	AccountInstanceAll = iota
	AccountInstanceDesktop
	AccountInstanceConsole
	AccountInstanceWeb
)
View Source
const (
	ChatInstanceFlagClan     = 0x80000
	ChatInstanceFlagLobby    = 0x40000
	ChatInstanceFlagMMSLobby = 0x20000
)
View Source
const (
	TradeConfirmationNone = iota
	TradeConfirmationEmail
	TradeConfirmationMobileApp
	TradeConfirmationMobile
)
View Source
const (
	TradeFilterNone             = iota
	TradeFilterSentOffers       = 1 << 0
	TradeFilterRecvOffers       = 1 << 1
	TradeFilterActiveOnly       = 1 << 3
	TradeFilterHistoricalOnly   = 1 << 4
	TradeFilterItemDescriptions = 1 << 5
)
View Source
const (
	CS2PropertyPaintSeed = 1
	CS2PropertyWearFloat = 2
)

CS2 asset property ids.

View Source
const (
	APIBaseUrl = "https://api.steampowered.com"
)
View Source
const (
	CommunityBaseURL = "https://steamcommunity.com"
)
View Source
const ConfirmationTypeTrade = 2

ConfirmationTypeTrade is the mobileconf "type" of trade offer confirmations.

View Source
const EconomyImageBaseURL = "https://community.fastly.steamstatic.com/economy/image/"

EconomyImageBaseURL is the Steam economy image CDN (icon_url hashes are appended to it).

View Source
const (
	InventoryEndpoint = "https://steamcommunity.com/inventory/%d/%d/%d?"
)

Variables

View Source
var (
	//ErrConfirmationsUnknownError = errors.New("unknown error occurred finding confirmation")
	ErrCannotFindConfirmations   = errors.New("unable to find confirmation")
	ErrCannotFindDescriptions    = errors.New("unable to find confirmation descriptions")
	ErrConfirmationsDescMismatch = errors.New("cannot match confirmation with their respective descriptions")
	ErrWGTokenExpired            = errors.New("WGToken expired")
)
View Source
var (
	// ErrInventoryPrivate: GET /inventory answered 403 with a "null" body (private profile or inventory).
	ErrInventoryPrivate = errors.New("steam: inventory is private")
	// ErrNotLoggedIn: the web session expired (HTTP 401, or a login page instead of JSON).
	ErrNotLoggedIn = errors.New("steam: not logged in")
	// ErrOfferNotFound: GetTradeOffer returned an empty response for the id.
	ErrOfferNotFound = errors.New("steam: trade offer not found")
	// ErrTradeNotFound: GetTradeStatus did not return the trade (yet).
	ErrTradeNotFound = errors.New("steam: trade not found")
	// ErrInvalidTradeURL: the string is not a https://steamcommunity.com/tradeoffer/new/?partner=..&token=.. link.
	ErrInvalidTradeURL = errors.New("steam: invalid trade offer URL")
	// ErrConfirmationNotFound: no pending mobile confirmation exists for the object (offer id).
	ErrConfirmationNotFound = errors.New("steam: confirmation not found")
)
View Source
var (
	ErrEmptySessionID  = errors.New("sessionid is empty")
	ErrInvalidUsername = errors.New("invalid username")
	ErrNeedTwoFactor   = errors.New("invalid twofactor code")
)
View Source
var (
	ErrInvalidSteam2ID = errors.New("invalid input specified for a Steam 2 ID")
	ErrInvalidSteam3ID = errors.New("invalid input specified for a Steam 3 ID")
)
View Source
var (
	ErrReceiptMatch        = errors.New("unable to match items in trade receipt")
	ErrCannotAcceptActive  = errors.New("unable to accept a non-active trade")
	ErrCannotFindOfferInfo = errors.New("unable to match data from trade offer url")
)
View Source
var (
	ErrCannotRegisterKey = errors.New("unable to register API key")
	ErrCannotRevokeKey   = errors.New("unable to revoke API key")
	ErrAccessDenied      = errors.New("access is denied")
	ErrKeyNotFound       = errors.New("key not found")
)
View Source
var DefaultRetryPolicy = RetryPolicy{Attempts: 3, BaseDelay: 2 * time.Second, MaxDelay: 30 * time.Second}

DefaultRetryPolicy is a conservative policy for Steam web endpoints.

View Source
var ErrCannotDisable = errors.New("unable to process disable two factor request")
View Source
var ErrCannotFindVanityMatch = errors.New("no match for the vanity URL")
View Source
var (
	ErrCannotLoadPrices = errors.New("unable to load prices at this time")
)
View Source
var ErrInvalidPhoneNumber = errors.New("invalid phone number specified")
View Source
var ErrNoPrice = errors.New("steam: no market price")

ErrNoPrice: the market has neither a lowest nor a median price for the item.

Functions

func BackoffDelay

func BackoffDelay(p RetryPolicy, attempt int) time.Duration

BackoffDelay is the jittered delay after the attempt-th failure (0-based): uniform in [d/2, d], d = BaseDelay * 2^attempt capped at MaxDelay.

func BuildOfferJSON

func BuildOfferJSON(give, receive []TradeItem) (string, error)

BuildOfferJSON returns the json_tradeoffer payload exactly as the Steam web client (and tradeoffer-manager) sends it.

func EconomyImageURL

func EconomyImageURL(iconHash, size string) string

EconomyImageURL builds a CDN URL for an icon hash; size like "256fx256f" or "" for the original.

func GenerateConfirmationCode

func GenerateConfirmationCode(identitySecret, tag string, current int64) (string, error)

func GenerateTwoFactorCode

func GenerateTwoFactorCode(sharedSecret string, current int64) (string, error)

func IsRateLimited

func IsRateLimited(err error) bool

IsRateLimited reports HTTP 429 / RateLimitExceeded errors.

func IsTemporary

func IsTemporary(err error) bool

IsTemporary reports errors worth retrying later (rate limits, 5xx, busy, network timeouts).

func ParseMarketPrice

func ParseMarketPrice(s string) (float64, error)

ParseMarketPrice parses Steam's formatted prices: "$1,234.56", "1 234,56₴", "12,34€", "1.234,56 pуб.", "₴1,234.56", "CDN$ 3.10", "1'234.50 CHF". The last '.' or ',' followed by 1–2 digits is the decimal mark; every other separator (',', '.', ' ', NBSP, '\”) is a thousands separator.

func Retry

func Retry(ctx context.Context, p RetryPolicy, fn func(ctx context.Context) error) error

Retry runs fn until it succeeds, returns a non-temporary error (see IsTemporary) or attempts run out. This package never retries on its own; callers opt in explicitly.

func RetryAfterOf

func RetryAfterOf(err error) time.Duration

RetryAfterOf returns the server-requested delay of a rate-limited error (0 when unknown).

Types

type APIResponse

type APIResponse struct {
	Inner *TradeOfferResponse `json:"response"`
}

type AssetProperty

type AssetProperty struct {
	PropertyID  int    `json:"propertyid"`
	IntValue    string `json:"int_value,omitempty"`
	FloatValue  string `json:"float_value,omitempty"`
	StringValue string `json:"string_value,omitempty"`
	Name        string `json:"name,omitempty"`
}

AssetProperty is one entry of the /inventory "asset_properties" block (CS2: 1 = paint seed, 2 = wear float, …).

type ChatFriendResponse

type ChatFriendResponse struct {
	AccountID   uint32  `json:"m_unAccountID"`
	SteamID     SteamID `json:"m_ulSteamID,string"`
	Name        string  `json:"m_strName"`
	State       uint8   `json:"m_ePersonaState"`
	StateFlags  uint32  `json:"m_nPersonaStateFlags"`
	AvatarHash  string  `json:"m_strAvatarHash"`
	InGame      bool    `json:"m_bIngame"`
	InGameAppID uint64  `json:"m_nInGameAppID,string"`
	InGameName  string  `json:"m_strInGameName"`
	LastMessage int64   `json:"m_tsLastMessage"`
	LastView    int64   `json:"m_tsLastView"`
}

type ChatLogMessage

type ChatLogMessage struct {
	Partner   uint32 `json:"m_unAccountID"`
	Timestamp int64  `json:"m_tsTimestamp"`
	Message   string `json:"m_strMessage"`
}

type ChatMessage

type ChatMessage struct {
	Type         string `json:"type"`
	Text         string `json:"text"`
	TimestampOff int64  `json:"timestamp"`
	UTCTimestamp int64  `json:"utc_timestamp"`
	Partner      uint32 `json:"accountid_from"`
	StatusFlags  uint32 `json:"status_flags"`
	PersonaState uint32 `json:"persona_state"`
	PersonaName  string `json:"persona_name"`
}

type ChatResponse

type ChatResponse struct {
	Message      int            `json:"message"`       // Login / Internal
	UmqID        string         `json:"umqid"`         // Login / Internal
	TimestampOff int64          `json:"timestamp"`     // Login
	UTCTimestamp int64          `json:"utc_timestamp"` // Login
	Push         int            `json:"push"`          // Login
	ErrorMessage string         `json:"error"`         // All (returned as error if not "OK")
	MessageBase  uint32         `json:"messagebase"`   // ChatPoll
	LastMessages uint32         `json:"messagelast"`   // ChatPoll
	Messages     []*ChatMessage `json:"messages"`      // ChatPoll
	SecTimeout   uint32         `json:"sectimeout"`    // ChatPoll
}

type Confirmation

type Confirmation struct {
	ID           string `json:"id"`
	Type         uint8  `json:"type"`
	Creator      string `json:"creator_id"`
	Nonce        string `json:"nonce"`
	CreationTime uint64 `json:"creation"`
	// Fields of the current mobileconf/getlist JSON.
	CreationTimeUnix uint64 `json:"creation_time"`
	TypeName         string `json:"type_name"`
	Headline         string `json:"headline"`
}

func (*Confirmation) Answer

func (confirmation *Confirmation) Answer(session *Session, key, answer string, current int64) error

type ConfirmationResponse

type ConfirmationResponse struct {
	Success       bool            `json:"success"`
	Confirmations []*Confirmation `json:"conf"`
}

type EResult

type EResult int

EResult is Steam's generic result code (x-eresult header, "strError ... (N)" suffixes, error bodies).

const (
	EResultInvalid                 EResult = 0
	EResultOK                      EResult = 1
	EResultFail                    EResult = 2
	EResultNoConnection            EResult = 3
	EResultInvalidPassword         EResult = 5
	EResultLoggedInElsewhere       EResult = 6
	EResultInvalidProtocolVer      EResult = 7
	EResultInvalidParam            EResult = 8
	EResultFileNotFound            EResult = 9
	EResultBusy                    EResult = 10
	EResultInvalidState            EResult = 11
	EResultInvalidName             EResult = 12
	EResultInvalidEmail            EResult = 13
	EResultDuplicateName           EResult = 14
	EResultAccessDenied            EResult = 15
	EResultTimeout                 EResult = 16
	EResultBanned                  EResult = 17
	EResultAccountNotFound         EResult = 18
	EResultInvalidSteamID          EResult = 19
	EResultServiceUnavailable      EResult = 20
	EResultNotLoggedOn             EResult = 21
	EResultPending                 EResult = 22
	EResultEncryptionFailure       EResult = 23
	EResultInsufficientPrivilege   EResult = 24
	EResultLimitExceeded           EResult = 25
	EResultRevoked                 EResult = 26
	EResultExpired                 EResult = 27
	EResultAlreadyRedeemed         EResult = 28
	EResultDuplicateRequest        EResult = 29
	EResultAlreadyOwned            EResult = 30
	EResultIPNotFound              EResult = 31
	EResultPersistFailed           EResult = 32
	EResultLockingFailed           EResult = 33
	EResultLogonSessionReplaced    EResult = 34
	EResultConnectFailed           EResult = 35
	EResultHandshakeFailed         EResult = 36
	EResultIOFailure               EResult = 37
	EResultRemoteDisconnect        EResult = 38
	EResultBlocked                 EResult = 40
	EResultIgnored                 EResult = 41
	EResultNoMatch                 EResult = 42
	EResultAccountDisabled         EResult = 43
	EResultServiceReadOnly         EResult = 44
	EResultTryAnotherCM            EResult = 48
	EResultCannotUseOldPassword    EResult = 51
	EResultInvalidLoginAuthCode    EResult = 65
	EResultAccountLogonDenied      EResult = 63
	EResultAccountLockedDown       EResult = 73
	EResultRateLimitExceeded       EResult = 84
	EResultTwoFactorCodeMismatch   EResult = 88
	EResultItemDeleted             EResult = 94
	EResultTooManyPending          EResult = 102
	EResultNoMobileDevice          EResult = 103
	EResultAccountLimitExceeded    EResult = 116
	EResultAccountActivityLimitExc EResult = 117
	EResultTimeNotSynced           EResult = 120
)

func (EResult) Retryable

func (r EResult) Retryable() bool

Retryable reports codes that usually go away on their own (busy / rate limited / backend hiccups).

func (EResult) String

func (r EResult) String() string

type ETradeStatus

type ETradeStatus int

ETradeStatus is the status of a completed exchange (GetTradeStatus / GetTradeHistory).

const (
	TradeStatusInit                     ETradeStatus = 0  // accepted/confirmed, no work done yet
	TradeStatusPreCommitted             ETradeStatus = 1  // about to commit
	TradeStatusCommitted                ETradeStatus = 2  // items exchanged
	TradeStatusComplete                 ETradeStatus = 3  // all work finished
	TradeStatusFailed                   ETradeStatus = 4  // failed and rolled back
	TradeStatusPartialSupportRollback   ETradeStatus = 5  // support rolled back one side
	TradeStatusFullSupportRollback      ETradeStatus = 6  // support rolled back both sides
	TradeStatusSupportRollbackSelective ETradeStatus = 7  // support rolled back some items
	TradeStatusRollbackFailed           ETradeStatus = 8  // rollback in progress / incomplete
	TradeStatusRollbackAbandoned        ETradeStatus = 9  // rollback gave up
	TradeStatusInEscrow                 ETradeStatus = 10 // on hold
	TradeStatusEscrowRollback           ETradeStatus = 11 // on-hold trade rolled back
)

func (ETradeStatus) IsCompleted

func (s ETradeStatus) IsCompleted() bool

IsCompleted: the items were exchanged and nothing has been reverted.

func (ETradeStatus) IsPending

func (s ETradeStatus) IsPending() bool

IsPending: the exchange is still in flight (Init / PreCommitted / Committed / InEscrow).

func (ETradeStatus) IsRolledBack

func (s ETradeStatus) IsRolledBack() bool

IsRolledBack: the exchange failed or was (partly) reverted — including any status newer than this table (Valve adds reversal states over time, e.g. for CS2 trade protection). Treat as "not received".

func (ETradeStatus) String

func (s ETradeStatus) String() string

type EconAction

type EconAction struct {
	Link string `json:"link"`
	Name string `json:"name"`
}

type EconDesc

type EconDesc struct {
	Type  string `json:"type"`
	Value string `json:"value"`
	Name  string `json:"name,omitempty"`
	Color string `json:"color,omitempty"`
}

type EconItem

type EconItem struct {
	AssetID    uint64 `json:"assetid,string,omitempty"`
	InstanceID uint64 `json:"instanceid,string,omitempty"`
	ClassID    uint64 `json:"classid,string,omitempty"`
	AppID      uint32 `json:"appid"`
	ContextID  uint64 `json:"contextid,string"`
	Amount     uint32 `json:"amount,string"`
	Missing    bool   `json:"missing,omitempty"`
	EstUSD     uint32 `json:"est_usd,string"`
}

type EconItemDesc

type EconItemDesc struct {
	AppID                       uint32        `json:"appid,omitempty"`
	ClassID                     uint64        `json:"classid,string"`    // for matching with EconItem
	InstanceID                  uint64        `json:"instanceid,string"` // for matching with EconItem
	Currency                    bool          `json:"currency,omitempty"`
	Tradable                    bool          `json:"tradable"`
	BackgroundColor             string        `json:"background_color"`
	IconURL                     string        `json:"icon_url"`
	IconLargeURL                string        `json:"icon_url_large"`
	IconDragURL                 string        `json:"icon_drag_url,omitempty"`
	Name                        string        `json:"name"`
	NameColor                   string        `json:"name_color"`
	Type                        string        `json:"type,omitempty"`
	MarketName                  string        `json:"market_name"`
	MarketHashName              string        `json:"market_hash_name"`
	MarketFeeApp                uint32        `json:"market_fee_app,omitempty"`
	Commodity                   bool          `json:"commodity"`
	MarketTradableRestriction   int           `json:"market_tradable_restriction,omitempty"`
	MarketMarketableRestriction int           `json:"market_marketable_restriction,omitempty"`
	Marketable                  bool          `json:"marketable,omitempty"`
	Actions                     []*EconAction `json:"actions,omitempty"`
	Tags                        []*EconTag    `json:"tags"`
	Descriptions                []*EconDesc   `json:"descriptions"`
	Sealed                      bool          `json:"sealed,omitempty"`
	MarketBucketGroupName       string        `json:"market_bucket_group_name,omitempty"`
	MarketBucketGroupID         string        `json:"market_bucket_group_id,omitempty"`
	SealedType                  int           `json:"sealed_type,omitempty"`
	OwnerDescriptions           []*EconDesc   `json:"owner_descriptions,omitempty"` // only for the owner's own session
	MarketActions               []*EconAction `json:"market_actions,omitempty"`
	FraudWarnings               []string      `json:"fraudwarnings,omitempty"`
	CacheExpiration             string        `json:"cache_expiration,omitempty"` // RFC 3339; set on trade-locked items (lock end)
}

func (*EconItemDesc) Tag

func (d *EconItemDesc) Tag(category string) *EconTag

Tag returns the first tag of the category (e.g. "Type", "Rarity", "Exterior", "Quality", "Weapon"), or nil.

func (*EconItemDesc) UnmarshalJSON

func (d *EconItemDesc) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts both the IEconService (booleans) and the /inventory (0/1 ints) description shapes.

type EconTag

type EconTag struct {
	Category              string `json:"category"`
	InternalName          string `json:"internal_name"`
	LocalizedCategoryName string `json:"localized_category_name"`
	LocalizedTagName      string `json:"localized_tag_name"`
	Color                 string `json:"color,omitempty"`
}

EconTag is a Steam economy item tag (category / wear / etc.).

type EscrowSteamGuardInfo

type EscrowSteamGuardInfo struct {
	MyDays   int64
	ThemDays int64
	ErrorMsg string
}

type Filter

type Filter func(*InventoryItem) bool

Filter get InventoryItem and return true if item meet its condition false otherwise

func IsSouvenir

func IsSouvenir(cond bool) Filter

IsSouvenir filters souvenir items

func IsTradable

func IsTradable(cond bool) Filter

IsTradable return Filter for item.Tradable option

type FinalizeTwoFactorInfo

type FinalizeTwoFactorInfo struct {
	Status     uint32 `json:"status"`
	ServerTime uint64 `json:"server_time,string"`
}

type Friend

type Friend struct {
	SteamID      uint64 `json:"steamid,string"`
	Relationship string `json:"relationship"`
	FriendSince  int64  `json:"friend_since"`
}

type Game

type Game struct {
	AppID           uint32 `json:"appid"`
	PlaytimeForever int64  `json:"playtime_forever"`
	Playtime2Weeks  int64  `json:"playtime_2weeks"`
}

type GetOffersOptions

type GetOffersOptions struct {
	Sent, Received   bool
	ActiveOnly       bool
	HistoricalOnly   bool
	Descriptions     bool
	HistoricalCutoff time.Time // with ActiveOnly: also return offers updated after this time
	Language         string
}

GetOffersOptions selects what GetOffers returns.

type InventoryAppStats

type InventoryAppStats struct {
	AppID            uint64                       `json:"appid"`
	Name             string                       `json:"name"`
	AssetCount       uint32                       `json:"asset_count"`
	Icon             string                       `json:"icon"`
	Link             string                       `json:"link"`
	TradePermissions string                       `json:"trade_permissions"`
	Contexts         map[string]*InventoryContext `json:"rgContexts"`
}

type InventoryContext

type InventoryContext struct {
	ID         uint64 `json:"id,string"` /* Apparently context id needs at least 64 bits...  */
	AssetCount uint32 `json:"asset_count"`
	Name       string `json:"name"`
}

type InventoryItem

type InventoryItem struct {
	AppID      uint32        `json:"appid"`
	ContextID  uint64        `json:"contextid"`
	AssetID    uint64        `json:"id,string,omitempty"`
	ClassID    uint64        `json:"classid,string,omitempty"`
	InstanceID uint64        `json:"instanceid,string,omitempty"`
	Amount     uint64        `json:"amount,string"`
	Desc       *EconItemDesc `json:"-"` /* May be nil  */
}

Due to the JSON being string, etc... we cannot re-use EconItem Also, "assetid" is included as "id" not as assetid.

type InventoryOptions

type InventoryOptions struct {
	Language     string // "english" by default (item names / tags are localized by Steam)
	PageSize     int    // items per request, default 1000 (Steam's own clients use 1000–2000)
	TradableOnly bool   // drop items whose description says tradable=0
	MaxPages     int    // safety cap on pagination, default 25
}

InventoryOptions tunes GetUserInventoryContents. The zero value is valid.

type ItemPrice

type ItemPrice struct {
	Success     bool   `json:"success"`
	LowestPrice string `json:"lowest_price"`
	Volume      string `json:"volume"`
	MedianPrice string `json:"median_price"`
}

type ItemTag

type ItemTag struct {
	Category              string `json:"category"`
	InternalName          string `json:"internal_name"`
	LocalizedCategoryName string `json:"localized_category_name"`
	LocalizedTagName      string `json:"localized_tag_name"`
}

type LoginFinalized

type LoginFinalized struct {
	SteamID      SteamID        `json:"steamID,string"`
	TransferInfo []TransferInfo `json:"transfer_info"`
}

type MarketBuyOrderResponse

type MarketBuyOrderResponse struct {
	ErrCode int    `json:"success"`
	ErrMsg  string `json:"message"` // Set if ErrCode != 1
	OrderID uint64 `json:"buy_orderid,string"`
}

type MarketItemPrice

type MarketItemPrice struct {
	Date  string
	Price float64
	Count string
}

type MarketItemPriceOverview

type MarketItemPriceOverview struct {
	Success     bool   `json:"success"`
	LowestPrice string `json:"lowest_price"`
	MedianPrice string `json:"median_price"`
	Volume      string `json:"volume"`
}

type MarketItemResponse

type MarketItemResponse struct {
	Success     bool        `json:"success"`
	PricePrefix string      `json:"price_prefix"`
	PriceSuffix string      `json:"price_suffix"`
	Prices      interface{} `json:"prices"`
}

type MarketSellResponse

type MarketSellResponse struct {
	Success                    bool   `json:"success"`
	RequiresConfirmation       uint32 `json:"requires_confirmation"`
	MobileConfirmationRequired bool   `json:"needs_mobile_confirmation"`
	EmailConfirmationRequired  bool   `json:"needs_email_confirmation"`
	EmailDomain                string `json:"email_domain"`
}

type OAuth

type OAuth struct {
	SteamID       SteamID `json:"steamid,string"`
	Token         string  `json:"oauth_token"`
	WGToken       string  `json:"wgtoken"`
	WGTokenSecure string  `json:"wgtoken_secure"`
	WebCookie     string  `json:"webcookie"`
}

type OfferRequest

type OfferRequest struct {
	Partner        SteamID
	Token          string // partner's trade URL token (required unless you are friends)
	Message        string // shown to the partner (max ~128 chars are displayed)
	ItemsToGive    []TradeItem
	ItemsToReceive []TradeItem
}

OfferRequest describes an offer to send.

type OwnedGamesResponse

type OwnedGamesResponse struct {
	Count uint32  `json:"game_count"`
	Games []*Game `json:"games"`
}

type PartnerDetails

type PartnerDetails struct {
	MyEscrowDays    int
	TheirEscrowDays int
	Probation       bool
}

PartnerDetails is what the "new trade offer" page reveals about a partner (tradeoffer-manager getUserDetails).

type PhoneAPIResponse

type PhoneAPIResponse struct {
	Success   bool   `json:"success"`
	State     string `json:"state"`
	ErrorText string `json:"errorText"`
}

type PlayerBan

type PlayerBan struct {
	SteamID          uint64 `json:"SteamId,string"`
	CommunityBanned  bool   `json:"CommunityBanned"`
	VACBanned        bool   `json:"VACBanned"`
	NumberOfVACBans  int    `json:"NumberOfVACBans"`
	DaysSinceLastBan int    `json:"DaysSinceLastBan"`
	NumberOfGameBans int    `json:"NumberOfGameBans"`
	EconomyBan       string `json:"EconomyBan"`
}

type PlayerSummary

type PlayerSummary struct {
	SteamID           SteamID `json:"steamid,string"`
	VisibilityState   uint32  `json:"communityvisibilitystate"`
	ProfileState      uint32  `json:"profilestate"`
	PersonaName       string  `json:"personaname"`
	PersonaState      uint32  `json:"personastate"`
	PersonaStateFlags uint32  `json:"personastateflags"`
	RealName          string  `json:"realname"`
	LastLogoff        int64   `json:"lastlogoff"`
	ProfileURL        string  `json:"profileurl"`
	AvatarURL         string  `json:"avatar"`
	AvatarMediumURL   string  `json:"avatarmedium"`
	AvatarFullURL     string  `json:"avatarfull"`
	PrimaryClanID     uint64  `json:"primaryclanid,string"`
	TimeCreated       int64   `json:"timecreated"`
	LocCountryCode    string  `json:"loccountrycode"`
	LocStateCode      string  `json:"locstatecode"`
	LocCityID         uint32  `json:"loccityid"`
	GameID            uint64  `json:"gameid,string"`
	GameServerIP      string  `json:"gameserverip"`
	GameExtraInfo     string  `json:"gameextrainfo"`
}

type PriceOverview

type PriceOverview struct {
	Lowest float64 // lowest listing, 0 when absent
	Median float64 // median sale price, 0 when absent
	Volume int     // sold in the last 24h (0 when absent)
	Raw    ItemPrice
}

PriceOverview is /market/priceoverview parsed.

func (*PriceOverview) Best

func (p *PriceOverview) Best() float64

Best returns the lowest listing price, falling back to the median sale price.

type RetryPolicy

type RetryPolicy struct {
	Attempts  int           // total attempts (>= 1)
	BaseDelay time.Duration // delay before the 2nd attempt (doubles each time)
	MaxDelay  time.Duration // cap for a single wait (also caps Retry-After)
}

RetryPolicy configures Retry: exponential backoff with full jitter, honouring Retry-After.

type SentOffer

type SentOffer struct {
	ID                      uint64
	NeedsMobileConfirmation bool
	NeedsEmailConfirmation  bool
	EmailDomain             string
	State                   TradeOfferState // Active, or CreatedNeedsConfirmation
}

SentOffer is the result of SendOffer.

type ServerTimeTip

type ServerTimeTip struct {
	Time                              int64  `json:"server_time,string"`
	SkewToleranceSeconds              uint32 `json:"skew_tolerance_seconds,string"`
	LargeTimeJink                     uint32 `json:"large_time_jink,string"`
	ProbeFrequencySeconds             uint32 `json:"probe_frequency_seconds"`
	AdjustedTimeProbeFrequencySeconds uint32 `json:"adjusted_time_probe_frequency_seconds"`
	HintProbeFrequencySeconds         uint32 `json:"hint_probe_frequency_seconds"`
	SyncTimeout                       uint32 `json:"sync_timeout"`
	TryAgainSeconds                   uint32 `json:"try_again_seconds"`
	MaxAttempts                       uint32 `json:"max_attempts"`
}

func GetTimeTip

func GetTimeTip() (*ServerTimeTip, error)

type Session

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

func NewSession

func NewSession(client *http.Client, apiKey string) *Session

func NewSessionWithAPIKey

func NewSessionWithAPIKey(apiKey string) *Session

func (*Session) AcceptConfirmationForObject

func (session *Session) AcceptConfirmationForObject(identitySecret string, objectID uint64, current int64) error

AcceptConfirmationForObject finds the pending mobile confirmation created for objectID (a trade offer id) and accepts it, like steamcommunity's acceptConfirmationForObject. current is the Steam-aligned unix time. Returns ErrConfirmationNotFound when no such confirmation is pending.

func (*Session) AcceptTradeOffer

func (session *Session) AcceptTradeOffer(id uint64) error

func (*Session) AddPhoneNumber

func (session *Session) AddPhoneNumber(number string) error

func (*Session) AnswerConfirmation

func (session *Session) AnswerConfirmation(confirmation *Confirmation, identitySecret, answer string, current int64) error

func (*Session) Auth

func (session *Session) Auth(realm, return_to string) (*http.Response, error)

func (*Session) CancelBuyOrder

func (session *Session) CancelBuyOrder(orderid uint64) error

func (*Session) CancelOffer

func (session *Session) CancelOffer(ctx context.Context, id uint64) error

CancelOffer cancels an offer we sent (POST /tradeoffer/{id}/cancel).

func (*Session) CancelTradeOffer

func (session *Session) CancelTradeOffer(id uint64) error

func (*Session) ChatFriendState

func (session *Session) ChatFriendState(sid SteamID) (*ChatFriendResponse, error)

func (*Session) ChatLog

func (session *Session) ChatLog(partner uint32) ([]*ChatLogMessage, error)

func (*Session) ChatLogin

func (session *Session) ChatLogin(uiMode string) error

func (*Session) ChatLogoff

func (session *Session) ChatLogoff() error

func (*Session) ChatPoll

func (session *Session) ChatPoll(timeoutSeconds string) (*ChatResponse, error)

func (*Session) ChatSendMessage

func (session *Session) ChatSendMessage(sid SteamID, message, messageType string) error

func (*Session) ConfirmRemovePhoneNumber

func (session *Session) ConfirmRemovePhoneNumber(mobileCode string) error

func (*Session) DeclineOffer

func (session *Session) DeclineOffer(ctx context.Context, id uint64) error

DeclineOffer declines an offer we received (POST /tradeoffer/{id}/decline).

func (*Session) DeclineTradeOffer

func (session *Session) DeclineTradeOffer(id uint64) error

func (*Session) DisableTwoFactor

func (session *Session) DisableTwoFactor(revocationCode string) error

func (*Session) EnableTwoFactor

func (session *Session) EnableTwoFactor() (*TwoFactorInfo, error)

func (*Session) FinalizeTwoFactor

func (session *Session) FinalizeTwoFactor(authCode, mobileCode string) (*FinalizeTwoFactorInfo, error)

func (*Session) GetAccessToken

func (session *Session) GetAccessToken() string

func (*Session) GetClient

func (session *Session) GetClient() *http.Client

func (*Session) GetConfirmations

func (session *Session) GetConfirmations(identitySecret string, current int64) ([]*Confirmation, error)

func (*Session) GetCookies

func (session *Session) GetCookies() http.CookieJar

func (*Session) GetEscrow

func (session *Session) GetEscrow(url string) (*EscrowSteamGuardInfo, error)

func (*Session) GetEscrowGuardInfo

func (session *Session) GetEscrowGuardInfo(sid SteamID, token string) (*EscrowSteamGuardInfo, error)

func (*Session) GetEscrowGuardInfoForTrade

func (session *Session) GetEscrowGuardInfoForTrade(offerID uint64) (*EscrowSteamGuardInfo, error)

func (*Session) GetFilterableInventory

func (session *Session) GetFilterableInventory(sid SteamID, appID, contextID uint64, filters []Filter) ([]InventoryItem, error)

func (*Session) GetFriends

func (session *Session) GetFriends(sid SteamID) ([]*Friend, error)

func (*Session) GetInventory

func (session *Session) GetInventory(sid SteamID, appID, contextID uint64, tradableOnly bool) ([]InventoryItem, error)

func (*Session) GetInventoryAppStats

func (session *Session) GetInventoryAppStats(sid SteamID) (map[string]InventoryAppStats, error)

func (*Session) GetMarketItemPriceHistory

func (session *Session) GetMarketItemPriceHistory(appID uint64, marketHashName string) ([]*MarketItemPrice, error)

func (*Session) GetMarketItemPriceOverview

func (session *Session) GetMarketItemPriceOverview(appID uint64, country, currencyID, marketHashName string) (*MarketItemPriceOverview, error)

func (*Session) GetMarketPrice

func (session *Session) GetMarketPrice(marketName string) (dataPrice *ItemPrice, err error)

func (*Session) GetMyTradeToken

func (session *Session) GetMyTradeToken() (string, error)

func (*Session) GetOffer

func (session *Session) GetOffer(ctx context.Context, id uint64) (*TradeOffer, []*EconItemDesc, error)

GetOffer loads one offer by id (IEconService/GetTradeOffer). Returns ErrOfferNotFound for unknown ids. Unlike the legacy GetTradeOffer it checks HTTP status / x-eresult and never dereferences a missing body.

func (*Session) GetOffers

func (session *Session) GetOffers(ctx context.Context, o GetOffersOptions) (*TradeOfferResponse, error)

GetOffers lists offers (IEconService/GetTradeOffers), following the cursor.

func (*Session) GetOwnedGames

func (session *Session) GetOwnedGames(sid SteamID, freeGames bool, appInfo bool) (*OwnedGamesResponse, error)

func (*Session) GetPartnerDetails

func (session *Session) GetPartnerDetails(ctx context.Context, t *TradeURL) (*PartnerDetails, error)

GetPartnerDetails opens https://steamcommunity.com/tradeoffer/new/?partner=..&token=.. with the session. Steam renders an error page for invalid tokens, trade-banned or otherwise unavailable partners: that is returned as a *SteamError with Cause CauseInvalidTradeURL / CauseTargetCannotTrade / CauseTradeBan.

func (*Session) GetPlayerBans

func (session *Session) GetPlayerBans(steamids string) ([]*PlayerBan, error)

func (*Session) GetPlayerSummaries

func (session *Session) GetPlayerSummaries(steamids string) ([]*PlayerSummary, error)

func (*Session) GetPriceOverview

func (session *Session) GetPriceOverview(ctx context.Context, appID uint64, currency int, marketHashName string) (*PriceOverview, error)

GetPriceOverview fetches https://steamcommunity.com/market/priceoverview/ for one market_hash_name in the given currency (1 = USD, 18 = UAH, see Currency* constants). Steam rate-limits this endpoint hard (~20 req/min per IP): HTTP 429 comes back as a *SteamError (IsRateLimited). ErrNoPrice when unpriced.

func (*Session) GetProfileURL

func (session *Session) GetProfileURL() (string, error)

func (*Session) GetRequiredSteamAppVersion

func (session *Session) GetRequiredSteamAppVersion(appID int) (int, error)

func (*Session) GetSessionID

func (session *Session) GetSessionID() string

func (*Session) GetSteamID

func (session *Session) GetSteamID() SteamID

func (*Session) GetTradeHoldDurations

func (session *Session) GetTradeHoldDurations(ctx context.Context, sid SteamID, token string) (*TradeHoldDurations, error)

GetTradeHoldDurations asks Steam for the trade hold with a partner (token = their trade URL token).

func (*Session) GetTradeOffer

func (session *Session) GetTradeOffer(id uint64) (*TradeOffer, error)

func (*Session) GetTradeOffers

func (session *Session) GetTradeOffers() (*TradeOfferResponse, error)

func (*Session) GetTradeReceivedItems

func (session *Session) GetTradeReceivedItems(receiptID uint64) ([]*InventoryItem, error)

func (*Session) GetTradeStatus

func (session *Session) GetTradeStatus(ctx context.Context, tradeID uint64) (*TradeStatus, error)

GetTradeStatus loads the exchange details of an accepted offer (TradeOffer.ReceiptID = "tradeid"), like tradeoffer-manager's getExchangeDetails. Use it to detect rollbacks before crediting anything. Returns ErrTradeNotFound when Steam does not know the trade (yet).

func (*Session) GetUserInventoryContents

func (session *Session) GetUserInventoryContents(ctx context.Context, sid SteamID, appID, contextID uint64, opts *InventoryOptions) (*UserInventory, error)

GetUserInventoryContents loads another user's (or our own) inventory through the modern https://steamcommunity.com/inventory/{steamid64}/{appid}/{contextid} endpoint, following pagination and merging descriptions and asset_properties — the equivalent of steamcommunity's getUserInventoryContents.

Errors: ErrInventoryPrivate (403 "null"), a *SteamError with HTTPStatus 429 when rate limited (see IsRateLimited / RetryAfterOf), or a *SteamError with the EResult parsed from Steam's error body.

func (*Session) GetWebAPIKey

func (session *Session) GetWebAPIKey() (string, error)

func (*Session) InitiateRemovePhoneNumber

func (session *Session) InitiateRemovePhoneNumber() error

func (*Session) Login

func (session *Session) Login(accountName, password, sharedSecret string, timeOffset time.Duration) error

func (*Session) PlaceBuyOrder

func (session *Session) PlaceBuyOrder(appid uint64, priceTotal float64, quantity uint64, currencyID, marketHashName string) (*MarketBuyOrderResponse, error)

func (*Session) PrepareForSteamStore

func (session *Session) PrepareForSteamStore()

func (*Session) ReSendVerificationCode

func (session *Session) ReSendVerificationCode() error

func (*Session) Refresh

func (session *Session) Refresh() error

func (*Session) RegisterWebAPIKey

func (session *Session) RegisterWebAPIKey(domain string) (string, error)

func (*Session) ResolveVanityURL

func (session *Session) ResolveVanityURL(vanityURL string) (uint64, error)

func (*Session) RevokeWebAPIKey

func (session *Session) RevokeWebAPIKey() error

func (*Session) SellItem

func (session *Session) SellItem(item *InventoryItem, amount, price uint64) (*MarketSellResponse, error)

func (*Session) SendOffer

func (session *Session) SendOffer(ctx context.Context, r OfferRequest) (*SentOffer, error)

SendOffer creates a trade offer. An offer where we only RECEIVE items does not need a mobile confirmation; when Steam asks for one anyway the result says so (NeedsMobileConfirmation) and the offer stays in CreatedNeedsConfirmation until AcceptConfirmationForObject(offer id) is called.

func (*Session) SendTradeOffer

func (session *Session) SendTradeOffer(offer *TradeOffer, sid SteamID, token string) error

func (*Session) SetLanguage

func (session *Session) SetLanguage(lang string)

func (*Session) SetProfileInfo

func (session *Session) SetProfileInfo(profileURL string, values *map[string][]string) error

func (*Session) SetProfilePrivacy

func (session *Session) SetProfilePrivacy(profileURL string, commentPrivacy string, privacy uint8) error

func (*Session) SetupProfile

func (session *Session) SetupProfile(profileURL string) error

func (*Session) ValidatePhoneNumber

func (session *Session) ValidatePhoneNumber(number string) error

func (*Session) VerifyPhoneNumber

func (session *Session) VerifyPhoneNumber(code string) error

type SteamError

type SteamError struct {
	Op         string        // e.g. "SendOffer", "GetTradeStatus"
	HTTPStatus int           // 0 when the transport failed or the status was 200
	EResult    EResult       // 0 when unknown
	Message    string        // Steam's message (strError / error / body excerpt)
	Cause      string        // one of the Cause* constants, "" when unknown
	RetryAfter time.Duration // from a Retry-After header (429), 0 when absent
}

SteamError is the structured error returned by the context-aware helpers of this package. Use errors.As to inspect it, or the IsXxx helpers below.

func (*SteamError) Error

func (e *SteamError) Error() string

func (*SteamError) Is

func (e *SteamError) Is(target error) bool

func (*SteamError) Temporary

func (e *SteamError) Temporary() bool

Temporary reports whether retrying later may succeed.

type SteamID

type SteamID uint64

* Full Steam 64-bit ID * Upper 32 bits Lower 32 bits * Upper 16 bits Lower 16 bits * Universe Type Acc Instance Account ID * |||| |||| xxxx |||| xxxx xx|| |||| |||| |||| |||| |||| |||| |||| |||| |||| ||||

func (*SteamID) GetAccountID

func (sid *SteamID) GetAccountID() uint32

func (*SteamID) GetAccountInstance

func (sid *SteamID) GetAccountInstance() uint32

func (*SteamID) GetAccountType

func (sid *SteamID) GetAccountType() uint32

func (*SteamID) GetAccountUniverse

func (sid *SteamID) GetAccountUniverse() uint32

func (*SteamID) Parse

func (sid *SteamID) Parse(accid uint32, instance uint32, accountType uint32, universe uint8)

func (*SteamID) ParseDefaults

func (sid *SteamID) ParseDefaults(accid uint32)

func (*SteamID) ParseSteam2ID

func (sid *SteamID) ParseSteam2ID(input string) error

func (*SteamID) ParseSteam3ID

func (sid *SteamID) ParseSteam3ID(input string) error

func (*SteamID) ToSteam2ID

func (sid *SteamID) ToSteam2ID() string

func (*SteamID) ToSteam3ID

func (sid *SteamID) ToSteam3ID() string

func (*SteamID) ToString

func (sid *SteamID) ToString() string

type TradeAsset

type TradeAsset struct {
	AppID        uint32 `json:"appid"`
	ContextID    uint64 `json:"contextid,string"`
	AssetID      uint64 `json:"assetid,string"`
	Amount       uint64 `json:"amount,string"`
	ClassID      uint64 `json:"classid,string"`
	InstanceID   uint64 `json:"instanceid,string"`
	NewAssetID   uint64 `json:"new_assetid,string"`
	NewContextID uint64 `json:"new_contextid,string"`
}

TradeAsset is an item of a GetTradeStatus exchange. NewAssetID is the id the item got in the receiver's inventory.

type TradeHoldDurations

type TradeHoldDurations struct {
	MyEscrow    time.Duration
	TheirEscrow time.Duration
	BothEscrow  time.Duration
}

TradeHoldDurations is IEconService/GetTradeHoldDurations: how long a trade between us and the target would be held (0 = instant). Their > 0 usually means no Steam Guard Mobile Authenticator (or < 7 days).

type TradeItem

type TradeItem struct {
	AppID     uint32
	ContextID uint64
	AssetID   uint64
	Amount    uint64 // 0 = 1
}

TradeItem identifies an asset in an offer.

type TradeOffer

type TradeOffer struct {
	ID                 uint64      `json:"tradeofferid,string"`
	Partner            uint32      `json:"accountid_other"`
	ReceiptID          uint64      `json:"tradeid,string"`
	RecvItems          []*EconItem `json:"items_to_receive"`
	SendItems          []*EconItem `json:"items_to_give"`
	Message            string      `json:"message"`
	State              uint8       `json:"trade_offer_state"`
	ConfirmationMethod uint8       `json:"confirmation_method"`
	Created            int64       `json:"time_created"`
	Updated            int64       `json:"time_updated"`
	Expires            int64       `json:"expiration_time"`
	EscrowEndDate      int64       `json:"escrow_end_date"`
	RealTime           bool        `json:"from_real_time_trade"`
	IsOurOffer         bool        `json:"is_our_offer"`
	EResult            int         `json:"eresult,omitempty"`
	DelaySettlement    bool        `json:"delay_settlement,omitempty"`
	SettlementDate     int64       `json:"settlement_date,omitempty"`
}

func (*TradeOffer) Accept

func (offer *TradeOffer) Accept(session *Session) error

func (*TradeOffer) Cancel

func (offer *TradeOffer) Cancel(session *Session) error

func (*TradeOffer) OfferState

func (offer *TradeOffer) OfferState() TradeOfferState

OfferState returns the typed state of the offer.

func (*TradeOffer) Send

func (offer *TradeOffer) Send(session *Session, sid SteamID, token string) error

type TradeOfferResponse

type TradeOfferResponse struct {
	Offer          *TradeOffer     `json:"offer"`                 // GetTradeOffer
	SentOffers     []*TradeOffer   `json:"trade_offers_sent"`     // GetTradeOffers
	ReceivedOffers []*TradeOffer   `json:"trade_offers_received"` // GetTradeOffers
	Descriptions   []*EconItemDesc `json:"descriptions"`          // GetTradeOffers
	NextCursor     int             `json:"next_cursor,omitempty"`
}

type TradeOfferState

type TradeOfferState int
const (
	Invalid                  TradeOfferState = iota + 1
	Active                                   // This trade offer has been sent, neither party has acted on it yet.
	Accepted                                 // The trade offer was accepted by the recipient and items were exchanged.
	Countered                                // The recipient made a counter offer.
	Expired                                  // The trade offer was not accepted before the expiration date.
	Canceled                                 // The sender cancelled the offer.
	Declined                                 // The recipient declined the offer.
	InvalidItems                             // Some of the items in the offer are no longer available.
	CreatedNeedsConfirmation                 // The offer hasn't been sent yet and is awaiting further confirmation.
	CanceledBySecondFactor                   // Either party canceled the offer via email/mobile confirmation.
	InEscrow                                 // The trade has been placed on hold.
)

func (TradeOfferState) IsFinal

func (s TradeOfferState) IsFinal() bool

IsFinal reports states that will never change again.

func (TradeOfferState) IsOpen

func (s TradeOfferState) IsOpen() bool

IsOpen reports states in which the offer can still change (Active, CreatedNeedsConfirmation, InEscrow).

func (TradeOfferState) String

func (s TradeOfferState) String() string

type TradeStatus

type TradeStatus struct {
	TradeID        uint64        `json:"tradeid,string"`
	SteamIDOther   SteamID       `json:"steamid_other,string"`
	TimeInit       int64         `json:"time_init"`
	TimeEscrowEnd  int64         `json:"time_escrow_end"`
	Status         ETradeStatus  `json:"status"`
	AssetsReceived []*TradeAsset `json:"assets_received"`
	AssetsGiven    []*TradeAsset `json:"assets_given"`
}

TradeStatus is one exchange returned by GetTradeStatus.

type TradeURL

type TradeURL struct {
	AccountID uint32
	Token     string
}

TradeURL is a parsed "Trade offer URL" (https://steamcommunity.com/tradeoffer/new/?partner=N&token=T).

func ParseTradeURL

func ParseTradeURL(raw string) (*TradeURL, error)

ParseTradeURL validates and parses a trade offer URL. Only steamcommunity.com (http/https, optional www) with a numeric partner (32-bit account id) and a token of 6–16 [A-Za-z0-9_-] chars is accepted.

func (*TradeURL) SteamID

func (t *TradeURL) SteamID() SteamID

SteamID returns the partner's SteamID64 (individual, public universe).

func (*TradeURL) String

func (t *TradeURL) String() string

String renders the canonical URL.

type TransferInfo

type TransferInfo struct {
	URL    string        `json:"url"`
	Params TransferParam `json:"params"`
}

type TransferParam

type TransferParam struct {
	Nonce string `json:"nonce"`
	Auth  string `json:"auth"`
}

type TwoFactorInfo

type TwoFactorInfo struct {
	Status         uint32 `json:"status"`
	SharedSecret   string `json:"shared_secret"`
	IdentitySecret string `json:"identity_secret"`
	Secret1        string `json:"secret_1"`
	SerialNumber   uint64 `json:"serial_number,string"`
	RevocationCode string `json:"revocation_code"`
	URI            string `json:"uri"`
	ServerTime     uint64 `json:"server_time,string"`
	TokenGID       string `json:"token_gid"`
}

type UserInventory

type UserInventory struct {
	Items      []*UserInventoryItem
	Currencies []*UserInventoryItem
	TotalCount int // total_inventory_count reported by Steam (includes items hidden from this viewer)
}

UserInventory is the full content of one app/context of a user's inventory.

type UserInventoryItem

type UserInventoryItem struct {
	AppID      uint32
	ContextID  uint64
	AssetID    uint64
	ClassID    uint64
	InstanceID uint64
	Amount     uint64
	CurrencyID uint64
	Desc       *EconItemDesc
	Properties []AssetProperty
}

UserInventoryItem is an asset merged with its description (Desc may be nil if Steam omitted it).

func (*UserInventoryItem) Float

func (it *UserInventoryItem) Float() (float64, bool)

Float returns the CS2 wear float when Steam included it.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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