JSPM

@tl3n/steam-api-wrapper

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q22109F
  • License MIT

Steam API wrapper with TypeScript support.

Package Exports

  • @tl3n/steam-api-wrapper
  • @tl3n/steam-api-wrapper/dist/index.js

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 (@tl3n/steam-api-wrapper) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@tl3n/steam-api-wrapper

A simple wrapper for Steam Web API with support of TypeScript types.

Installation

# Using npm
npm install @tl3n/steam-api-wrapper

Getting Started

Before proceeding further, make sure that you have obtained Steam Web API key. More information can be found here.

Let's start with an example. Imagine, that you need to obtain news posts for Team Fortress 2, or your hamster will die tomorrow. Don't panic! It's really easy to do:

import { SteamClient, SteamNewsService } from "@tl3n/steam-api-wrapper";

// Create a new Steam client with your API key.
const steamClient = new SteamClient("YOUR_API_KEY_HERE");

// Create news service with your steamClient.
const newsService = new SteamNewsSerivce(steamClient);

// And now, all we need to do is to call our method.
const news = await newsService.GetNewsForApp({ appid: 440 });

And voilà! Your hamster will live another day.

{
  appnews: {
    appid: 440,
    newsitems: [
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object]
    ],
    count: 3687
  }
}

Documentation

This package provides functionality described here. So, if the following section doesn't supply your needs, feel free to follow the link.

SteamClient

Responsible for communication with Steam API. Remember to pass your API key!

const steamClient = new SteamClient("YOUR_API_KEY");

// Send request to Steam Web API URL with specified params
const response = await steamClient.get<T>("API URL", params);

SteamNewsService

Wrapper for ISteamNews interface.

const newsService = new SteamNewsService(steamClient);

// Get news for specified appid.
const news = await newsService.GetNewsForApp({
  appid: 440,
  count: 3,
  maxlength: 300,
});

SteamUserStatsService

Wrapper for ISteamUserStats interface.

const userStatsService = new SteamUserStatsService(steamClient);

// Get global achievements overview of a specific game in percentages.
const achievementPercentages =
  await userStatsService.GetGlobalAchievementPercentagesForApp({ gameid: 440 });

// Get list of user's achievements for by appid.
const playerAchievements = await userStatsService.GetPlayerAchievements({
  steamid: "76561197972495328",
  appid: 440,
});

// Get list of user's stats by appid.
const userStats = await userStatsService.GetUserStatsForGame({
  steamid: "76561197972495328",
  appid: 440,
});

SteamUserService

Wrapper for ISteamUser interface.

const userService = new SteamUserService(steamClient);

// Get basic profile information for a list of 64-bit Steam IDs.
const playerSummaries = await userService.GetPlayerSummaries({
  steamids: "76561197960435530",
});

// Get a list of user's friends, provided their Steam Community profile is set to "Public".
const friendList = await userService.GetFriendList({
  steamid: "76561197960435530",
  relationship: "friend",
});

SteamPlayerService

Wrapper for ISteamPlayer interface.

const playerService = new SteamPlayerService(steamClient);

// Get a list of games player owns along with some playtime information, if profile is public.
const ownedGames = await playerService.GetOwnedGames({
  steamid: "76561197960434622",
});

// Get a list of games that player has played in the last two weeks.
const recentlyPlayedGames = await playerService.GetRecentlyPlayedGames({
  steamid: "76561197960434622",
});