steamapi

package module
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: MIT Imports: 22 Imported by: 1

README

English|简体中文

steamapi

Static Badge GitHub

steamapi is a Steam Web API Client package.Through it, you can easily interact with the Steam web API. The original Steam API Doc address is located at Steam Web API

Install

go get github.com/246859/steamapi

Supported Interface

Since the host is partner.steam-api.com, the interface needs the publisher key to call, and the publisher key must be 100$ to register, so we have no way to get its specific response, so the interface The unified return type is map[string]any

  • IPublishedFileService
  • ISteamNews
  • ISteamUser
  • IPlayerService
  • ISteamWebAPIUtil
  • ISteamApps
  • ISteamPublishedItemVoting
  • ISteamPublishedItemSearch
  • ISteamLeaderBoard
  • ISteamUserAuth
  • ISteamBroadcastService
  • ISteamRemoteStorage
  • ISteamGameServerStats
  • ISteamCommunity

Example

GetServerInfo interface has no apikey required, but you should pass a key still.In this case, you can pass a steamapi.NopKey to New func which just a meaningless string.

// initialize client with NopKey
client, err := steamapi.New(steamapi.NopKey)
if err != nil {
    panic(err)
}
// call the webapiutil interface
info, err := client.ISteamWebAPIUtil().GetServerInfo()
if err != nil {
    panic(err)
}
fmt.Printf("%+v", info)

output

{ ServerTime: 1693832041 ServerTimeString: Mon Sep  4 05:54:01 2023 }

GetSupportedAPIList interface needs to pass your own apikey


// pass your own key
client, err := steamapi.New(key)
if err != nil {
    panic(err)
}
list, err := client.ISteamWebAPIUtil().GetSupportedAPIList()
if err != nil {
    panic(err)
}
fmt.Printf("%+v", list)

output

