A simple .NET 10 library for retrieving Steam application data with automatic pagination.
- Automatic pagination (default 50,000 results per page)
- Async streaming with
IAsyncEnumerable<SteamApp> - File and stream output options
- Progress/error reporting via
IMessageSink - Minimal memory footprint with streaming mode
- Standalone CLI tool included
./build.ps1This produces:
publish/- Library DLL and CLI tool
The CLI source is generated at build time in .cli-build/ (excluded from solution/git) and cleaned up after compilation.
./build.ps1 -SkipCli # Library only, no CLI# With API key argument (outputs to app directory)
steamapps your-api-key
# With custom output path
steamapps your-api-key C:\output\steam-apps.json
# Using environment variable
set STEAM_API_KEY=your-api-key
steamapps- Go to https://steamcommunity.com/dev/apikey
- Log in with your Steam account
- Register for a key (free, requires Steam account)
using AppIdStream;
// Create client with your Web API key
using var client = new SteamAppIdClient("your-api-key");
// Stream all apps
await foreach (var app in client.GetAllAppsAsync())
{
Console.WriteLine($"{app.AppId}: {app.Name}");
}Iterate through all Steam apps with automatic pagination:
using var client = new SteamAppIdClient("your-api-key");
await foreach (var app in client.GetAllAppsAsync())
{
// Process each app as it arrives
Console.WriteLine($"{app.AppId}: {app.Name}");
}Save all apps as a JSON file:
using var client = new SteamAppIdClient("your-api-key");
await client.WriteToFileAsync("steam-apps.json");For large datasets, stream directly to a file without buffering:
using var client = new SteamAppIdClient("your-api-key");
await using var file = File.Create("steam-apps.json");
await client.StreamToAsync(file);Monitor progress using the built-in console sink:
using var client = new SteamAppIdClient("your-api-key");
await client.WriteToFileAsync(
"steam-apps.json",
messageSink: new ConsoleMessageSink()
);
// Output:
// Page 1: Retrieved 50000 apps (Total: 50000)
// Page 2: Retrieved 50000 apps (Total: 100000)
// Complete: 150000 apps retrieved across 3 pagesImplement IMessageSink for custom logging:
public class MyLogger : IMessageSink
{
public void OnProgress(int pageNumber, int appsRetrieved, int totalApps)
=> Log.Info($"Page {pageNumber}: {totalApps} total");
public void OnError(string message, Exception? ex)
=> Log.Error(ex, message);
public void OnComplete(int totalApps, int totalPages)
=> Log.Info($"Done: {totalApps} apps");
}
// Usage
using var client = new SteamAppIdClient("your-api-key");
await client.WriteToFileAsync("apps.json", messageSink: new MyLogger());Adjust the number of results per API call:
using var client = new SteamAppIdClient("your-api-key");
// Smaller pages (useful for testing or rate limiting)
await foreach (var app in client.GetAllAppsAsync(pageSize: 10_000))
{
Console.WriteLine(app.Name);
}Cancel long-running operations:
using var cts = new CancellationTokenSource(TimeSpan.FromMinutes(5));
using var client = new SteamAppIdClient("your-api-key");
try
{
await client.WriteToFileAsync(
"steam-apps.json",
cancellationToken: cts.Token
);
}
catch (OperationCanceledException)
{
Console.WriteLine("Operation timed out");
}Provide your own HttpClient for custom configuration:
var httpClient = new HttpClient
{
Timeout = TimeSpan.FromMinutes(2)
};
using var client = new SteamAppIdClient("your-api-key", httpClient);
await client.WriteToFileAsync("apps.json");| Method | Description |
|---|---|
GetAllAppsAsync() |
Streams all apps as IAsyncEnumerable<SteamApp> |
WriteToFileAsync() |
Writes all apps as JSON to a file |
WriteToStreamAsync() |
Writes all apps as JSON to a stream (buffered) |
StreamToAsync() |
Streams JSON directly to output (low memory) |
| Property | Type | Description |
|---|---|---|
AppId |
uint |
Steam application ID |
Name |
string |
Application name |
LastModified |
long |
Last modification timestamp |
PriceChangeNumber |
long |
Price change tracking number |
| Method | Description |
|---|---|
OnProgress() |
Called after each page is retrieved |
OnError() |
Called when an error occurs |
OnComplete() |
Called when all pages are retrieved |
- .NET 10+
- Steam Web API key (free from https://steamcommunity.com/dev/apikey)
MIT