Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

steamapi

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

steamapi - npm Package Compare versions

Comparing version 2.2.0 to 2.3.0

3

package.json

@@ -6,3 +6,3 @@ {

"main": "index.js",
"version": "2.2.0",
"version": "2.3.0",
"license": "MIT",

@@ -31,4 +31,5 @@ "eslintConfig": {

"dependencies": {
"node-fetch": "^2.6.11",
"steamid": "^2.0.0"
}
}

@@ -64,27 +64,26 @@ ## SteamAPI

- [Documentation](#documentation)
- [SteamAPI](#steamapi-1)
- [new SteamAPI(key, [options])](#new-steamapikey-options)
- [steamAPI.get(path, [base], [key]) ⇒ <code>Promise.&lt;Object&gt;</code>](#steamapigetpath-base-key-%E2%87%92-codepromiseltobjectgtcode)
- [steamAPI.resolve(info) ⇒ <code>Promise.&lt;string&gt;</code>](#steamapiresolveinfo-%E2%87%92-codepromiseltstringgtcode)
- [steamAPI.getAppList() ⇒ <code>Promise.&lt;Array.&lt;App&gt;&gt;</code>](#steamapigetapplist-%E2%87%92-codepromiseltarrayltappgtgtcode)
- [steamAPI.getFeaturedCategories() ⇒ <code>Promise.&lt;Array.&lt;Object&gt;&gt;</code>](#steamapigetfeaturedcategories-%E2%87%92-codepromiseltarrayltobjectgtgtcode)
- [steamAPI.getFeaturedGames() ⇒ <code>Promise.&lt;Object&gt;</code>](#steamapigetfeaturedgames-%E2%87%92-codepromiseltobjectgtcode)
- [steamAPI.getGameAchievements(app) ⇒ <code>Promise.&lt;Object&gt;</code>](#steamapigetgameachievementsapp-%E2%87%92-codepromiseltobjectgtcode)
- [steamAPI.getGameDetails(app, [force]) ⇒ <code>Promise.&lt;Object&gt;</code>](#steamapigetgamedetailsapp-force-%E2%87%92-codepromiseltobjectgtcode)
- [steamAPI.getGameNews(app) ⇒ <code>Promise.&lt;Array.&lt;Object&gt;&gt;</code>](#steamapigetgamenewsapp-%E2%87%92-codepromiseltarrayltobjectgtgtcode)
- [steamAPI.getGamePlayers(app) ⇒ <code>Promise.&lt;number&gt;</code>](#steamapigetgameplayersapp-%E2%87%92-codepromiseltnumbergtcode)
- [steamAPI.getGameSchema(app) ⇒ <code>Promise.&lt;Object&gt;</code>](#steamapigetgameschemaapp-%E2%87%92-codepromiseltobjectgtcode)
- [steamAPI.getServers(host) ⇒ <code>Promise.&lt;Array.&lt;Server&gt;&gt;</code>](#steamapigetservershost-%E2%87%92-codepromiseltarrayltservergtgtcode)
- [steamAPI.getUserAchievements(id, app) ⇒ <code>Promise.&lt;PlayerAchievements&gt;</code>](#steamapigetuserachievementsid-app-%E2%87%92-codepromiseltplayerachievementsgtcode)
- [steamAPI.getUserBadges(id) ⇒ <code>Promise.&lt;PlayerBadges&gt;</code>](#steamapigetuserbadgesid-%E2%87%92-codepromiseltplayerbadgesgtcode)
- [steamAPI.getUserBans(id) ⇒ <code>Promise.&lt;(PlayerBans\|Array.&lt;PlayerBans&gt;)&gt;</code>](#steamapigetuserbansid-%E2%87%92-codepromiseltplayerbansarrayltplayerbansgtgtcode)
- [steamAPI.getUserFriends(id) ⇒ <code>Promise.&lt;Array.&lt;Friend&gt;&gt;</code>](#steamapigetuserfriendsid-%E2%87%92-codepromiseltarrayltfriendgtgtcode)
- [steamAPI.getUserGroups(id) ⇒ <code>Promise.&lt;Array.&lt;string&gt;&gt;</code>](#steamapigetusergroupsid-%E2%87%92-codepromiseltarrayltstringgtgtcode)
- [steamAPI.getUserLevel(id) ⇒ <code>Promise.&lt;number&gt;</code>](#steamapigetuserlevelid-%E2%87%92-codepromiseltnumbergtcode)
- [steamAPI.getUserOwnedGames(id) ⇒ <code>Promise.&lt;Array.&lt;Game&gt;&gt;</code>](#steamapigetuserownedgamesid-%E2%87%92-codepromiseltarrayltgamegtgtcode)
- [steamAPI.getUserRecentGames(id) ⇒ <code>Promise.&lt;Array.&lt;RecentGame&gt;&gt;</code>](#steamapigetuserrecentgamesid-%E2%87%92-codepromiseltarrayltrecentgamegtgtcode)
- [steamAPI.getUserServers([hide], [key]) ⇒ <code>Promise.&lt;PlayerServers&gt;</code>](#steamapigetuserservershide-key-%E2%87%92-codepromiseltplayerserversgtcode)
- [steamAPI.getUserStats(id, app) ⇒ <code>Promise.&lt;PlayerStats&gt;</code>](#steamapigetuserstatsid-app-%E2%87%92-codepromiseltplayerstatsgtcode)
- [steamAPI.getUserSummary(id) ⇒ <code>Promise.&lt;PlayerSummary&gt;</code>](#steamapigetusersummaryid-%E2%87%92-codepromiseltplayersummarygtcode)
* [SteamAPI](#SteamAPI)
* [new SteamAPI(key, [options])](#new_SteamAPI_new)
* [.get(path, [base], [key])](#SteamAPI+get) ⇒ <code>Promise.&lt;Object&gt;</code>
* [.resolve(info)](#SteamAPI+resolve) ⇒ <code>Promise.&lt;string&gt;</code>
* [.getAppList()](#SteamAPI+getAppList) ⇒ <code>Promise.&lt;Array.&lt;App&gt;&gt;</code>
* [.getFeaturedCategories()](#SteamAPI+getFeaturedCategories) ⇒ <code>Promise.&lt;Array.&lt;Object&gt;&gt;</code>
* [.getFeaturedGames()](#SteamAPI+getFeaturedGames) ⇒ <code>Promise.&lt;Object&gt;</code>
* [.getGameAchievements(app)](#SteamAPI+getGameAchievements) ⇒ <code>Promise.&lt;Object&gt;</code>
* [.getGameDetails(app, [force], [region])](#SteamAPI+getGameDetails) ⇒ <code>Promise.&lt;Object&gt;</code>
* [.getGameNews(app)](#SteamAPI+getGameNews) ⇒ <code>Promise.&lt;Array.&lt;Object&gt;&gt;</code>
* [.getGamePlayers(app)](#SteamAPI+getGamePlayers) ⇒ <code>Promise.&lt;number&gt;</code>
* [.getGameSchema(app)](#SteamAPI+getGameSchema) ⇒ <code>Promise.&lt;Object&gt;</code>
* [.getServers(host)](#SteamAPI+getServers) ⇒ <code>Promise.&lt;Array.&lt;Server&gt;&gt;</code>
* [.getUserAchievements(id, app)](#SteamAPI+getUserAchievements) ⇒ <code>Promise.&lt;PlayerAchievements&gt;</code>
* [.getUserBadges(id)](#SteamAPI+getUserBadges) ⇒ <code>Promise.&lt;PlayerBadges&gt;</code>
* [.getUserBans(id)](#SteamAPI+getUserBans) ⇒ <code>Promise.&lt;(PlayerBans\|Array.&lt;PlayerBans&gt;)&gt;</code>
* [.getUserFriends(id)](#SteamAPI+getUserFriends) ⇒ <code>Promise.&lt;Array.&lt;Friend&gt;&gt;</code>
* [.getUserGroups(id)](#SteamAPI+getUserGroups) ⇒ <code>Promise.&lt;Array.&lt;string&gt;&gt;</code>
* [.getUserLevel(id)](#SteamAPI+getUserLevel) ⇒ <code>Promise.&lt;number&gt;</code>
* [.getUserOwnedGames(id, [includeF2P])](#SteamAPI+getUserOwnedGames) ⇒ <code>Promise.&lt;Array.&lt;Game&gt;&gt;</code>
* [.getUserRecentGames(id, [count])](#SteamAPI+getUserRecentGames) ⇒ <code>Promise.&lt;Array.&lt;RecentGame&gt;&gt;</code>
* [.getUserServers([hide], [key])](#SteamAPI+getUserServers) ⇒ <code>Promise.&lt;PlayerServers&gt;</code>
* [.getUserStats(id, app)](#SteamAPI+getUserStats) ⇒ <code>Promise.&lt;PlayerStats&gt;</code>
* [.getUserSummary(id)](#SteamAPI+getUserSummary) ⇒ <code>Promise.&lt;PlayerSummary&gt;</code>

@@ -167,3 +166,3 @@ <a name="new_SteamAPI_new"></a>

### steamAPI.getGameDetails(app, [force]) ⇒ <code>Promise.&lt;Object&gt;</code>
### steamAPI.getGameDetails(app, [force], [region]) ⇒ <code>Promise.&lt;Object&gt;</code>
Get details for app id.

@@ -179,2 +178,3 @@ <warn>Requests for this endpoint are limited to 200 every 5 minutes</warn>

| [force] | <code>boolean</code> | <code>false</code> | Overwrite cache |
| [region] | <code>string</code> | <code>&quot;us&quot;</code> | Store region |

@@ -304,3 +304,3 @@ <a name="SteamAPI+getGameNews"></a>

### steamAPI.getUserOwnedGames(id) ⇒ <code>Promise.&lt;Array.&lt;Game&gt;&gt;</code>
### steamAPI.getUserOwnedGames(id, [includeF2P]) ⇒ <code>Promise.&lt;Array.&lt;Game&gt;&gt;</code>
Get users owned games.

@@ -311,9 +311,10 @@

| Param | Type | Description |
| --- | --- | --- |
| id | <code>string</code> | User ID |
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| id | <code>string</code> | | User ID |
| [includeF2P] | <code>boolean</code> | <code>true</code> | Whether to include user's free-to-play games or not |
<a name="SteamAPI+getUserRecentGames"></a>
### steamAPI.getUserRecentGames(id) ⇒ <code>Promise.&lt;Array.&lt;RecentGame&gt;&gt;</code>
### steamAPI.getUserRecentGames(id, [count]) ⇒ <code>Promise.&lt;Array.&lt;RecentGame&gt;&gt;</code>
Get users recent games.

@@ -327,2 +328,3 @@

| id | <code>string</code> | User ID |
| [count] | <code>number</code> | Optionally limit the number of games to fetch to some number |

@@ -329,0 +331,0 @@ <a name="SteamAPI+getUserServers"></a>

@@ -17,4 +17,4 @@ const SteamID = require('steamid');

const { version, name } = require('../package.json');
const regions = ['us', 'ca', 'cc', 'es', 'de', 'fr', 'ru', 'nz', 'au', 'uk'];
const reApp = /^\d{1,7}$/;
const reRegion = /^us|es|de|fr|ru|nz|au|uk$/i;
const reID = /^\d{17}$/;

@@ -182,3 +182,3 @@

if (!reApp.test(app)) return Promise.reject(TypeError('Invalid/no app provided'));
if (!reRegion.test(region)) return Promise.reject(TypeError('Invalid region provided'));
if (!regions.includes(region)) return Promise.reject(TypeError('Invalid region provided'));

@@ -353,9 +353,10 @@ const request = () => this

* @param {string} id User ID
* @param {boolean} [includeF2P=true] Whether to include user's free-to-play games or not
* @returns {Promise<Game[]>} Owned games
*/
getUserOwnedGames(id) {
getUserOwnedGames(id, includeF2P = true) {
if (!reID.test(id)) return Promise.reject(new TypeError('Invalid/no id provided'));
return this
.get(`/IPlayerService/GetOwnedGames/v1?steamid=${id}&include_appinfo=1`)
.get(`/IPlayerService/GetOwnedGames/v1?steamid=${id}${includeF2P ? '&include_played_free_games=1' : ''}&include_appinfo=1`)
.then(json => json.response.games ? json.response.games.map(game => new Game(game)) : Promise.reject(new Error('No games found')));

@@ -367,9 +368,10 @@ }

* @param {string} id User ID
* @param {number} [count] Optionally limit the number of games to fetch to some number
* @returns {Promise<RecentGame[]>} Recent games
*/
getUserRecentGames(id) {
getUserRecentGames(id, count) {
if (!reID.test(id)) return Promise.reject(new TypeError('Invalid/no id provided'));
return this
.get(`/IPlayerService/GetRecentlyPlayedGames/v1?steamid=${id}`)
.get(`/IPlayerService/GetRecentlyPlayedGames/v1?steamid=${id}${count ? `&count=${count}` : ''}`)
.then(json => json.response.total_count ? json.response.games.map(game => new RecentGame(game)) : []);

@@ -376,0 +378,0 @@ }

@@ -1,37 +0,13 @@

const { createDeflate, createGunzip } = require('zlib');
const { parse } = require('url');
const https = require('https');
const http = require('http');
const fetch = require('node-fetch');
const reg = /<h1>(.*)<\/h1>/;
module.exports = (url, { headers } = {}) => {
const fetch = url.startsWith('https') ? https.get : http.get;
const options = Object.assign(
parse(url),
{ headers: Object.assign({ 'Accept-Encoding': 'gzip, deflate' }, headers) }
);
module.exports = async (url, options) => {
const res = await fetch(url, options);
if (res.status === 400) {
const data = await res.text();
throw new Error(reg.test(data) ? data.match(reg)[1] : data);
}
if (res.status !== 200) throw new Error(res.statusText);
return new Promise((resolve, reject) => {
fetch(options, res => {
const ce = res.headers['content-encoding'];
let data = '';
let op = res;
if (ce === 'deflate') res.pipe(op = createDeflate());
if (ce === 'gzip') res.pipe(op = createGunzip());
op.on('data', chunk => data += chunk);
op.once('error', reject);
op.once('end', () => {
if (res.statusCode === 400) return reject(new Error(reg.test(data) ? data.match(reg)[1] : data));
if (res.statusCode !== 200) return reject(new Error(res.statusMessage));
try {
resolve(JSON.parse(data));
} catch (_) {
reject(new Error(data));
}
});
});
});
};
return res.json();
};
/**
* Yes, I do know what objectify means.
* Convert

@@ -7,6 +6,2 @@ * * [{ name: 'a', value: 'b' }, { name: 'b', value: 'c' }]

* * { a: 'b', b: 'c' }
* &
* * [{ name: 'a', value: 'b', other: 'c' }, { name: 'b', value: 'c', other: 'd' }]
* To
* * { a: { value: 'b', other: 'c' }, b: { value: 'c', other: 'd' } }
* @param {Object[]} arr The array to objectify

@@ -13,0 +8,0 @@ * @param {string} [val=value] The name of the value

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc