steamapi

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: MIT Imports: 15 Imported by: 0

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

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"
)

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 added in v1.2.0

func (c *Client) IPlayerService() *IPlayerService

func (*Client) IPublishedFileService added in v1.2.0

func (c *Client) IPublishedFileService() *ISteamPublishedFileService

func (*Client) ISteamApps added in v1.2.0

func (c *Client) ISteamApps() *ISteamApps

func (*Client) ISteamNews added in v1.2.0

func (c *Client) ISteamNews() *ISteamNews

func (*Client) ISteamUser added in v1.2.0

func (c *Client) ISteamUser() *ISteamUser

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

func (*Client) ISteamWebAPIUtil added in v1.2.0

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 added in v1.2.0

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 added in v1.2.0

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 added in v1.2.0

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

type ClientOption added in v1.2.0

type ClientOption func(client *Client)

func WithClientKey added in v1.2.0

func WithClientKey(key string) ClientOption

func WithClientResty added in v1.2.0

func WithClientResty(client *resty.Client) ClientOption

func WithHttpsClient added in v1.2.0

func WithHttpsClient() ClientOption

type IPlayerService added in v1.2.0

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

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

func (*IPlayerService) GetBadges added in v1.2.0

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

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

func (*IPlayerService) GetCommunityBadgeProgress added in v1.2.0

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) GetOwnedGames added in v1.2.0

func (i *IPlayerService) GetOwnedGames(ownGameOpt player.OwnedGamesQueryOption, ops ...RequestOption) (steam.CommonResponse, error)

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

func (*IPlayerService) GetRecentlyPlayedGames added in v1.2.0

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 added in v1.2.0

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 added in v1.2.0

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

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

type ISteamApps added in v1.2.0

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

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

func (*ISteamApps) GetAppBeta added in v1.2.0

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

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

func (*ISteamApps) GetAppBuilds added in v1.2.0

func (i *ISteamApps) GetAppBuilds(buildsQueryOpt app.BuildsQueryOption, ops ...RequestOption) (steam.CommonResponse, error)

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

func (*ISteamApps) GetAppDepotVersion added in v1.2.0

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

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

func (*ISteamApps) GetAppList added in v1.2.0

func (i *ISteamApps) GetAppList(ops ...RequestOption) (app.PublicAppList, error)

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

func (*ISteamApps) GetPartnerAppListForWebAPIKey added in v1.2.0

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 added in v1.2.0

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

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

func (*ISteamApps) GetServerList added in v1.2.0

func (i *ISteamApps) GetServerList(filter app.ServerListQueryFilter, ops ...RequestOption) (steam.CommonResponse, error)

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

func (*ISteamApps) GetServersAtAddress added in v1.2.0

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

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

func (*ISteamApps) SetAppBuildLive added in v1.2.0

func (i *ISteamApps) SetAppBuildLive(updateOption app.BuildLiveUpdateOption, ops ...RequestOption) (steam.CommonResponse, error)

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

func (*ISteamApps) UpToDateCheck added in v1.2.0

func (i *ISteamApps) UpToDateCheck(opt app.UpToDateCheckQueryOption, ops ...RequestOption) (app.UpToDateCheck, error)

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

type ISteamNews added in v1.2.0

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

func (*ISteamNews) GetNewsForApp added in v1.2.0

func (i *ISteamNews) GetNewsForApp(query news.AppNewsQueryOption, ops ...RequestOption) (news.AppNewsList, error)

GetNewsForApp see https://partner.steamgames.com/doc/webapi/ISteamNews#GetNewsForApp

func (*ISteamNews) GetNewsForAppAuthed added in v1.2.0

func (i *ISteamNews) GetNewsForAppAuthed(query news.AppNewsQueryOption, ops ...RequestOption) (news.AppNewsList, error)

GetNewsForAppAuthed see https://partner.steamgames.com/doc/webapi/ISteamNews#GetNewsForAppAuthed

type ISteamPublishedFileService added in v1.2.0

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

func (*ISteamPublishedFileService) QueryFiles added in v1.2.0

