### Get Steam Installation Path using JavaScript Source: https://github.com/osztenkurden/steam-game-path/blob/master/README.md This JavaScript example shows how to use the 'getSteamPath' function from the 'steam-game-path' module. This function returns a Promise that resolves to a string representing the Steam installation directory, or null if it cannot be found. ```javascript import { getSteamPath } from 'steam-game-path'; const steamPath = await getSteamPath(); // Example usage within an async function ``` -------------------------------- ### Path Object Structure Example Source: https://github.com/osztenkurden/steam-game-path/blob/master/README.md This example illustrates the structure of the 'Path Object' returned by the 'getGamePath' function. It includes the game's installation path, name, and an optional executable Promise, as well as the Steam installation path and a list of library folders. ```javascript { game: { path: 'C:\\SteamLibrary\\steamapps\\common\\Counter-Strike Global Offensive', name: 'Counter-Strike: Global Offensive', executable?: Promise }, steam: { path: 'E:\\Program Files (x86)\\Steam', libraries: [ 'C:\\SteamLibrary\\steamapps', 'D:\\SteamLibrary\\steamapps', 'E:\\Program Files (x86)\\Steam\\steamapps' ] } } ``` -------------------------------- ### Get Steam Game Path and Executable Info (JavaScript) Source: https://context7.com/osztenkurden/steam-game-path/llms.txt Retrieves installation paths for a specific Steam game using its App ID. Optionally, it can find the game's executable configuration via Steam's API. This function returns an object containing game and Steam installation details. If the `findExecutable` flag is true, it returns a Promise that resolves with executable information. ```javascript import { getGamePath } from 'steam-game-path'; // Basic usage - Find Counter-Strike: Global Offensive (App ID 730) const gameData = getGamePath(730); console.log(gameData); // Output: // { // game: { // path: 'C:\\SteamLibrary\\steamapps\\common\\Counter-Strike Global Offensive', // name: 'Counter-Strike: Global Offensive' // }, // steam: { // path: 'E:\\Program Files (x86)\\Steam', // libraries: [ // 'C:\\SteamLibrary\\steamapps', // 'E:\\Program Files (x86)\\Steam\\steamapps' // ] // } // } // With executable information (returns Promise) const gameDataWithExec = getGamePath(730, true); if (gameDataWithExec && gameDataWithExec.game) { console.log(`Game found at: ${gameDataWithExec.game.path}`); // Await the executable promise gameDataWithExec.game.executable.then(execInfo => { console.log('Launch configurations:', execInfo); }).catch(err => { console.error('Failed to get executable info:', err); }); } // Handle game not found const missingGame = getGamePath(999999); if (missingGame && !missingGame.game) { console.log('Game not installed'); console.log('Steam libraries:', missingGame.steam.libraries); } ``` -------------------------------- ### TypeScript: Get Steam Game and Library Paths Source: https://context7.com/osztenkurden/steam-game-path/llms.txt This snippet demonstrates how to use the steam-game-path library with TypeScript for type-safe retrieval of game paths, Steam installation paths, and Steam library locations. It defines interfaces for game and Steam path structures and shows example usage for finding game details, the Steam installation directory, and enumerating library folders. ```typescript import { getGamePath, getSteamPath, getSteamLibraries } from 'steam-game-path'; interface GamePath { path: string; name: string; executable?: Promise; } interface SteamPath { game: GamePath | null; steam: { path: string; libraries: string[]; }; } // Type-safe usage const result: SteamPath | null = getGamePath(730); if (result?.game) { const gamePath: string = result.game.path; const gameName: string = result.game.name; console.log(`${gameName} is at ${gamePath}`); } // Type-safe Steam path retrieval const steamInstall: string | null = getSteamPath(); // Type-safe library enumeration if (steamInstall) { const libs: string[] | null = getSteamLibraries(steamInstall); if (libs) { libs.forEach((lib: string) => console.log(lib)); } } ``` -------------------------------- ### Get Steam Library Folders (JavaScript) Source: https://context7.com/osztenkurden/steam-game-path/llms.txt Parses Steam's library configuration file to return an array of all Steam library folder paths. It requires the Steam installation path obtained from `getSteamPath()`. Returns null if the configuration file is missing or unparseable. Includes an example of checking for installed games within each library. ```javascript import { getSteamPath, getSteamLibraries } from 'steam-game-path'; const steamPath = getSteamPath(); if (steamPath) { const libraries = getSteamLibraries(steamPath); if (libraries) { console.log('Steam library folders:'); libraries.forEach((libPath, index) => { console.log(`${index + 1}. ${libPath}`); }); // Output: // 1. C:\\SteamLibrary\\steamapps // 2. D:\\Games\\Steam\\steamapps // 3. E:\\Program Files (x86)\\Steam\\steamapps // Check each library for available space const fs = require('fs'); libraries.forEach(lib => { try { const files = fs.readdirSync(lib); const manifests = files.filter(f => f.startsWith('appmanifest_')); console.log(`${lib}: ${manifests.length} games installed`); } catch (err) { console.error(`Cannot read ${lib}:`, err.message); } }); } else { console.log('No library folders found or error parsing configuration'); } } else { console.error('Steam not found'); } ``` -------------------------------- ### Install steam-game-path using npm Source: https://github.com/osztenkurden/steam-game-path/blob/master/README.md This command installs the 'steam-game-path' npm package. It is a prerequisite for using the module in your Node.js project. ```bash npm install steam-game-path ``` -------------------------------- ### Get Game Path using JavaScript Source: https://github.com/osztenkurden/steam-game-path/blob/master/README.md This JavaScript example demonstrates how to import and use the 'getGamePath' function from the 'steam-game-path' module. It takes a game ID (e.g., 730 for CS:GO) and returns a Promise that resolves to a Path Object containing game and Steam installation details. ```javascript import { getGamePath } from 'steam-game-path'; const data = getGamePath(730); ``` -------------------------------- ### Get Steam Installation Path (JavaScript) Source: https://context7.com/osztenkurden/steam-game-path/llms.txt Retrieves the installation directory path for Steam on the current operating system. It checks the Windows registry, standard Linux paths (including Flatpak), and macOS Application Support directories. Returns null if Steam is not found. This can be used in conjunction with file system operations. ```javascript import { getSteamPath } from 'steam-game-path'; import fs from 'fs'; import path from 'path'; const steamPath = getSteamPath(); if (steamPath) { console.log(`Steam is installed at: ${steamPath}`); // Windows: "E:\\Program Files (x86)\\Steam" // Linux: "/home/user/.steam/root" // macOS: "/Users/username/Library/Application Support/Steam" // Use in conjunction with file operations const configPath = path.join(steamPath, 'config', 'config.vdf'); if (fs.existsSync(configPath)) { console.log('Steam config found'); } } else { console.error('Steam installation not found'); process.exit(1); } ``` -------------------------------- ### getSteamPath() Source: https://context7.com/osztenkurden/steam-game-path/llms.txt Returns the Steam installation directory path for the current operating system. ```APIDOC ## GET /steamPath ### Description Returns the Steam installation directory path for the current operating system, or null if Steam is not found. This function checks the Windows registry on Windows, standard home directory locations on Linux, and the Application Support directory on macOS. ### Method GET ### Endpoint /steamPath ### Parameters None ### Request Example (No request body needed for this endpoint) ### Response #### Success Response (200) - **steamPath** (string | null) - The absolute path to the Steam installation directory, or null if not found. ``` -------------------------------- ### getGamePath(gameId, findExecutable) Source: https://context7.com/osztenkurden/steam-game-path/llms.txt Retrieves installation paths for a specific Steam game using its App ID. It can also optionally find the game's executable information. ```APIDOC ## GET /gamePath ### Description Retrieves installation paths for a specific Steam game identified by its App ID, along with Steam's installation path and all library folders. The optional `findExecutable` parameter triggers an asynchronous lookup of the game's executable configuration through Steam's API. ### Method GET ### Endpoint /gamePath ### Parameters #### Query Parameters - **gameId** (number) - Required - The App ID of the Steam game. - **findExecutable** (boolean) - Optional - If true, attempts to find the game's executable configuration. ### Request Example ```json { "gameId": 730, "findExecutable": true } ``` ### Response #### Success Response (200) - **game** (object) - Information about the game. - **path** (string) - The installation path of the game. - **name** (string) - The name of the game. - **executable** (Promise) - A promise that resolves with launch configurations if `findExecutable` is true. - **steam** (object) - Information about the Steam installation. - **path** (string) - The installation path of Steam. - **libraries** (array) - An array of paths to Steam library folders. ``` -------------------------------- ### getSteamLibraries(steamPath) Source: https://context7.com/osztenkurden/steam-game-path/llms.txt Parses Steam's library folders configuration file and returns an array of paths to all Steam library locations. ```APIDOC ## GET /steamLibraries ### Description Parses Steam's library folders configuration file and returns an array of paths to all Steam library locations where games can be installed. Returns null if the configuration file doesn't exist or cannot be parsed. ### Method GET ### Endpoint /steamLibraries ### Parameters #### Query Parameters - **steamPath** (string) - Required - The path to the Steam installation directory obtained from `getSteamPath()`. ### Request Example ```json { "steamPath": "E:\\Program Files (x86)\\Steam" } ``` ### Response #### Success Response (200) - **libraries** (array | null) - An array of strings, where each string is a path to a Steam library folder, or null if libraries cannot be determined. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.