steamwebapi

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2025 License: 0BSD Imports: 9 Imported by: 1

README

steamwebapi

This lightweight Go library provides an easy way accessing the Steam Web API through a clean and functional interface which handles making HTTP requests and processing responses.

Documentation

Index

Constants

View Source
const BaseSteamAPIURLProduction = "https://api.steampowered.com"

BaseSteamAPIURLProduction is the steam url used to do requests in prod

View Source
const ISteamWebAPIUtilIface = "ISteamWebAPIUtil"

Variables

View Source
var BaseSteamAPIURL = BaseSteamAPIURLProduction

BaseSteamAPIURL is the url used to do requests, defaulted to prod

View Source
var GetServerInfoMethod = NewMethod[*GetServerInfoResponse](ISteamWebAPIUtilIface, "GetServerInfo", 1)

GlobalRate counts global API usage.

Functions

func NewDefaultClient

func NewDefaultClient() *resty.Client

Types

type CallConfig added in v0.3.0

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

CallConfig represents optional arguments to Method.Call.

func NewCallConfig added in v0.3.0

func NewCallConfig() *CallConfig

func (*CallConfig) SetArgs added in v0.3.0

func (c *CallConfig) SetArgs(args url.Values) *CallConfig

func (*CallConfig) SetHeaders added in v0.3.0

func (c *CallConfig) SetHeaders(headers url.Values) *CallConfig

type GetServerInfoResponse added in v0.3.0

type GetServerInfoResponse struct {
	ServerTimeInt    int    `json:"servertime"`
	ServerTimeString string `json:"servertimestring"`
}

type HTTPError

type HTTPError struct {
	Response *resty.Response
	Method   string
}

func (*HTTPError) Error

func (e *HTTPError) Error() string

type Method

type Method[T any] struct {
	// contains filtered or unexported fields
}

A Method represents a Steam Web API method.

func NewMethod

func NewMethod[T any](iface, method string, version int) *Method[T]

NewMethod creates a new Method.

func (*Method[T]) Call

func (m *Method[T]) Call(ctx context.Context, opts ...*CallConfig) (out T, err error)

Call makes a request to the Steam Web API with the given arguments and stores the result in the given out parameter.

May return an HTTPError error if the return status code was not 200. May return other errors from calling into resty.Request.Get.

func (*Method[T]) Rate

func (m *Method[T]) Rate() *ratecounter.AvgRateCounter

Rate returns the average rate counter.

func (*Method[T]) String added in v0.3.0

func (m *Method[T]) String() string

func (*Method[T]) URLString added in v0.2.0

func (m *Method[T]) URLString() string

type RequestProvider

type RequestProvider interface {
	NewRequest() *resty.Request
}

Client is the http client that will be used for all API calls.

Jump to

Keyboard shortcuts

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