QueryFiles see https://partner.steamgames.com/doc/webapi/IPublishedFileService#QueryFiles

func (*ISteamPublishedFileService) SetDeveloperMetaData added in v1.2.0

SetDeveloperMetaData see https://partner.steamgames.com/doc/webapi/IPublishedFileService#SetDeveloperMetadata

func (*ISteamPublishedFileService) UpdateBanStatus added in v1.2.0

func (i *ISteamPublishedFileService) UpdateBanStatus(banStatusUpdateOpt publishedfile.BanStatusUpdateOption, ops ...RequestOption) (steam.CommonResponse, error)

UpdateBanStatus see https://partner.steamgames.com/doc/webapi/IPublishedFileService#UpdateBanStatus

func (*ISteamPublishedFileService) UpdateIncompatibleStatus added in v1.2.0

UpdateIncompatibleStatus see https://partner.steamgames.com/doc/webapi/IPublishedFileService#UpdateIncompatibleStatus

func (*ISteamPublishedFileService) UpdateTags added in v1.2.0

UpdateTags see https://partner.steamgames.com/doc/webapi/IPublishedFileService#UpdateTags

func (*ISteamPublishedFileService) UpdateUGCBan added in v1.2.0

UpdateUGCBan see https://partner.steamgames.com/doc/webapi/IPublishedFileService#UpdateUGCBan

type ISteamUser added in v1.2.0

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

func (*ISteamUser) CheckAppOwnership added in v1.2.0

func (i *ISteamUser) CheckAppOwnership(ids steam.SteamAppId, ops ...RequestOption) (user.AppOwnershipList, error)

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

func (*ISteamUser) GetAppPriceInfo added in v1.2.0

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 added in v1.2.0

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

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

func (*ISteamUser) GetFriendList added in v1.2.0

func (i *ISteamUser) GetFriendList(relation user.FriendListQueryOption, ops ...RequestOption) (steam.CommonResponse, error)

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

func (*ISteamUser) GetPlayerBans added in v1.2.0

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

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

func (*ISteamUser) GetPlayerSummaries added in v1.2.0

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

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

func (*ISteamUser) GetPublisherAppOwnership added in v1.2.0

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

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

func (*ISteamUser) GetPublisherAppOwnershipChanges added in v1.2.0

func (i *ISteamUser) GetPublisherAppOwnershipChanges(chaneQueryOption user.PublisherAppOwnershipChangeQueryOption, ops ...RequestOption) (user.AppOwnershipChanges, error)

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

func (*ISteamUser) GetUserGroupList added in v1.2.0

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

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

func (*ISteamUser) ResolveVanityURL added in v1.2.0

func (i *ISteamUser) ResolveVanityURL(urlResolve user.ResolveVanityUrlQueryOption, ops ...RequestOption) (steam.CommonResponse, error)

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

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
	Body      any
	Header    http.Header

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

func (*Request) Attach

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

func (*Request) FullURL

func (r *Request) FullURL() string

func (*Request) QueryFormEscaped added in v1.1.0

func (r *Request) QueryFormEscaped() map[string]string

func (*Request) Send

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

type RequestOption added in v1.2.0

type RequestOption func(request *Request)

RequestOption use options to override some request settings

func WithAPIKey added in v1.2.0

func WithAPIKey(key string) RequestOption

func WithBody added in v1.2.0

func WithBody(body any) RequestOption

func WithHeader added in v1.2.0

func WithHeader(header http.Header) RequestOption

func WithHost added in v1.2.0

func WithHost(host string) RequestOption

func WithLanguage

func WithLanguage(language string) RequestOption

func WithMethod added in v1.2.0

func WithMethod(method string) RequestOption

func WithQueryForm added in v1.2.0

func WithQueryForm(query any) RequestOption

func WithQueryMap added in v1.2.0

func WithQueryMap(query map[string]any) RequestOption

func WithRequest added in v1.2.0

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

func WithURL added in v1.2.0

func WithURL(url string) RequestOption

Directories

Path Synopsis
types
app

Jump to

Keyboard shortcuts

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