Skip to content

feat: add JSON output format #8

@unhappychoice

Description

@unhappychoice

Summary

Add --json flag to output stats in JSON format for scripting and integration with other tools.

Interface

steamfetch --json           # Pretty-printed JSON
steamfetch --json --compact # Minified JSON (single line)

Output Example

{
  "username": "unhappychoice",
  "account_created": "2010-01-15",
  "account_age_years": 16,
  "steam_level": 42,
  "games": {
    "total": 486,
    "unplayed": 123,
    "unplayed_percent": 25
  },
  "playtime": {
    "total_hours": 2847,
    "top_games": [
      { "name": "Borderlands 3", "hours": 478 },
      { "name": "Coin Push RPG", "hours": 377 }
    ]
  },
  "recently_played": [
    { "name": "Elden Ring", "hours": 20, "minutes": 0 }
  ],
  "achievements": {
    "total": 3241,
    "possible": 5892,
    "percent": 55,
    "perfect_games": 24,
    "rarest": {
      "name": "Impossible Task",
      "game": "Dark Souls III",
      "percent": 0.1
    }
  }
}

Implementation

  • Add Serialize derive to SteamStats and related structs
  • Add --json CLI flag
  • Use serde_json for serialization (already a dependency via reqwest)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions