Client
steamlayer_core.api
The sole public interface for steamlayer-core.
Consumers should only import from this module. Everything below the API boundary is an implementation detail.
Usage
Quick one-shot functions for simple scripts::
game = resolve_game(Path("C:/games/Euro Truck Simulator 2"))
patch_game(game, Path("C:/games/Euro Truck Simulator 2"), vendor=vendor, config_writer=writer)
Stateful client for when you need shared lifecycle management (HTTP session, resolver reuse, progress hooks wired once)::
with SteamLayerClient(vendor=vendor, config_writer=writer) as client:
game = client.resolve(Path("C:/games/Euro Truck Simulator 2"))
result = client.patch(game, Path("C:/games/Euro Truck Simulator 2"))
Classes:
| Name | Description |
|---|---|
SteamLayerClient |
Stateful orchestrator. Manages HTTP session lifecycle, resolver
construction, and exposes |
Functions:
| Name | Description |
|---|---|
resolve_game |
One-shot wrapper around |
patch_game |
One-shot wrapper around |
fetch_dlcs |
One-shot wrapper around |
Design notes
- No
input()orprint()calls here or anywhere reachable from here. - All human-interaction events are delegated to injected handlers.
- Exceptions are always typed (see
steamlayer_core.domain.exceptions). pathlib.Path | stris accepted for all filesystem arguments.SteamLayerClientis the canonical entry point; the module-level functions are thin convenience wrappers that open and close a client for a single call.
SteamLayerClient
A stateful, emulator-agnostic orchestrator for the SteamLayer pipeline.
The client serves as a universal interface for identifying and patching Steam games. By decoupling the patching logic from specific emulator implementations, it can support any Steam-emulator environment (Goldberg, etc.) simply by injecting the appropriate VendorProvider and ConfigWriter.
The client manages the shared lifecycle of dependencies, such as HTTP sessions and resolution engines, ensuring resource efficiency and clean cleanup.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
options
|
SteamlayerOptions | None
|
Configuration for game and DLC resolution logic. |
None
|
allow_network
|
bool
|
If True (default), the client ensures an HTTP session is available for web-based metadata hydration and store searches. |
True
|
vendor
|
VendorProvider | None
|
Provider for emulator binaries and metadata. Required for patching. |
None
|
config_writer
|
ConfigWriter | None
|
Custom logic for writing emulator configuration files. If None, the engine uses its default implementation. |
None
|
on_disambiguation
|
DisambiguationHandler | None
|
Callback for resolving ties between multiple game candidates. |
None
|
on_confirmation
|
ConfirmationHandler | None
|
Callback for verifying low-confidence matches. |
None
|
http_client
|
HTTPClientProtocol | None
|
A custom HTTP client implementation. If provided, this instance
is used regardless of the |
None
|
progress
|
ProgressCallback
|
Hook for reporting operation status (e.g., UI progress bars). |
NULL_PROGRESS
|
Source code in steamlayer_core/api.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | |
fetch_dlcs(appid)
Hydrate DLC metadata for a known AppID.
Results are cached on disk as dlcs_{appid}.json under cache_dir.
On a cache hit the network is never touched. On a miss, the Steam Web
API is queried and the result is written back to disk before returning.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
appid
|
int
|
Steam AppID to look up. |
required |
Returns:
| Type | Description |
|---|---|
dict[int, DLCInfo]
|
Mapping of DLC AppID → |
Source code in steamlayer_core/api.py
is_patched(game_path)
Determine if the specified directory contains an active SteamLayer patch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
game_path
|
Path | str
|
The filesystem path to the game's root directory. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if a valid vault and patch signature are detected. |
Source code in steamlayer_core/api.py
patch(game, game_path)
Apply an emulator patch to the specified game directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
game
|
ResolvedGame
|
Metadata identifying the game and its components. |
required |
game_path
|
Path | str
|
The filesystem path to the game's root directory. |
required |
Returns:
| Type | Description |
|---|---|
PatchResult
|
Summary of the files modified and backups created. |
Source code in steamlayer_core/api.py
resolve(game_path)
Identify a game and hydrate its metadata.
Uses the internal HTTP client if allow_network was set to True during
initialization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
game_path
|
Path | str
|
The filesystem path to the game's root directory. |
required |
Returns:
| Type | Description |
|---|---|
`ResolvedGame`
|
The identified game metadata. |
Source code in steamlayer_core/api.py
unpatch(game_path, *, purge_vault=True)
Revert a patch and restore original Steam binaries from the vault.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
game_path
|
Path | str
|
The filesystem path to the game's root directory. |
required |
purge_vault
|
bool
|
Whether to delete the backup vault after a successful restoration. |
True
|
Returns:
| Type | Description |
|---|---|
`list[pathlib.Path]`
|
A list of files restored to their original locations. |
Source code in steamlayer_core/api.py
fetch_dlcs(appid, *, options=None, allow_network=True, progress=NULL_PROGRESS)
Hydrate DLC metadata for a known AppID.
Convenience wrapper around SteamLayerClient.fetch_dlcs() for
one-shot use. For repeated calls or shared HTTP session lifecycle,
use SteamLayerClient directly.
Results are cached on disk under options.cache_dir (default:
~/.steamlayer/.cache). On a cache hit the network is never
touched. On a miss, the Steam Web API is queried and the result is
written back to disk before returning.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
appid
|
int
|
Steam AppID to look up. |
required |
options
|
SteamlayerOptions | None
|
Resolution configuration. Controls |
None
|
allow_network
|
bool
|
Set to |
True
|
progress
|
ProgressCallback
|
Optional progress hook for surfacing status to a UI. |
NULL_PROGRESS
|
Returns:
| Type | Description |
|---|---|
dict[int, DLCInfo]
|
Mapping of DLC AppID → |
Source code in steamlayer_core/api.py
patch_game(game, game_path, *, vendor, config_writer, progress=NULL_PROGRESS)
Apply an emulator patch and strip Steam DRM from a game directory.
This function orchestrates a generic patching lifecycle: scanning for Steam API DLLs, creating backups in a local vault, running DRM removal on executables, and writing emulator-specific configuration files.
The specific emulator binaries used and the format of the configuration
files are determined by the injected vendor and the config_writer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
game
|
ResolvedGame
|
The |
required |
game_path
|
Path | str
|
Root directory of the game installation to be patched. |
required |
vendor
|
VendorProvider
|
An injected |
required |
config_writer
|
ConfigWriter
|
|
required |
progress
|
ProgressCallback
|
Optional progress hook for UI updates. |
NULL_PROGRESS
|
Returns:
| Type | Description |
|---|---|
PatchResult
|
A summary of the operation, including the vault path and patched targets. |
Raises:
| Type | Description |
|---|---|
PatchError
|
If no Steam API DLLs are found, I/O operations fail, or configuration writing fails. |
VaultError
|
If a backup cannot be created or a vault already exists. |
Source code in steamlayer_core/api.py
resolve_game(game_path, options=None, *, allow_network=True, on_disambiguation=None, on_confirmation=None, progress=NULL_PROGRESS)
Resolve a game directory to a Steam AppID and (optionally) its DLC list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
game_path
|
Path | str
|
Path to the game's root directory. |
required |
options
|
SteamlayerOptions | None
|
Resolution configuration. Defaults to strict mode with network enabled. |
None
|
allow_network
|
bool
|
Whether to allow network access for metadata hydration. |
True
|
on_disambiguation
|
DisambiguationHandler | None
|
Handler for ambiguous matches. If |
None
|
on_confirmation
|
ConfirmationHandler | None
|
Handler for low-confidence matches. If |
None
|
progress
|
ProgressCallback
|
Optional progress hook for UI updates. |
NULL_PROGRESS
|
Returns:
| Type | Description |
|---|---|
ResolvedGame
|
Contains |
Raises:
| Type | Description |
|---|---|
AppIDNotFoundError
|
No candidate could be found. |
AmbiguousMatchError
|
Tie-breaking needed but no |
LowConfidenceError
|
Confirmation needed but no |