{ApiList:{Interfaces:[{Name:IClientStats_1046930 Methods:[{Name:ReportEvent Version:1 HttpMethod:POST Parameters:[]}]} {Name:ICSGOPlayers_730...
...
...
...

Contribute

  1. fork this repository
  2. create you own feature branch
  3. commit your changes
  4. create a pull request to this repository
  5. waiting pr to be merged

Documentation

Index

Constants

View Source
const (
	NopKey           = "nop-key"
	EmptyKey         = ""
	QuerySteamApiKey = "key"
	QueryLanguage    = "language"
)
View Source
const (
	// PublicHost is the public steam server, you can interact with you own normal key
	PublicHost = "api.steampowered.com"

	// PartnerHost is the partner steam server, you should take your publisher api key in query parameters in any case
	PartnerHost = "partner.steam-api.com"

	// InputJson service interface need "input_json" query parameter to pass post params
	InputJson = "input_json"
)

Variables

View Source
var (
	ApiKeyNotExistErr = errors.New("steam api key must be provided")
)
View Source
var (
	PartnerEnforceHttpsErr = errors.New("partner.steam-api.com must be requested with https")
)

Functions

This section is empty.

Types

type Client

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

Client steam api client, interact with steam api server

func New

func New(key string) (*Client, error)

New func create a new Client only with api key which must be provided, if you just want to access some interface which does not need api key you can pass the NopKey

func NewWith

func NewWith(options ...ClientOption) (*Client, error)

func (*Client) Get

func (c *Client) Get(host, url string, resultPtr any, opts ...RequestOption) (*resty.Response, error)

func (*Client) IPlayerService

func (c *Client) IPlayerService() *IPlayerService

func (*Client) IPublishedFileService

func (c *Client) IPublishedFileService() *ISteamPublishedFileService

func (*Client) ISteamApps

func (c *Client) ISteamApps() *ISteamApps

func (*Client) ISteamBroadcastService

func (c *Client) ISteamBroadcastService() *ISteamBroadcastService

func (*Client) ISteamCommunity

func (c *Client) ISteamCommunity() *ISteamCommunity

func (*Client) ISteamGameServerStats

func (c *Client) ISteamGameServerStats() *ISteamGameServerStats

func (*Client) ISteamLeaderBoards

func (c *Client) ISteamLeaderBoards() *ISteamLeaderBoards

func (*Client) ISteamNews

func (c *Client) ISteamNews() *ISteamNews

func (*Client) ISteamPublishedItemVoting

func (c *Client) ISteamPublishedItemVoting() *ISteamPublishedItemVoting

func (*Client) ISteamPublishedSearch

func (c *Client) ISteamPublishedSearch() *ISteamPublishedItemSearch

func (*Client) ISteamRemoteStorage

func (c *Client) ISteamRemoteStorage() *ISteamRemoteStorage

func (*Client) ISteamUser

func (c *Client) ISteamUser() *ISteamUser

ISteamUser see https://partner.steamgames.com/doc/webapi/ISteamUser

func (*Client) ISteamUserAuth

func (c *Client) ISteamUserAuth() *ISteamUserAuth

func (*Client) ISteamWebAPIUtil

func (c *Client) ISteamWebAPIUtil() *ISteamWebAPIUtil

func (*Client) NewRequest

func (c *Client) NewRequest(method, host, url string, options ...RequestOption) *Request

NewRequest creates a new request, you can use options to customize request configuration

func (*Client) Post

func (c *Client) Post(host, url string, resultPtr any, opts ...RequestOption) (*resty.Response, error)

func (*Client) SendRequest

func (c *Client) SendRequest(method, host, url string, resultPtr any, opts ...RequestOption) (*resty.Response, error)

SendRequest this is a helper func to send a request, resultPtr must be a pointer.

func (*Client) Unknown

func (c *Client) Unknown(method, host, url string, opts ...RequestOption) (steam.CommonResponse, error)

Unknown some interfaces response are unknown, so return steam.CommonResponse that is alias of map[string]any

type ClientCfg

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

type ClientOption

type ClientOption func(client *Client)

func WithClientKey

func WithClientKey(key string) ClientOption

func WithClientResty

func WithClientResty(client *resty.Client) ClientOption

func WithHttpsClient

func WithHttpsClient() ClientOption

type IPlayerService

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

IPlayerService see https://partner.steamgames.com/doc/webapi/IPlayerService

func (*IPlayerService) GetCommunityBadgeProgress

func (i *IPlayerService) GetCommunityBadgeProgress(steamId uint, badgeId int, ops ...RequestOption) (steam.CommonResponse, error)

GetCommunityBadgeProgress see https://partner.steamgames.com/doc/webapi/IPlayerService#GetCommunityBadgeProgress

func (*IPlayerService) GetRecentlyPlayedGames

func (i *IPlayerService) GetRecentlyPlayedGames(steamId uint, count uint, ops ...RequestOption) (steam.CommonResponse, error)

GetRecentlyPlayedGames see https://partner.steamgames.com/doc/webapi/IPlayerService#GetRecentlyPlayedGames

func (*IPlayerService) GetSingleGamePlayTime

func (i *IPlayerService) GetSingleGamePlayTime(steamId uint, appId uint, ops ...RequestOption) (steam.CommonResponse, error)

GetSingleGamePlayTime see https://partner.steamgames.com/doc/webapi/IPlayerService#GetSingleGamePlaytime

func (*IPlayerService) GetSteamLevel

func (i *IPlayerService) GetSteamLevel(steamId uint, ops ...RequestOption) (steam.CommonResponse, error)

GetSteamLevel see https://partner.steamgames.com/doc/webapi/IPlayerService#GetSteamLevel

type ISteamApps

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

ISteamApps see https://partner.steamgames.com/doc/webapi/ISteamApps

func (*ISteamApps) GetAppDepotVersion

func (i *ISteamApps) GetAppDepotVersion(appId uint, ops ...RequestOption) (steam.CommonResponse, error)

GetAppDepotVersion see https://partner.steamgames.com/doc/webapi/ISteamApps#GetAppDepotVersion

func (*ISteamApps) GetPartnerAppListForWebAPIKey

func (i *ISteamApps) GetPartnerAppListForWebAPIKey(filter app.PartnerAppQueryFilter, ops ...RequestOption) (app.PartnerAppList, error)

GetPartnerAppListForWebAPIKey see https://partner.steamgames.com/doc/webapi/ISteamApps#GetPartnerAppListForWebAPIKey

func (*ISteamApps) GetPlayersBanned

func (i *ISteamApps) GetPlayersBanned(appId uint, ops ...RequestOption) (steam.CommonResponse, error)

GetPlayersBanned see https://partner.steamgames.com/doc/webapi/ISteamApps#GetPlayersBanned

func (*ISteamApps) GetServersAtAddress

func (i *ISteamApps) GetServersAtAddress(addr string, ops ...RequestOption) (app.ServerAddressList, error)

GetServersAtAddress see https://partner.steamgames.com/doc/webapi/ISteamApps#GetServersAtAddress

type ISteamBroadcastService

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

ISteamBroadcastService see https://partner.steamgames.com/doc/webapi/IBroadcastService

type ISteamCommunity

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

ISteamCommunity see https://partner.steamgames.com/doc/webapi/ISteamCommunity

type ISteamGameServerStats

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

ISteamGameServerStats see https://partner.steamgames.com/doc/webapi/ISteamGameServerStats

type ISteamLeaderBoards

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

ISteamLeaderBoards see https://partner.steamgames.com/doc/webapi/ISteamLeaderboards

func (*ISteamLeaderBoards) GetLeaderboardsForGame

func (i *ISteamLeaderBoards) GetLeaderboardsForGame(appid uint, ops ...RequestOption) (steam.CommonResponse, error)

GetLeaderboardsForGame see https://partner.steamgames.com/doc/webapi/ISteamLeaderboards#GetLeaderboardsForGame

type ISteamNews

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

type ISteamPublishedFileService

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

type ISteamPublishedItemSearch

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

ISteamPublishedItemSearch see https://partner.steamgames.com/doc/webapi/ISteamPublishedItemSearch

type ISteamPublishedItemVoting

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

ISteamPublishedItemVoting see https://partner.steamgames.com/doc/webapi/ISteamPublishedItemVoting

type ISteamRemoteStorage

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

ISteamRemoteStorage see https://partner.steamgames.com/doc/webapi/ISteamRemoteStorage

type ISteamUser

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

func (*ISteamUser) GetAppPriceInfo

func (i *ISteamUser) GetAppPriceInfo(steamId uint, appIds string, ops ...RequestOption) (steam.CommonResponse, error)

GetAppPriceInfo see https://partner.steamgames.com/doc/webapi/ISteamUser#GetAppPriceInfo

func (*ISteamUser) GetDeletedSteamIds

func (i *ISteamUser) GetDeletedSteamIds(rowVersion uint, ops ...RequestOption) (steam.CommonResponse, error)

GetDeletedSteamIds see https://partner.steamgames.com/doc/webapi/ISteamUser#GetDeletedSteamIds

func (*ISteamUser) GetPlayerBans

func (i *ISteamUser) GetPlayerBans(steamids string, ops ...RequestOption) (steam.CommonResponse, error)

GetPlayerBans see https://partner.steamgames.com/doc/webapi/ISteamUser#GetPlayerBans

func (*ISteamUser) GetPlayerSummaries

func (i *ISteamUser) GetPlayerSummaries(steamids string, ops ...RequestOption) (user.PlayerSummaryList, error)

GetPlayerSummaries see https://partner.steamgames.com/doc/webapi/ISteamUser#GetPlayerSummaries

func (*ISteamUser) GetPublisherAppOwnership

func (i *ISteamUser) GetPublisherAppOwnership(steamId uint, ops ...RequestOption) (user.PublisherAppOwnershipList, error)

GetPublisherAppOwnership see https://partner.steamgames.com/doc/webapi/ISteamUser#GetPublisherAppOwnership

func (*ISteamUser) GetUserGroupList

func (i *ISteamUser) GetUserGroupList(steamId uint, ops ...RequestOption) (steam.CommonResponse, error)

GetUserGroupList see https://partner.steamgames.com/doc/webapi/ISteamUser#GetUserGroupList

type ISteamUserAuth

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

ISteamUserAuth see https://partner.steamgames.com/doc/webapi/ISteamUserAuth

func (*ISteamUserAuth) AuthenticateUser

func (i *ISteamUserAuth) AuthenticateUser(authenticateOpt user.AuthenticateOpt, ops ...RequestOption) (steam.CommonResponse, error)

AuthenticateUser see https://partner.steamgames.com/doc/webapi/ISteamUserAuth#AuthenticateUser

func (*ISteamUserAuth) AuthenticateUserTicket

func (i *ISteamUserAuth) AuthenticateUserTicket(ticketAuthenticateOpt user.TicketAuthenticateOpt, ops ...RequestOption) (steam.CommonResponse, error)

AuthenticateUserTicket see https://partner.steamgames.com/doc/webapi/ISteamUserAuth#AuthenticateUserTicket

type ISteamWebAPIUtil

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

type Request

type Request struct {
	Host      string
	Method    string
	Url       string
	QueryForm map[string]any
	FormData  map[string]any
	Body      any
	Header    http.Header

	*resty.Request
	// contains filtered or unexported fields
}

func (*Request) Attach

func (r *Request) Attach(req *resty.Request)

func (*Request) FormEscaped

func (r *Request) FormEscaped(form map[string]any) map[string]string

func (*Request) FullURL

func (r *Request) FullURL() string

func (*Request) Send

func (r *Request) Send() (*resty.Response, error)

type RequestOption

type RequestOption func(request *Request)

RequestOption use options to override some request settings

func WithAPIKey

func WithAPIKey(key string) RequestOption

func WithBody

func WithBody(body any) RequestOption

func WithFormData

func WithFormData(formdata any) RequestOption

func WithHeader

func WithHeader(header http.Header) RequestOption

func WithHost

func WithHost(host string) RequestOption

func WithInputJson

func WithInputJson(input any) RequestOption

func WithLanguage

func WithLanguage(language string) RequestOption

func WithMethod

func WithMethod(method string) RequestOption

func WithQueryForm

func WithQueryForm(query any) RequestOption

func WithQueryMap

func WithQueryMap(query map[string]any) RequestOption

func WithRequest

func WithRequest(fn func(r *resty.Request)) RequestOption

func WithURL

func WithURL(url string) RequestOption

Jump to

Keyboard shortcuts

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