steam

package module
v0.0.0-...-819113b Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2017 License: MIT Imports: 8 Imported by: 0

README

GoDoc Build Status

steam

Steam API implementation in GoLang

go get github.com/FenixAra/steam

To run tests Add your steam API key to STEAM_KEY environment variable.

export STEAM_KEY={your key}
go test

Example

import (
	"github.com/FenixAra/steam"
)

steamAPI := steam.NewSteam(steamApiKey)
steamAPI.SetSteamKey(steamApiKey)

option := steam.NewOption(appID)
option.Count = 10
news, err := steamAPI.GetNews(option)
if err != nil {
	// Handle error
}

option := steam.NewOption(0)
option.SetSteamIDs(steamIDs)
playerSummaries, err := steamAPI.GetPlayerSummaries(option)
if err != nil {
	// Handle error
}

Documentation

Index

Constants

View Source
const (
	BaseURL = "https://api.steampowered.com"
)

Variables

View Source
var (
	ErrSteamIDsExceedsLimit = errors.New("Steam IDs exceeds the max allowed steam IDs")
)

Functions

This section is empty.

Types

type Achievement

type Achievement struct {
	Name       string  `json:"name"`
	Percentage float32 `json:"percent"`
}

type AchievementPercentages

type AchievementPercentages struct {
	Achievements []Achievement `json:"achievements"`
}

type App

type App struct {
	AppID int    `json:"appid"`
	Name  string `json:"name"`
}

type AppList

type AppList struct {
	Apps []App `json:"apps"`
}

type AppNews

type AppNews struct {
	News News `json:"appnews"`
}

type Apps

type Apps struct {
	List AppList `json:"applist"`
}

type Config

type Config struct {
	Key string
}

func NewConfig

func NewConfig(key string) *Config

type Friend

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

type Friends

type Friends struct {
	List FriendsList `json:"friendslist"`
}

type FriendsList

type FriendsList struct {
	Friends []Friend `json:"friends"`
}

type Game

type Game struct {
	ID                       int    `json:"appid"`
	Name                     string `json:"name"`
	PlayTimeForever          int    `json:"playtime_forever"`
	ImgIconURL               string `json:"img_icon_url"`
	ImgLogoURL               string `json:"img_logo_url"`
	HasCommunityVisibleStats bool   `json:"has_community_visible_stats"`
}

type GamesOwned

type GamesOwned struct {
	GamesOwnedResponse GamesOwnedResponse `json:"response"`
}

type GamesOwnedResponse

type GamesOwnedResponse struct {
	GameCount int    `json:"game_count"`
	Games     []Game `json:"games"`
}

type GlobalAchievements

type GlobalAchievements struct {
	Percentages AchievementPercentages `json:"achievementpercentages"`
}

type GlobalStats

type GlobalStats struct {
	Stats  map[string]Stat `json:"globalstats"`
	Result int             `json:"result"`
}

type GlobalStatsResponse

type GlobalStatsResponse struct {
	GlobalStats GlobalStats `json:"response"`
}

type JSONData

type JSONData struct {
	SteamID                int   `json:"steamid"`
	AppIDs                 []int `json:"appids_filter"`
	IncludeAppInfo         bool  `json:"include_appinfo"`
	IncludePlayedFreeGames bool  `json:"include_played_free_games"`
}

type News

type News struct {
	AppID    int        `json:"appid"`
	NewItems []NewsItem `json:"newsitems"`
}

type NewsItem

type NewsItem struct {
	GID           string    `json:"gid"`
	Title         string    `json:"title"`
	URL           string    `json:"url"`
	IsExternalURL bool      `json:"is_external_url"`
	Author        string    `json:"author"`
	Contents      string    `json:"contents"`
	FeedLabel     string    `json:"feedlabel"`
	DateUnix      int       `json:"date"`
	Date          time.Time `json:"-"`
	FeedName      string    `json:"feedname"`
}

type Option

type Option struct {
	AppID                  int
	Count                  int
	MaxLength              int
	Names                  []string
	SteamIDs               string
	SteamID                string
	Relationship           string
	Language               string
	IncludeAppInfo         bool
	IncludePlayedFreeGames bool
	HasJSONData            bool
	JSONData               JSONData
}

func NewOption

func NewOption(appID int) *Option

Get a new Option instance. You can set an App ID to Option.

func (*Option) SetAppIDs

func (o *Option) SetAppIDs(appIDs []int)

Set APP IDs JSON filters

func (*Option) SetIncludeAppInfo

func (o *Option) SetIncludeAppInfo(includeAppInfo bool, IsService bool)

func (*Option) SetIncludePlayedFreeGames

func (o *Option) SetIncludePlayedFreeGames(includePlayedFreeGames bool, IsService bool)

func (*Option) SetSteamID

func (o *Option) SetSteamID(steamID int, IsService bool)

Set the steam ID filter, If IsService is set true then the filters are only sent as JSON input

func (*Option) SetSteamIDs

func (o *Option) SetSteamIDs(ids []string) error

Set steamIDs to Option

type PlayerAchievement

type PlayerAchievement struct {
	APIName  string `json:"apiname"`
	Achieved int    `json:"achieved"`
}

type PlayerInfo

