steamanalyst

package module
v0.0.0-...-68851c7 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 6 Imported by: 0

README

SteamAnalyst Go SDK

Go Reference Go Report Card

The official Go client library for the SteamAnalyst CS2 Pricing API. Retrieve real-time and aggregated CS2 skin prices from 25+ marketplaces with a single API call.

About SteamAnalyst

SteamAnalyst is the leading price aggregation platform for Counter-Strike 2 skins. It continuously tracks prices across every major CS2 marketplace and computes fair market values used by traders, investors, and developers worldwide.

Getting Started

1. Get Your API Key

Sign up and generate an API key on the SteamAnalyst API page. Three tiers are available:

Tier Endpoints Rate Limit
Hobby (free) GET /v1/prices 30 req/min, 100 req/day
Lite GET /v1/prices + GET /v1/prices/all 60 req/min
Paid All endpoints (v1, v2, v3) 300 req/min

Full details on the SteamAnalyst API info page.

2. Install
go get github.com/steamanalyst/go
3. Quick Start
package main

import (
    "fmt"
    "log"

    steamanalyst "github.com/steamanalyst/go"
)

func main() {
    client := steamanalyst.New("sa_live_your_api_key_here")

    price, err := client.GetPrice("AK-47 | Redline (Field-Tested)")
    if err != nil {
        log.Fatal(err)
    }

    fmt.Printf("%s: $%.2f\n", price.MarketName, price.Price)
}

API Reference

Full API documentation is available at api.steamanalyst.com/docs.

New(apiKey string, opts ...Option) *Client

Creates a new SteamAnalyst API client. Requires an API key from steamanalyst.com/api-info.

// Default configuration
client := steamanalyst.New("sa_live_xxx")

// With custom base URL
client := steamanalyst.New("sa_live_xxx", steamanalyst.WithBaseURL("https://custom.endpoint.com"))

// With custom HTTP client
client := steamanalyst.New("sa_live_xxx", steamanalyst.WithHTTPClient(&http.Client{
    Timeout: 60 * time.Second,
}))

GetPrice(marketName string) (*PriceData, error)

GET /v1/prices?market_name=NAME — Tier: Hobby, Lite, Paid

Returns the SteamAnalyst aggregated price for a single CS2 item.

price, err := client.GetPrice("AWP | Dragon Lore (Factory New)")
if err != nil {
    log.Fatal(err)
}
fmt.Printf("%s: $%.2f\n", price.MarketName, price.Price)
// AWP | Dragon Lore (Factory New): $12450.00

GetAllPrices() ([]PriceAllItem, error)

GET /v1/prices/all — Tier: Lite, Paid

Returns prices for every CS2 item tracked by SteamAnalyst.

items, err := client.GetAllPrices()
if err != nil {
    log.Fatal(err)
}
fmt.Printf("Loaded %d items\n", len(items))
for _, item := range items[:5] {
    fmt.Printf("  %s: $%.2f\n", item.MarketName, item.AvgPrice7DaysRaw)
}

GetGamePrices(game string) (json.RawMessage, error)

GET /v2/:game — Tier: Paid

Returns the full pricing dataset for a specific game. Supported games: csgo, dota2.

data, err := client.GetGamePrices("csgo")
if err != nil {
    log.Fatal(err)
}

// Unmarshal into your own type
var prices map[string]interface{}
json.Unmarshal(data, &prices)

GetMarketPrices() (*MarketsPriceData, error)

GET /v3/markets — Tier: Paid

Returns per-item prices across all tracked marketplaces. Each item includes the lowest listed price on every marketplace — Buff, Skinbaron, DMarket, CSFloat, and 20+ others.

markets, err := client.GetMarketPrices()
if err != nil {
    log.Fatal(err)
}

item := markets.MarketsPrices["AK-47 | Redline (Field-Tested)"]
for marketplace, price := range item {
    if price != nil {
        fmt.Printf("  %s: $%.2f\n", marketplace, *price)
    }
}

Examples

Price Checker

Look up the current SteamAnalyst price for any CS2 skin:

package main

import (
    "fmt"
    "log"
    "os"

    steamanalyst "github.com/steamanalyst/go"
)

func main() {
    client := steamanalyst.New(os.Getenv("STEAMANALYST_API_KEY"))

    skins := []string{
        "AK-47 | Redline (Field-Tested)",
        "AWP | Asiimov (Field-Tested)",
        "M4A4 | Howl (Factory New)",
        "Karambit | Doppler (Factory New)",
    }

    for _, skin := range skins {
        price, err := client.GetPrice(skin)
        if err != nil {
            log.Printf("Error fetching %s: %v", skin, err)
            continue
        }
        fmt.Printf("%-45s $%10.2f\n", price.MarketName, price.Price)
    }
}
Find the Cheapest Marketplace

Compare prices across all CS2 marketplaces to find the best deal:

package main

import (
    "fmt"
    "log"
    "math"
    "os"

    steamanalyst "github.com/steamanalyst/go"
)

func main() {
    client := steamanalyst.New(os.Getenv("STEAMANALYST_API_KEY"))

    markets, err := client.GetMarketPrices()
    if err != nil {
        log.Fatal(err)
    }

    itemName := "AK-47 | Redline (Field-Tested)"
    item, ok := markets.MarketsPrices[itemName]
    if !ok {
        log.Fatalf("Item not found: %s", itemName)
    }

    bestMarket := ""
    bestPrice := math.MaxFloat64

    for marketplace, price := range item {
        if price != nil && *price > 0 && *price < bestPrice {
            bestPrice = *price
            bestMarket = marketplace
        }
    }

    fmt.Printf("Cheapest listing for %s:\n", itemName)
    fmt.Printf("  %s at $%.2f\n", bestMarket, bestPrice)
}
Error Handling

