JSPM

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

Steam API wrapper created with typescript

Package Exports

  • type-steamapi

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 (type-steamapi) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Typescript Steam API

GitHub npm

Installation

npm install type-steamapi

or if you are using yarn

yarn add type-steamapi

Typescript

If you are using typescript, you don't need to install any type definitions, since this package is created with typescript

Usage

API key

Once installed, you would need to get Steam API key from Steam Developer Platform

Creating an instance

After receiving an API key, you would need to create an instance of SteamAPI class, imported as a default from package.

WARNING: You should never pass your API key directly as a string! Use environmental variables instead!

import SteamAPI from 'type-steamapi';

const steam = new SteamAPI({
    apiKey: 'YOUR_API_KEY',
    cache: {
      enabled:  true,
      expiresIn:  1000  *  60  *  5  // 5 min
    }
});

By default cache is enabled and expires in 5 minutes. However, if you want to overwrite this behaviour, you can add cache property to configuration object.

Examples

Now you can call methods on SteamAPI instance. Lets try a few things.

Fetching user ID

const steamid = await steam.resolve('https://steamcommunity.com/id/tekkenthuuug/');

console.log(steamid);

// Output: 76561198129961822

Fetching user owned games

const  userOwnedGames  =  await steam.getUserOwnedGames(steamid);

console.log(userOwnedGames);

// Output:
// [OwnedGame {
//    name: 'Broken Dreams',
//    appId: 444480,
//    playtimeTotal: 222,
//    playtime2weeks: 0,
//    imgIconUrl: 'https://steamcdn-a.akamaihd.net/steamcommunity/public/images/apps/444480/ab25220f8ae0432881195c8532776e634922bb7f.jpg',
//    imgLogoUrl: 'https://steamcdn-a.akamaihd.net/steamcommunity/public/images/apps/444480/fa699b3f546806db99c4f8f9b5078224ca606893.jpg'
// }, ...]

Caching

When enabling cache, responses for getAppDetails and resolve methods would be cached. If there would be another request when key found in cache and haven't expired yet, response would be returned from cache.

Types

All interfaces, types, and classes could be accessed.

Type GraphQL

Full type-graphql support would be added some day. Currently it is working only for some classes.

import  { OwnedGame }  from  'type-steamapi'