steam

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package steam is the library behind the steam command: the HTTP client, request shaping, and typed data models for the Steam game store.

Two base APIs:

Index

Constants

View Source
const DefaultUserAgent = "steam/dev (+https://github.com/tamnd/steam-cli)"

DefaultUserAgent identifies the client to Steam.

View Source
const Host = "store.steampowered.com"

Host is the Steam store hostname, used by the kit domain driver.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is returned when an app is unavailable or the API returns no data.

Functions

func ParseAppID

func ParseAppID(s string) (int, error)

ParseAppID parses a bare integer or a Steam store URL into an appid. Accepted forms:

570
https://store.steampowered.com/app/570/
https://store.steampowered.com/app/570/Dota_2/

Types

type Client

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

Client talks to the Steam store APIs.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client configured from cfg.

func (*Client) GameDetails

func (c *Client) GameDetails(ctx context.Context, appid int) (GameDetail, error)

GameDetails returns full details for a single app by appid.

func (*Client) NewReleases

func (c *Client) NewReleases(ctx context.Context, limit int) ([]Game, error)

NewReleases returns the newest released games on the store.

func (*Client) Reviews

func (c *Client) Reviews(ctx context.Context, appid, limit int) ([]Review, error)

Reviews returns user reviews for appid. It paginates until limit is reached.

func (*Client) Search

func (c *Client) Search(ctx context.Context, query string, limit int) ([]Game, error)

Search searches the Steam store for query and returns up to limit results.

func (*Client) Specials

func (c *Client) Specials(ctx context.Context, limit int) ([]Game, error)

Specials returns games currently on sale (discount_percent > 0).

func (*Client) TopSellers

func (c *Client) TopSellers(ctx context.Context, limit int) ([]Game, error)

TopSellers returns the top-selling games on the store.

type Config

type Config struct {
	UserAgent string
	Rate      time.Duration
	Retries   int
	Timeout   time.Duration
	// BaseURL overrides the Steam store API base for testing.
	// Defaults to "https://store.steampowered.com/api".
	BaseURL string
}

Config holds constructor parameters.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns sensible defaults.

type Domain added in v0.1.1

type Domain struct{}

Domain is the steam kit driver. Register it with a blank import:

import _ "github.com/tamnd/steam-cli/steam"

func (Domain) Info added in v0.1.1

func (Domain) Info() kit.DomainInfo

func (Domain) Register added in v0.1.1

func (Domain) Register(app *kit.App)

type Game

type Game struct {
	Rank     int    `json:"rank"`
	ID       int    `json:"id"`
	Name     string `json:"name"`
	Price    string `json:"price"`
	Discount int    `json:"discount"`
	URL      string `json:"url"`
}

Game is the record emitted for list commands: top-sellers, new-releases, specials, search.

type GameDetail

type GameDetail struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Type        string `json:"type"`
	Description string `json:"description"`
	Developers  string `json:"developers"`
	Publishers  string `json:"publishers"`
	Price       string `json:"price"`
	Discount    int    `json:"discount"`
	Released    string `json:"released"`
	Metacritic  int    `json:"metacritic"`
	Genres      string `json:"genres"`
	IsFree      bool   `json:"is_free"`
	URL         string `json:"url"`
}

GameDetail is the record emitted by the game command.

type Review

type Review struct {
	Rank      int    `json:"rank"`
	Voted     string `json:"voted"`
	Author    string `json:"author"`
	Playtime  int    `json:"playtime"`
	Review    string `json:"review"`
	Timestamp string `json:"timestamp"`
}

Review is the record emitted by the reviews command.

Jump to

Keyboard shortcuts

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