type PlayerInfo struct {
	SteamID                  string `json:"steamid"`
	CommunityVisibilityState int    `json:"communityvisibilitystate"`
	ProfileState             int    `json:"profilestate"`
	ProfileName              string `json:"personaname":`
	LastLogOff               int    `json:"lastlogoff"`
	ProfileURL               string `json:"profileurl"`
	Avatar                   string `json:"avatar"`
	AvatarMedium             string `json:"avatarmedium"`
	AvatarFull               string `json:"avatarfull"`
	PersonaState             int    `json:"personastate"`
	RealName                 string `json:"realname"`
	PrimaryClanID            string `json:"primaryclanid"`
	TimeCreated              int    `json:"timecreated"`
	PersonaStateFlags        int    `json:"personastateflags"`
	LocalCountryCode         string `json:"loccountrycode"`
	LocalStateCode           string `json:"locstatecode"`
	LocalCityID              int    `json:"loccityid"`
	GameID                   int    `json:"gameid"`
	GameServerIP             string `json:"gameserverip"`
	GameExtraInfo            string `json:"gameextrainfo"`
}

type PlayerStat

type PlayerStat struct {
	Name  string `json:"name"`
	Value int    `json:"value"`
}

type PlayerStatistics

type PlayerStatistics struct {
	SteamID      string              `json:"steamID"`
	GameName     string              `json:"gameName"`
	Achievements []PlayerAchievement `json:"achievements"`
	Stats        []PlayerStat        `json:"stats"`
}

type PlayerStats

type PlayerStats struct {
	Stats PlayerStatistics `json:"playerstats"`
}

type PlayerSummaries

type PlayerSummaries struct {
	Response PlayerSummariesResponse `json:"response"`
}

type PlayerSummariesResponse

type PlayerSummariesResponse struct {
	PlayerInfos []PlayerInfo `json:"players"`
}

type Stat

type Stat struct {
	Total string `json:"total"`
}

type Steam

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

func NewSteam

func NewSteam(key string) *Steam

Create a new steam API instance. You can set steam API key.

func (*Steam) GetAppList

func (s *Steam) GetAppList() (*Apps, error)

Get list of all apps present in steam along with their App IDs.

func (*Steam) GetFriendList

func (s *Steam) GetFriendList(o *Option) (*Friends, error)

Get player's friend list using their steam id. Version: v0001

Options:

SteamID(Mandatory) - Steam ID of the player.

Relationship(Madatory) - Relationship filter. Possible values are all, friend.

func (*Steam) GetGlobalAchievement

func (s *Steam) GetGlobalAchievement(o *Option) (*GlobalAchievements, error)

Get global acheivements overview of a specific game in percentage. Version: v0002

Options:

AppID(Mandatory) - App for which you need the global achievements.

func (*Steam) GetGlobalStatsForGame

func (s *Steam) GetGlobalStatsForGame(o *Option) (*GlobalStatsResponse, error)

Get global stats detail for a particular achievement for the given game. Version: v0001

Options:

AppID(Mandatory) - App for which you need the global stats.

Names(Mandatory, atleast 1) - The achievement name/names for which you need the global stats.

func (*Steam) GetNews

func (s *Steam) GetNews(o *Option) (*AppNews, error)

Get news related to the application specified by application's ID. Version: v0002

Options:

AppID(Mandatory) - App for which you need the news.

Count(Optional) - Number of news articles you want to receive.

MaxLength(Optional) - Maximum length of each news entry.

func (*Steam) GetOwnedGames

func (s *Steam) GetOwnedGames(o *Option) (*GamesOwned, error)

Get list of games a player owns along with some playtime information, if the profile is publicly visible. Private, friends-only, and other privacy settings are not supported unless you are asking for your own personal details (ie the steam API key you are using is linked to the steamid you are requesting). Version: v0001

Options:

This API is a service API, you set the filters by using IsService=true.

SteamID(Mandatory) - Steam ID of the player you need achievement stats for.

IncludeAppInfo(Optional) - Include game name and logo information in the output. The default is to return appids only.

IncludePlayedFreeGames(Optional) - By default, free games like Team Fortress 2 are excluded (as technically everyone owns them). If include_played_free_games is set, they will be returned if the player has played them at some point. This is the same behavior as the games list on the Steam Community.

AppIDs(Optional) - App IDs to verify if the user owns it.

func (*Steam) GetPlayerAchievements

func (s *Steam) GetPlayerAchievements(o *Option) (*PlayerStats, error)

Get player's achievements for the given app. Version: v0001

Options:

SteamID(Mandatory) - Steam ID of the player you need achievement stats for.

AppID(Mandatory) - The Application for which achievements are needed.

l(Optional) - Language in which the achievements should be displayed.

func (*Steam) GetPlayerSummaries

func (s *Steam) GetPlayerSummaries(o *Option) (*PlayerSummaries, error)

Get player summaries using their steamids. Version: v0002

Options:

SteamIDs(Mandatory) - You can set comma seperated steamIDs or use Option's method SetSteamIDs(steamIDs[]string)

Steam should have been initialized with Steam API Key Or use Steam's SetSteamKey(key string) to set the Steam API key

func (*Steam) GetUserStatsForGame

func (s *Steam) GetUserStatsForGame(o *Option) (*PlayerStats, error)

Get list of achievements by this user for the given app/game. Version: v0002

Options:

SteamID(Mandatory) - Steam ID of the player you need achievement stats for.

AppID(Mandatory) - The Application for which achievements are needed.

l(Optional) - Language in which the achievements should be displayed.

func (*Steam) SetSteamKey

func (s *Steam) SetSteamKey(key string)

Set steam key for the Steam API instance

Jump to

Keyboard shortcuts

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