Skip to content

feature: add stats api#125

Merged
OpenSteam001 merged 1 commit into
mainfrom
feature/opensteamtool-stats-api
Jun 20, 2026
Merged

feature: add stats api#125
OpenSteam001 merged 1 commit into
mainfrom
feature/opensteamtool-stats-api

Conversation

@OpenSteam001

@OpenSteam001 OpenSteam001 commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Summary

This PR adds optional Stats SteamID API support for stats and achievements.

Previously, when no Lua setStat(appid, "steamid") override was configured, OpenSteamTool always fell back to the hardcoded default SteamID. With this change, OpenSteamTool can now query the official stats API to obtain a recommended SteamID for the current AppId.

Behavior

The SteamID resolution priority is now:

  1. Lua setStat(appid, "steamid")
  2. Stats API, when [stats] enable_api = true and the API returns a valid SteamID
  3. Hardcoded fallback SteamID 76561198028121353

This keeps existing Lua configurations fully compatible while improving the default behavior for games without a manually configured setStat.

New Configuration

[stats]
# Query the official stats API when no Lua setStat override exists.
# Priority: setStat > stats API > hardcoded preset SteamID.
enable_api = true

Users can set enable_api = false to disable the remote API lookup and keep the old fallback-only behavior.

Implementation Details

  • Added StatsClient for querying the stats API.
  • Added thread-safe in-memory caching to avoid repeated API requests for the same AppId.
  • Added validation for API responses: only HTTP 200 responses containing a valid non-zero uint64 SteamID are accepted.
  • Integrated the API lookup into LuaConfig::GetStatSteamId.
  • Added [stats] enable_api parsing to the main config loader.
  • Updated README.md, README_ES.md, and opensteamtool.example.toml.

Compatibility

Existing setStat() usage is not affected. Manually configured SteamIDs still have the highest priority.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5a788a33ed

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

char url[128];
std::snprintf(url, sizeof(url), "https://stats.opensteamtool.com/%u", appId);

auto r = OSTPlatform::Http::Execute(L"GET", url);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid blocking stats packet sends on the API call

When an unlocked app has no setStat override and the stats API is enabled by default, this synchronous WinHTTP request runs inside LuaConfig::GetStatSteamId, which is called from the outgoing user-stats packet handlers before forwarding the packet. If stats.opensteamtool.com is slow or unreachable, each uncached app can stall Steam/game networking until the HTTP timeouts expire; failures are not cached, so the stall repeats on later stats requests. Consider resolving this asynchronously, prefetching, or caching failures/using much shorter configurable timeouts.

Useful? React with 👍 / 👎.

@OpenSteam001 OpenSteam001 merged commit 02dee68 into main Jun 20, 2026
2 checks passed
piqseu added a commit to piqseu/OpenSteamTool that referenced this pull request Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant