2.0.0 • Published 1 year ago

@varandas/steam v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Steam

Node.js CI codecov semantic-release: angular

Interface to the Steam Web API, fully typed, written in TypeScript. (Wrapper for the Steam Web API)

Steam

Valve provides these APIs so website developers can use data from Steam in new and interesting ways. They allow developers to query Steam for information that they can present on their own sites.

The Steam Web API is a RESTful web service designed to be called from a web browser using JavaScript, or from a server using a standard HTTP library.

I designed this library to make it easy to use the Steam Web API in your projects - Contributions are more than welcome! Feel free to submit your ideas by opening a new issue or creating a Pull Request.

Features / Roadmap

  • News
  • Player
  • User
  • User Stats

News

  • Get News For App

Player

  • Get Owned Games
  • Get Recently Played Games

User

  • Get PlayerSummaries
  • Get IFriend List

User Stats

  • Get Player Achievements
  • Get Global Achievements Percentages For App
  • Get User Stats For Game

Installation

# With npm
npm install @varandas/steam

# Or with yarn
yarn add @varandas/steam

Usage

Please note that you need to register for a Steam Web API key.

Also be aware that the Steam Web API only works on a node environment. Requests made from the browser will fail.

With es6 modules

import SteamApi, { IGetNewsForAppParams, IGetNewsForAppResponse } from '@varandas/steam'

// Create a new client
const steamApi = new SteamApi("YOUR_STEAM_API_KEY")

// Get the services as needed
const newsService = steamApi.getNewsService()
const playerService = steamApi.getPlayerService()
const userService = steamApi.getUserService()
const userStatsService = steamApi.getUserStatsService()

Or with commonjs

const SteamApi = require('@varandas/steam').default

Documentation

SteamApi

// Main class, use it to create the services. 
const steamApi = new SteamApi("YOUR_STEAM_API_KEY")

News Service

// Get the news service from the client
const newsService = steamApi.getNewsService()

// Get News For App
const news = await newsService.getNewsForApp({
  appid: 440,
  count: 3,
  maxlength: 300,
})

User Service

// Get the user service
const userService = steamApi.getUserService()

// Get Player Summaries
const users = await userService.getPlayerSummaries({
  steamids: ['76561198000000000', '76561198000000001'],
})

// Get IFriend List
const friends = await userService.getFriendList({
  steamid: '76561198000000000',
  relationship: 'all',
})

User Stats Service

// Get the user stats service
const userStatsService = steamApi.getUserStatsService()

// Get Player Achievements
const achievements = await userStatsService.getPlayerAchievements({
  steamid: '76561198000000000',
  appid: 440,
})

// Get Global Achievements Percentages For App
const achievements = await userStatsService.getGlobalAchievementsPercentagesForApp({
  gameid: 440,
})

// Get User Stats For Game
const stats = await userStatsService.getUserStatsForGame({
  steamid: '76561198000000000',
  appid: 440,
})

Player Service

// Get the player service
const playerService = steamApi.getPlayerService()

// Get Owned Games
const games = await playerService.getOwnedGames({
  steamId: '76561198000000000',
  includeAppInfo: true,
  includePlayedFreeGames: true,
})

// Get Recently Played Games
const games = await playerService.getRecentlyPlayedGames({
  steamid: '76561198000000000',
  count: 3,
})

License

MIT - 2023 André Varandas

Disclaimer

This project is not affiliated with Valve Corporation or Steam. All trademarks are property of their respective owners in the US and other countries. ©2023 Valve Corporation. Steam and the Steam logo are trademarks and/or registered trademarks of Valve Corporation in the U.S. and/or other countries.

2.0.0

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago