Documentation ¶
Overview ¶
Package steamid provides conversion to and from all steam ID formats.
If you wish to resolve vanity names like https://steamcommunity.com/id/SQUIRRELLY into steam id, or to GetPlayerSummaries requests against the WebAPI you must first obtain an API key at https://steamcommunity.com/dev/apikey.
You can then set it for the package to use:
steamid.SetKey(apiKey) With a steam api key set you can now use the following functions: steamid.ResolveVanity()
Index ¶
- Constants
- Variables
- func KeyConfigured() bool
- func SetKey(key string) error
- type AppID
- type Collection
- type GID
- type SID
- type SID3
- type SID32
- type SID64
- func New(value any) SID64
- func ParseString(body string) []SID64
- func RandSID64() SID64
- func ResolveSID64(ctx context.Context, query string) (SID64, error)
- func ResolveVanity(ctx context.Context, query string) (SID64, error)
- func SID32ToSID64(steam32 SID32) SID64
- func SID3ToSID64(steam3 SID3) SID64
- func SID64FromString(steamID string) (SID64, error)
- func SIDToSID64(steamID SID) SID64
- func StringToSID64(s string) (SID64, error)
Constants ¶
const ( BaseSID = uint64(76561197960265728) BaseGID = uint64(103582791429521408) )
Variables ¶
var ( // BuildVersion is replaced at compile time with the current tag or revision. BuildVersion = "master" //nolint:gochecknoglobals // ErrNoAPIKey is returned for functions that require an API key to use when one has not been set. ErrNoAPIKey = errors.New("No steam web api key, to obtain one see: " + "https://steamcommunity.com/dev/apikey and call steamid.SetKey()") ErrInvalidSID = errors.New("Invalid steam id") )
Functions ¶
func KeyConfigured ¶ added in v2.3.0
func KeyConfigured() bool
func SetKey ¶
SetKey will set the package global steam webapi key used for some requests Basic id conversion usage does not require this to be set.
You can alternatively set the key with the environment variable `STEAM_TOKEN={YOUR_API_KEY` To get a key see: https://steamcommunity.com/dev/apikey
Types ¶
type Collection ¶ added in v2.2.0
type Collection []SID64
func (Collection) Contains ¶ added in v2.2.1
func (c Collection) Contains(sid64 SID64) bool
func (Collection) ToStringSlice ¶ added in v2.2.0
func (c Collection) ToStringSlice() []string
type GID ¶
GID represents a GroupID (64bit) 103582791453729676.
func GIDFromString ¶
GIDFromString will attempt to convert a properly formatted string to a GID.
func ResolveGID ¶
ResolveGID tries to resolve the GroupID from a group custom URL. NOTE This may be prone to error due to not being a real api endpoint.
type SID ¶
type SID string
SID represents a SteamID STEAM_0:0:86173181.
func SID32ToSID ¶
SID32ToSID converts a given SID32 to a SteamID. eg. 172346362 -> STEAM_0:0:86173181
An empty SteamID (string) is returned if the process was unsuccessful.
func SID3ToSID ¶
SID3ToSID converts a given SID3 to a SteamID. eg. [U:1:172346362] -> STEAM_0:0:86173181
An empty SteamID (string) is returned if the process was unsuccessful.
func SID64ToSID ¶
SID64ToSID converts a given SID64 to a SteamID. e.g. 76561198132612090 -> STEAM_0:0:86173181
An empty SteamID (string) is returned if the process was unsuccessful.
type SID3 ¶
type SID3 string
SID3 represents a Steam3 [U:1:172346362].
func SID32ToSID3 ¶
SID32ToSID3 converts a given SID32 to a SID3. eg. 172346362 -> [U:1:172346362]
An empty SID3 (string) is returned if the process was unsuccessful.
func SID64ToSID3 ¶
SID64ToSID3 converts a given SID64 to a SID3. e.g. 76561198132612090 -> [U:1:172346362]
An empty SID3 (string) is returned if the process was unsuccessful.
type SID32 ¶
type SID32 uint32
SID32 represents a Steam32 172346362.
func SID3ToSID32 ¶
SID3ToSID32 converts a given SID3 to a SID64. eg. [U:1:172346362] -> 172346362
0 is returned if the process was unsuccessful.
func SID64ToSID32 ¶
SID64ToSID32 converts a given SID64 to a SID32. e.g. 76561198132612090 -> 172346362
0 is returned if the process was unsuccessful.
func SIDToSID32 ¶
SIDToSID32 converts a given SteamID to a SID32. e.g. STEAM_0:0:86173181 -> 172346362
0 is returned if the process was unsuccessful.
type SID64 ¶
SID64 represents a Steam64 76561198132612090.
func ParseString ¶
ParseString attempts to parse any strings of any known format within the body to a common SID64 format.
func RandSID64 ¶
func RandSID64() SID64
RandSID64 generates a unique random (numerically) valid steamid for testing.
func ResolveSID64 ¶
ResolveSID64 tries to retrieve a SteamID64 using a query (search).
If an error occurs or the SteamID was unable to be resolved from the query then am error is returned. TODO try and resolve len(17) && len(9) failed conversions as vanity.
func ResolveVanity ¶
ResolveVanity attempts to resolve the underlying SID64 of a users vanity url name This only accepts the name or last portion of the /id/ profile link For https://steamcommunity.com/id/SQUIRRELLY the value is SQUIRRELLY.
func SID32ToSID64 ¶
SID32ToSID64 converts a given SID32 to a SID64. e.g. 172346362 -> 76561198132612090
0 is returned if the process was unsuccessful.
func SID3ToSID64 ¶
SID3ToSID64 converts a given SID3 to a SID64. eg. [U:1:172346362] -> 76561198132612090
0 is returned if the process was unsuccessful.
func SID64FromString ¶
SID64FromString will attempt to convert a Steam64 formatted string into a SID64.
func SIDToSID64 ¶
SIDToSID64 converts a given SteamID to a SID64. e.g. STEAM_0:0:86173181 -> 76561198132612090
0 is returned if the process was unsuccessful.
func StringToSID64 ¶
StringToSID64 will attempt to convert a string containing some format of steam id into a SID64 automatically, picking the appropriate matching conversion to make.
This will not resolve vanity ids. Use ResolveSID64 if you also want to attempt
to resolve it as a vanity url in addition.
func (SID64) MarshalJSON ¶ added in v2.3.1
func (*SID64) UnmarshalJSON ¶
UnmarshalJSON implements the Unmarshaler interface for steam ids. It will attempt to do all steam id types by calling StringToSID64.