Package Exports
- steamgrab
- steamgrab/src/index.ts
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (steamgrab) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Steam Game Scraper (steamgrab)
A TypeScript library for fetching game information from the Steam store. This library provides easy-to-use functions for searching games by name and retrieving detailed game information by Steam App ID.
Features
- Search for games by name and get multiple results
- Fetch detailed game information using Steam App ID
- TypeScript support with full type definitions
- Modern async/await API
- Error handling with custom error types
- Compatible with Node.js 16+ and modern browsers
Installation
npm install steamgrab
# or
yarn add steamgrab
# or
bun add steamgrabThis package is distributed as TypeScript source files rather than compiled JavaScript, which provides several benefits:
- Better type information directly from the source
- Easier debugging with source maps
- Ability to adapt the code to your TypeScript configuration
Note that you'll need TypeScript ≥4.5.0 in your project to use this package.
Usage
Searching for games
import { Steam } from 'steamgrab';
async function searchGames() {
try {
// Get up to 10 games matching "Portal"
const games = await Steam.getGames('Portal');
console.log(`Found ${games.length} games:`);
games.forEach(game => {
console.log(`${game.title} (${game.appid}) - ${game.price}`);
});
} catch (error) {
if (error instanceof Steam.SteamScraperError) {
console.error('Steam scraper error:', error.message);
} else {
console.error('Error:', error);
}
}
}
searchGames();Getting game details by App ID
import { Steam } from 'steamgrab';
async function getGameDetails(appId: number) {
try {
const game = await Steam.getGameInfoById(appId);
if (game) {
console.log(`Title: ${game.title}`);
console.log(`Release Date: ${game.release}`);
console.log(`Price: ${game.price}`);
console.log(`Image URL: ${game.image}`);
} else {
console.log(`No game found with AppID: ${appId}`);
}
} catch (error) {
if (error instanceof Steam.SteamScraperError) {
console.error('Steam API error:', error.message);
} else {
console.error('Error:', error);
}
}
}
// Get details for Portal 2 (App ID: 620)
getGameDetails(620);API Reference
getGames(query: string, limit?: number): Promise<GameInfo[]>
Searches for games by name and returns an array of game information.
query: The game name to search forlimit: Maximum number of results to return (default: 10)
getFirstGameInfo(query: string): Promise<GameInfo | null>
Fetches the first game information result by searching for a game name.
query: The game name to search for
Note: This function is deprecated. Use getGames(query, 1) instead.
getGameInfoById(appId: string | number): Promise<GameInfo | null>
Fetches game information directly using the Steam API with a game ID.
appId: The Steam app ID of the game
GameInfo Interface
interface GameInfo {
title: string;
release: string;
price: string;
image: string | undefined;
appid: number | undefined;
}Development
# Clone the repository
git clone https://github.com/RedWilly/steamgrab.git
cd steamgrab
# Install dependencies
npm install
# Build the library
npm run build
# Run tests
npm testLicense
MIT