The SDK returns typed errors for API failures:

price, err := client.GetPrice("Nonexistent Skin Name")
if err != nil {
    var saErr *steamanalyst.SteamAnalystError
    if errors.As(err, &saErr) {
        switch saErr.Code {
        case "ITEM_NOT_FOUND":
            fmt.Println("Item does not exist")
        case "RATE_LIMIT_EXCEEDED":
            fmt.Println("Slow down — check rate limits at steamanalyst.com/api-info")
        case "INSUFFICIENT_TIER":
            fmt.Println("Upgrade your API key at steamanalyst.com/api-info")
        default:
            fmt.Printf("API error: %s\n", saErr.Message)
        }
    } else {
        fmt.Printf("Network error: %v\n", err)
    }
}

Rate Limits

Rate limits depend on your API tier. The API returns rate limit headers with every response:

Header Description
X-RateLimit-Limit Maximum requests per window
X-RateLimit-Remaining Requests remaining in current window
X-RateLimit-Reset Unix timestamp when the window resets
Tier Per-Minute Limit Daily Limit
Hobby (free) 30 100
Lite 60 Unlimited
Paid 300 Unlimited

Manage your API key and view current usage at steamanalyst.com/api-info.

Error Codes

Code HTTP Description
MISSING_AUTH 401 No API key provided
INVALID_KEY 401 API key is invalid or revoked
INSUFFICIENT_TIER 403 Endpoint requires a higher tier
ITEM_NOT_FOUND 404 Item market name not found
RATE_LIMIT_EXCEEDED 429 Too many requests
DAILY_LIMIT_EXCEEDED 429 Daily request quota exceeded (hobby tier)
DATA_UNAVAILABLE 503 Price data temporarily unavailable

Requirements


Built and maintained by SteamAnalyst. Licensed under the MIT License.

Documentation

Overview

Package steamanalyst provides a Go client for the SteamAnalyst CS2 Pricing API.

SteamAnalyst (https://steamanalyst.com) tracks real-time prices across 25+ CS2 skin marketplaces, providing aggregated pricing data through a simple REST API.

Get your API key at https://steamanalyst.com/api-info

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiError

type ApiError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

ApiError describes an error returned by the API.

type ApiResponse

type ApiResponse struct {
	Success bool            `json:"success"`
	Data    json.RawMessage `json:"data,omitempty"`
	Error   *ApiError       `json:"error,omitempty"`
}

ApiResponse is the standard API envelope returned by all endpoints.

type Client

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

Client is the SteamAnalyst API client.

func New

func New(apiKey string, opts ...Option) *Client

New creates a new SteamAnalyst API client.

You can obtain an API key at https://steamanalyst.com/api-info

func (*Client) GetAllPrices

func (c *Client) GetAllPrices() ([]PriceAllItem, error)

GetAllPrices retrieves prices for all CS2 items.

This endpoint requires a lite or paid tier API key.

func (*Client) GetGamePrices

func (c *Client) GetGamePrices(game string) (json.RawMessage, error)

GetGamePrices retrieves the full pricing dataset for a game.

Supported game identifiers: "csgo", "dota2". This endpoint requires a paid tier API key with the game subscription.

Returns the raw JSON data object, which you can unmarshal into your own types.

func (*Client) GetMarketPrices

func (c *Client) GetMarketPrices() (*MarketsPriceData, error)

GetMarketPrices retrieves per-item prices across all tracked marketplaces.

This endpoint requires a paid tier API key. It returns the lowest listed price for every CS2 item on each of the 25+ marketplaces tracked by SteamAnalyst (https://steamanalyst.com/markets).

func (*Client) GetPrice

func (c *Client) GetPrice(marketName string) (*PriceData, error)

GetPrice retrieves the price for a single CS2 item by its exact market name.

This endpoint is available to all API tiers (hobby, lite, paid).

Example market name: "AK-47 | Redline (Field-Tested)"

type MarketsPriceData

type MarketsPriceData struct {
	MarketsPrices map[string]map[string]*float64 `json:"markets_prices"`
}

MarketsPriceData contains per-item prices across all supported marketplaces.

The outer map key is the item market name. The inner map keys are marketplace identifiers (e.g., "buff", "skinbaron", "dmarket") and values are the lowest listed price on that marketplace, or nil if unavailable.

See https://steamanalyst.com/markets for the full list of tracked marketplaces.

type Option

type Option func(*Client)

Option configures the Client.

func WithBaseURL

func WithBaseURL(url string) Option

WithBaseURL overrides the default API base URL.

func WithHTTPClient

func WithHTTPClient(hc *http.Client) Option

WithHTTPClient sets a custom http.Client for requests.

type PriceAllItem

type PriceAllItem struct {
	MarketName       string  `json:"market_name"`
	AvgPrice7DaysRaw float64 `json:"avg_price_7_days_raw"`
}

PriceAllItem represents a single item from the bulk prices endpoint.

type PriceData

type PriceData struct {
	MarketName string  `json:"market_name"`
	Price      float64 `json:"price"`
}

PriceData represents the price of a single CS2 item.

type SteamAnalystError

type SteamAnalystError struct {
	StatusCode int
	Code       string
	Message    string
}

SteamAnalystError is returned when the API responds with success: false.

func (*SteamAnalystError) Error

func (e *SteamAnalystError) Error() string

Jump to

Keyboard shortcuts

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