Skip to content

steamanalyst/go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SteamAnalyst Go SDK

Go Reference Go Report Card License: MIT

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

Links


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

About

Official Go client for the SteamAnalyst CS2 Pricing API — real-time skin prices from 30+ marketplaces

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages