@steamsets/client-ts
v0.34.8
Published
<div align="left"> <a href="https://www.speakeasy.com/?utm_source=<no value>&utm_campaign=go"><img src="https://custom-icon-badges.demolab.com/badge/-Built%20By%20Speakeasy-212015?style=for-the-badge&logoColor=FBE331&logo=speakeasy&labelColor=545454"
Readme
openapi
SDK Installation
The SDK can be installed with either npm, pnpm, bun or yarn package managers.
NPM
npm add @steamsets/client-tsPNPM
pnpm add @steamsets/client-tsBun
bun add @steamsets/client-tsYarn
yarn add @steamsets/client-ts zod
# Note that Yarn does not install peer dependencies automatically. You will need
# to install zod as shown above.SDK Example Usage
Example
import { SteamSets } from "@steamsets/client-ts";
const steamSets = new SteamSets({
token: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await steamSets.account.bookmarkBadge({
badgeId: "bdg_123",
bookmark: true,
});
console.log(result);
}
run();
Available Resources and Operations
Account
- bookmarkBadge - Bookmark or unbookmark a badge
- compareBadges - Compare badge collections between accounts
- createConnection - Create OAuth or domain connection
- createDeveloperApp - Create developer application
- deleteConnection - Delete OAuth or domain connection
- deleteDeveloperApp - Delete developer application
- deleteImages - Delete uploaded images
- deleteSession - Delete user session
- accountFindFriendPath - Find up to N shortest friend paths between two accounts
- accountGetBadgeHeatmap - Get monthly badge crafting counts for an account
- getBadgeStats - Get account badge statistics
- getDataPoints - Get account data points for charts
- getInfo - Get account profile information
- getMeta - Get account metadata
- getSession - Get user session information
- getSettings - Get account settings
- accountGetTrending - Top accounts by unique viewers in a window
- getViewStats - Get profile view counts (24h/7d/30d × unique/total) for an account
- listApps - List account owned apps
- listBadgeBookmarks - List bookmarked badges
- listBadges - List account badges
- listFriends - List account friends
- listImages - List uploaded images
- listInventorySets - List inventory sets
- listLeaderboardHistory - Get leaderboard history
- listOwnedBadges - List owned badges
- accountListOwnedGroups - List groups owned by account
- login - Login with Steam
- logout - Logout from session
- queueUpdate - Queue account update
- reconnectConnection - Reconnect OAuth connection
- refreshInventory - Refresh inventory
- refreshSession - Refresh session token
- sendEmailVerification - Send email verification
- subscribe - Server-sent-events stream of per-account updates (queue status, view ticks).
- subscribeEmail - Subscribe to email notifications
- updateConnection - Update OAuth connection
- updateDeveloperApp - Update developer application
- updateImages - Update account images
- updateRole - Update account role
- updateSettings - Update account settings
- updateVanity - Update account vanity URL
- uploadImages - Upload images
- verifyConnection - Verify OAuth connection
- verifyEmail - Verify email address
Activity
- listAccountFeed - List the activity feed for a single account (profile timeline)
- listGlobalFeed - List the global activity feed
- streamGlobalFeed - Live server-sent-events stream of the global activity feed
Admin
- cmsArchive - Archive a CMS document so it stops appearing in public reads (versions retained)
- cmsCreate - Create a new CMS document with an initial draft version
- cmsDelete - Permanently delete a CMS document and all its versions
- cmsList - List CMS documents (drafts + published) for editor
- cmsListAssets - List recently uploaded CMS images
- cmsPreviewToken - Issue a short-lived preview token for a specific document version
- cmsPublish - Publish a CMS document version (also used for rollback by passing an older version_id)
- cmsReorder - Batch-update parent_id / sort_order for CMS documents (used after drag-drop)
- cmsUpdateDraft - Append a new draft version to an existing CMS document
- cmsUploadImage - Upload a CMS image (partner logos, page hero, etc.) to S3/MinIO
- cmsVersions - List the version history of a CMS document (newest first)
- getAccount - Get account for admin
- removeVanity - Remove vanity URL
- updateResources - Update account resources
- adminUpdateRoleOverride - Set or remove a tier role override for an account
- updateRoles - Update account roles
Admin.Donations
- createCurrency - Add a currency to the donation whitelist
- deleteCurrency - Soft-delete a donation currency (sets active=0)
- listCurrencies - List every donation currency (active + soft-deleted) for admin management
- updateCurrency - Update a donation currency (treasury, decimals, etc.); chain+contract are immutable
Admin.Maintenance
- create - Create a maintenance event
- delete - Hard-delete a maintenance event
- list - Admin: list every maintenance event including disabled and scheduled
- update - Update a maintenance event (any subset of fields)
Analytics
- getBivariate - Bucket by X, aggregate Y, within a scope
- getDistribution - Histogram + summary stats for a metric in a scope
- getInequality - Lorenz curve + Gini + top-X%-own-Y% headlines for one metric in a scope
- getMetricByScope - One metric aggregated per country (or region) — worldmap source
- getMyPercentiles - Per-metric percentile rank for the logged-in user in the chosen scope
- getTrend - Daily quantiles over a window for a metric in a scope
- listMetrics - List every analytics domain, metric, and scope the data-library can serve
- trackEvent - Track a frontend-only analytics event (profile view, search). Frontend API key + logged-in users only.
Apps
- listBadges - List app badges
Badge
- streamPricing - Server-sent-events stream of badge pricing ticks. Forwards every tick — filter client-side.
- search - Search badges
- suggestTags - Suggest badge tag
Badges
Cms
- list - List published CMS documents of a given type
Donations
- claim - Claim a crypto donation by tx hash + signed message
- getAddresses - Get the treasury addresses to send crypto donations to
- listSupportedCurrencies - List cryptocurrencies accepted for donations (DB-backed; admin-managed)
Item
- findOwners - Find owners of one or more trading cards or booster packs. Friend paths from the requester are included for logged-in callers.
Leaderboard
- getAccount - Get account leaderboard
- getAccountsMeta - Get accounts leaderboard metadata
- getBucketLeaders - Get the top account in each value bucket
- getChanges - Top movers in a windowed delta on a leaderboard
- getGroup - Get group leaderboard
- getGroupsMeta - Get groups leaderboard metadata
- getLowestRanks - Get lowest ranked accounts
- previewAccountRank - Preview account rank
Leaderboards
- list - List leaderboard badges
Location
- get - List available locations
Maintenance
- list - List currently active maintenance events
Search
- searchGetTrending - Top search queries in a window, by unique searcher count
Site
- subscribe - Server-sent-events stream of site-wide broadcasts (maintenance, announcements, etc).
Staff
- list - List staff members
Stats
- get - Get platform statistics
- subscribe - Server-sent-events stream of platform stats. Emits a snapshot, then deltas as the queues commit them.
Server-sent event streaming
Server-sent events are used to stream content from certain
operations. These operations will expose the stream as an async iterable that
can be consumed using a for await...of loop. The loop will
terminate when the server no longer has any events to send and closes the
underlying connection.
import { SteamSets } from "@steamsets/client-ts";
const steamSets = new SteamSets({
token: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await steamSets.account.subscribe({
accountId: 442779,
});
if (result.serverSentEvents == null) {
throw new Error("failed to create stream: received null value");
}
for await (const event of result.serverSentEvents) {
console.log(event);
}
}
run();
Pagination
Some of the endpoints in this SDK support pagination. To use pagination, you
make your SDK calls as usual, but the returned response object will also be an
async iterable that can be consumed using the for await...of
syntax.
Here's an example of one such pagination call:
import { SteamSets } from "@steamsets/client-ts";
const steamSets = new SteamSets({
token: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await steamSets.admin.cmsListAssets({});
for await (const page of result) {
console.log(page);
}
}
run();
Retries
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
import { SteamSets } from "@steamsets/client-ts";
const steamSets = new SteamSets({
token: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await steamSets.account.bookmarkBadge({
badgeId: "bdg_123",
bookmark: true,
}, {
retries: {
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
},
});
console.log(result);
}
run();
If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
import { SteamSets } from "@steamsets/client-ts";
const steamSets = new SteamSets({
retryConfig: {
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
},
token: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await steamSets.account.bookmarkBadge({
badgeId: "bdg_123",
bookmark: true,
});
console.log(result);
}
run();
Error Handling
SteamSetsError is the base class for all HTTP error responses. It has the following properties:
| Property | Type | Description |
| ------------------------- | ---------- | --------------------------------------------------------------------------------------- |
| error.message | string | Error message |
| error.httpMeta.response | Response | HTTP response. Access to headers and more. |
| error.httpMeta.request | Request | HTTP request. Access to headers and more. |
| error.data$ | | Optional. Some errors may contain structured data. See Error Classes. |
Example
import { SteamSets } from "@steamsets/client-ts";
import * as errors from "@steamsets/client-ts/models/errors";
const steamSets = new SteamSets({
token: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
try {
const result = await steamSets.account.bookmarkBadge({
badgeId: "bdg_123",
bookmark: true,
});
console.log(result);
} catch (error) {
// The base class for HTTP error responses
if (error instanceof errors.SteamSetsError) {
console.log(error.message);
console.log(error.httpMeta.response.status);
console.log(error.httpMeta.response.headers);
console.log(error.httpMeta.request);
// Depending on the method different errors may be thrown
if (error instanceof errors.ErrorModel) {
console.log(error.data$.dollarSchema); // string
console.log(error.data$.detail); // string
console.log(error.data$.errors); // ErrorDetail[]
console.log(error.data$.instance); // string
console.log(error.data$.status); // number
}
}
}
}
run();
Error Classes
Primary errors:
SteamSetsError: The base class for HTTP error responses.ErrorModel: *
Network errors:
ConnectionError: HTTP client was unable to make a request to a server.RequestTimeoutError: HTTP request timed out due to an AbortSignal signal.RequestAbortedError: HTTP request was aborted by the client.InvalidRequestError: Any input used to create a request is invalid.UnexpectedClientError: Unrecognised or unexpected error.
Inherit from SteamSetsError:
ResponseValidationError: Type mismatch between the data returned from the server and the structure expected by the SDK. Seeerror.rawValuefor the raw value anderror.pretty()for a nicely formatted multi-line string.
* Check the method documentation to see if the error is applicable.
Server Selection
Select Server by Index
You can override the default server globally by passing a server index to the serverIdx: number optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:
| # | Server | Description |
| --- | --------------------------- | ----------- |
| 0 | https://api.steamsets.com | |
| 1 | http://localhost:7388 | |
Example
import { SteamSets } from "@steamsets/client-ts";
const steamSets = new SteamSets({
serverIdx: 0,
token: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await steamSets.account.bookmarkBadge({
badgeId: "bdg_123",
bookmark: true,
});
console.log(result);
}
run();
Override Server URL Per-Client
The default server can also be overridden globally by passing a URL to the serverURL: string optional parameter when initializing the SDK client instance. For example:
import { SteamSets } from "@steamsets/client-ts";
const steamSets = new SteamSets({
serverURL: "http://localhost:7388",
token: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await steamSets.account.bookmarkBadge({
badgeId: "bdg_123",
bookmark: true,
});
console.log(result);
}
run();
Custom HTTP Client
The TypeScript SDK makes API calls using an HTTPClient that wraps the native
Fetch API. This
client is a thin wrapper around fetch and provides the ability to attach hooks
around the request lifecycle that can be used to modify the request or handle
errors and response.
The HTTPClient constructor takes an optional fetcher argument that can be
used to integrate a third-party HTTP client or when writing tests to mock out
the HTTP client and feed in fixtures.
The following example shows how to:
- route requests through a proxy server using undici's ProxyAgent
- use the
"beforeRequest"hook to add a custom header and a timeout to requests - use the
"requestError"hook to log errors
import { SteamSets } from "@steamsets/client-ts";
import { ProxyAgent } from "undici";
import { HTTPClient } from "@steamsets/client-ts/lib/http";
const dispatcher = new ProxyAgent("http://proxy.example.com:8080");
const httpClient = new HTTPClient({
// 'fetcher' takes a function that has the same signature as native 'fetch'.
fetcher: (input, init) =>
// 'dispatcher' is specific to undici and not part of the standard Fetch API.
fetch(input, { ...init, dispatcher } as RequestInit),
});
httpClient.addHook("beforeRequest", (request) => {
const nextRequest = new Request(request, {
signal: request.signal || AbortSignal.timeout(5000)
});
nextRequest.headers.set("x-custom-header", "custom value");
return nextRequest;
});
httpClient.addHook("requestError", (error, request) => {
console.group("Request Error");
console.log("Reason:", `${error}`);
console.log("Endpoint:", `${request.method} ${request.url}`);
console.groupEnd();
});
const sdk = new SteamSets({ httpClient: httpClient });Authentication
Per-Client Security Schemes
This SDK supports the following security scheme globally:
| Name | Type | Scheme |
| ------- | ---- | ----------- |
| token | http | HTTP Bearer |
To authenticate with the API the token parameter must be set when initializing the SDK client instance. For example:
import { SteamSets } from "@steamsets/client-ts";
const steamSets = new SteamSets({
token: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await steamSets.account.bookmarkBadge({
badgeId: "bdg_123",
bookmark: true,
});
console.log(result);
}
run();
Special Types
SDK Installation
The SDK can be installed with either npm, pnpm, bun or yarn package managers.
NPM
npm add @steamsets/client-tsPNPM
pnpm add @steamsets/client-tsBun
bun add @steamsets/client-tsYarn
yarn add @steamsets/client-tsRequirements
For supported JavaScript runtimes, please consult RUNTIMES.md.
Standalone functions
All the methods listed above are available as standalone functions. These functions are ideal for use in applications running in the browser, serverless runtimes or other environments where application bundle size is a primary concern. When using a bundler to build your application, all unused functionality will be either excluded from the final bundle or tree-shaken away.
To read more about standalone functions, check FUNCTIONS.md.
accountAccountFindFriendPath- Find up to N shortest friend paths between two accountsaccountAccountGetBadgeHeatmap- Get monthly badge crafting counts for an accountaccountAccountGetTrending- Top accounts by unique viewers in a windowaccountAccountListOwnedGroups- List groups owned by accountaccountBookmarkBadge- Bookmark or unbookmark a badgeaccountCompareBadges- Compare badge collections between accountsaccountCreateConnection- Create OAuth or domain connectionaccountCreateDeveloperApp- Create developer applicationaccountDeleteConnection- Delete OAuth or domain connectionaccountDeleteDeveloperApp- Delete developer applicationaccountDeleteImages- Delete uploaded imagesaccountDeleteSession- Delete user sessionaccountGetBadgeStats- Get account badge statisticsaccountGetDataPoints- Get account data points for chartsaccountGetInfo- Get account profile informationaccountGetMeta- Get account metadataaccountGetSession- Get user session informationaccountGetSettings- Get account settingsaccountGetViewStats- Get profile view counts (24h/7d/30d × unique/total) for an accountaccountListApps- List account owned appsaccountListBadgeBookmarks- List bookmarked badgesaccountListBadges- List account badgesaccountListFriends- List account friendsaccountListImages- List uploaded imagesaccountListInventorySets- List inventory setsaccountListLeaderboardHistory- Get leaderboard historyaccountListOwnedBadges- List owned badgesaccountLogin- Login with SteamaccountLogout- Logout from sessionaccountQueueUpdate- Queue account updateaccountReconnectConnection- Reconnect OAuth connectionaccountRefreshInventory- Refresh inventoryaccountRefreshSession- Refresh session tokenaccountSendEmailVerification- Send email verificationaccountSubscribe- Server-sent-events stream of per-account updates (queue status, view ticks).accountSubscribeEmail- Subscribe to email notificationsaccountUpdateConnection- Update OAuth connectionaccountUpdateDeveloperApp- Update developer applicationaccountUpdateImages- Update account imagesaccountUpdateRole- Update account roleaccountUpdateSettings- Update account settingsaccountUpdateVanity- Update account vanity URLaccountUploadImages- Upload imagesaccountVerifyConnection- Verify OAuth connectionaccountVerifyEmail- Verify email addressactivityListAccountFeed- List the activity feed for a single account (profile timeline)activityListGlobalFeed- List the global activity feedactivityStreamGlobalFeed- Live server-sent-events stream of the global activity feedadminAdminUpdateRoleOverride- Set or remove a tier role override for an accountadminCmsArchive- Archive a CMS document so it stops appearing in public reads (versions retained)adminCmsCreate- Create a new CMS document with an initial draft versionadminCmsDelete- Permanently delete a CMS document and all its versionsadminCmsList- List CMS documents (drafts + published) for editoradminCmsListAssets- List recently uploaded CMS imagesadminCmsPreviewToken- Issue a short-lived preview token for a specific document versionadminCmsPublish- Publish a CMS document version (also used for rollback by passing an older version_id)adminCmsReorder- Batch-update parent_id / sort_order for CMS documents (used after drag-drop)adminCmsUpdateDraft- Append a new draft version to an existing CMS documentadminCmsUploadImage- Upload a CMS image (partner logos, page hero, etc.) to S3/MinIOadminCmsVersions- List the version history of a CMS document (newest first)adminDonationsCreateCurrency- Add a currency to the donation whitelistadminDonationsDeleteCurrency- Soft-delete a donation currency (sets active=0)adminDonationsListCurrencies- List every donation currency (active + soft-deleted) for admin managementadminDonationsUpdateCurrency- Update a donation currency (treasury, decimals, etc.); chain+contract are immutableadminGetAccount- Get account for adminadminMaintenanceCreate- Create a maintenance eventadminMaintenanceDelete- Hard-delete a maintenance eventadminMaintenanceList- Admin: list every maintenance event including disabled and scheduledadminMaintenanceUpdate- Update a maintenance event (any subset of fields)adminRemoveVanity- Remove vanity URLadminUpdateResources- Update account resourcesadminUpdateRoles- Update account rolesanalyticsGetBivariate- Bucket by X, aggregate Y, within a scopeanalyticsGetDistribution- Histogram + summary stats for a metric in a scopeanalyticsGetInequality- Lorenz curve + Gini + top-X%-own-Y% headlines for one metric in a scopeanalyticsGetMetricByScope- One metric aggregated per country (or region) — worldmap sourceanalyticsGetMyPercentiles- Per-metric percentile rank for the logged-in user in the chosen scopeanalyticsGetTrend- Daily quantiles over a window for a metric in a scopeanalyticsListMetrics- List every analytics domain, metric, and scope the data-library can serveanalyticsTrackEvent- Track a frontend-only analytics event (profile view, search). Frontend API key + logged-in users only.appsListBadges- List app badgesbadgeSearch- Search badgesbadgesListTags- List badge tagsbadgesTag- Tag a badgebadgeStreamPricing- Server-sent-events stream of badge pricing ticks. Forwards every tick — filter client-side.badgeSuggestTags- Suggest badge tagcmsList- List published CMS documents of a given typedonationsClaim- Claim a crypto donation by tx hash + signed messagedonationsGetAddresses- Get the treasury addresses to send crypto donations todonationsListSupportedCurrencies- List cryptocurrencies accepted for donations (DB-backed; admin-managed)itemFindOwners- Find owners of one or more trading cards or booster packs. Friend paths from the requester are included for logged-in callers.leaderboardGetAccount- Get account leaderboardleaderboardGetAccountsMeta- Get accounts leaderboard metadataleaderboardGetBucketLeaders- Get the top account in each value bucketleaderboardGetChanges- Top movers in a windowed delta on a leaderboardleaderboardGetGroup- Get group leaderboardleaderboardGetGroupsMeta- Get groups leaderboard metadataleaderboardGetLowestRanks- Get lowest ranked accountsleaderboardPreviewAccountRank- Preview account rankleaderboardsList- List leaderboard badgeslocationGet- List available locationsmaintenanceList- List currently active maintenance eventssearchSearchGetTrending- Top search queries in a window, by unique searcher countsiteSubscribe- Server-sent-events stream of site-wide broadcasts (maintenance, announcements, etc).staffList- List staff membersstatsGet- Get platform statisticsstatsSubscribe- Server-sent-events stream of platform stats. Emits a snapshot, then deltas as the queues commit them.
Debugging
You can setup your SDK to emit debug logs for SDK requests and responses.
You can pass a logger that matches console's interface as an SDK option.
[!WARNING] Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production.
import { SteamSets } from "@steamsets/client-ts";
const sdk = new SteamSets({ debugLogger: console });Summary
Table of Contents
Development
Maturity
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
Contributions
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
