simplesteamapis 0.0.4 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -79
- package/examples/getInventory.js +11 -11
- package/examples/getItem.js +11 -11
- package/index.js +114 -98
- package/package.json +2 -4
- package/renovate.json +5 -0
package/README.md
CHANGED
|
@@ -1,96 +1,79 @@
|
|
|
1
|
-
|
|
2
|
-
<p>
|
|
3
|
-
<img alt="Version" src="https://img.shields.io/badge/version-0.0.1-blue.svg?cacheSeconds=2592000" />
|
|
4
|
-
<a href="#" target="_blank">
|
|
5
|
-
<img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg" />
|
|
6
|
-
</a>
|
|
7
|
-
</p>
|
|
1
|
+
# SimpleSteamApis 👋
|
|
8
2
|
|
|
9
|
-
|
|
3
|
+
[](#)
|
|
4
|
+
[](#)
|
|
10
5
|
|
|
11
|
-
|
|
6
|
+
> A simple, zero-dependency Node.js wrapper for the [SteamApis.com](http://steamapis.com) API using native `fetch`.
|
|
12
7
|
|
|
13
|
-
|
|
8
|
+
|
|
14
9
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
## 📋 Requirements:
|
|
11
|
+
|
|
12
|
+
- Node.js **18+**
|
|
13
|
+
- A [SteamApis.com](http://steamapis.com) API key
|
|
14
|
+
|
|
15
|
+
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
## 📦 Install:
|
|
18
|
+
|
|
19
|
+
Use your preferred package manager:
|
|
20
20
|
|
|
21
21
|
```sh
|
|
22
|
-
npm
|
|
22
|
+
npm install simplesteamapis
|
|
23
|
+
# or: yarn add simplesteamapis | pnpm add simplesteamapis | bun add simplesteamapis
|
|
23
24
|
```
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
<dl>
|
|
28
|
-
<dt> getLegacyInventory(steamID, appID, contextID) </dt>
|
|
29
|
-
<dd> Used to get the legacy version of the users inventory. this includes some information that is not included in the new endpoints data.</dd>
|
|
30
|
-
<dt>compactItems(appID)</dt>
|
|
31
|
-
<dd>Used to gather a compact version of the items from a specific game, provided an appID is provided, for example 730 (CSGO)</dd>
|
|
32
|
-
<dt>CompactItemsWithValue(appID, compact_value)</dt>
|
|
33
|
-
<dd>Used to gather a compact version of the items from a specific game, like above. But with the added feature of allowing a user set timeframe for prices.</dd>
|
|
34
|
-
</dl>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
<h2> Steam Specific </h2>
|
|
38
|
-
<dl>
|
|
39
|
-
<dt>getInventory(steamID, appID, contextID)</dt>
|
|
40
|
-
<dd>Used to gather a users inventory from steam. If supplied with a steamID, appID and contextID, this is used in the example below.</dd>
|
|
41
|
-
<dt>getProfile(steamID)</dt>
|
|
42
|
-
<dd>Used to return all information regarding a steam users profile, such as name, avatar etc.</dd>
|
|
43
|
-
</dl>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<h2>Market Specific</h2>
|
|
47
|
-
<dl>
|
|
48
|
-
<dt>siteStats()</dt>
|
|
49
|
-
<dd>Used to return the stats of how many items have been scanned/requests that have been served by steamapis.com</dd>
|
|
50
|
-
<dt>app(appID)</dt>
|
|
51
|
-
<dd>Used to return all information on a specific game/application that has been chosen, 730 (CSGO) for example.</dd>
|
|
52
|
-
<dt>apps()</dt>
|
|
53
|
-
<dd>Used to return all information on all games tracked by steamapis.com.</dd>
|
|
54
|
-
<dt>item(appID, market_hash_name)</dt>
|
|
55
|
-
<dd>Used to return specific information for an item on the community market, provided an appID and Market name are provided.</dd>
|
|
56
|
-
<dt>items(appID)</dt>
|
|
57
|
-
<dd>Used to return all information on items for a specific game, that are on the community market. 730 (CSGO) for example.</dd>
|
|
58
|
-
<dt>cards()</dt>
|
|
59
|
-
<dd>used to return card data for all of steam.</dd>
|
|
60
|
-
</dl>
|
|
61
|
-
|
|
62
|
-
<h2>Image Specific</h2>
|
|
63
|
-
<dl>
|
|
64
|
-
<dt>itemsImage(appID)</dt>
|
|
65
|
-
<dd>returns images for items from a sepcific game or app, if appID is provided.</dd>
|
|
66
|
-
</dl>
|
|
67
|
-
|
|
68
|
-
## Usage
|
|
69
|
-
|
|
70
|
-
Example:
|
|
26
|
+
|
|
71
27
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
28
|
+
## 🚀 Usage:
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
const SteamApis = require("simplesteamapis");
|
|
32
|
+
const api = new SteamApis("YOUR_API_KEY");
|
|
33
|
+
|
|
34
|
+
// Fetch a user's CS:GO inventory
|
|
35
|
+
const inventory = await api.getInventory("76561198027608071", 730, 2);
|
|
36
|
+
|
|
37
|
+
// Look up a specific market item
|
|
38
|
+
const item = await api.item(730, "AK-47 | Redline (Field-Tested)");
|
|
39
|
+
|
|
40
|
+
// Get all tracked games
|
|
41
|
+
const apps = await api.apps();
|
|
84
42
|
```
|
|
85
43
|
|
|
86
|
-
|
|
44
|
+
All methods are `async` and return parsed JSON. Errors throw with `err.message`, `err.status`, and `err.data` (the API's JSON error body) attached.
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
## 📖 API Reference:
|
|
49
|
+
|
|
50
|
+
### **Steam:**
|
|
51
|
+
|
|
52
|
+
| Method | Description |
|
|
53
|
+
| ----------------------------------------------- | ------------------------------------------------------------------------------- |
|
|
54
|
+
| `getInventory(steamID, appID, contextID)` | Fetches a user's Steam inventory for a given game and context. |
|
|
55
|
+
| `getLegacyInventory(steamID, appID, contextID)` | Fetches a user's inventory in legacy format, which includes additional fields. |
|
|
56
|
+
| `getProfile(steamID)` | Fetches a user's Steam profile — display name, avatar, visibility, etc. |
|
|
57
|
+
|
|
58
|
+
|
|
87
59
|
|
|
88
|
-
|
|
60
|
+
### **Market:**
|
|
89
61
|
|
|
90
|
-
|
|
62
|
+
| Method | Description |
|
|
63
|
+
| -------------------------------------------- | ---------------------------------------------------------------------------------- |
|
|
64
|
+
| `siteStats()` | Platform stats for SteamApis.com — items scanned, requests served, etc. |
|
|
65
|
+
| `app(appID)` | Detailed information for a specific game or application. |
|
|
66
|
+
| `apps()` | Lists all games and applications currently tracked by SteamApis.com. |
|
|
67
|
+
| `item(appID, market_hash_name)` | Pricing and metadata for a single item on the Steam Community Market. |
|
|
68
|
+
| `items(appID)` | All tracked market items for a given game. |
|
|
69
|
+
| `compactItems(appID)` | Compact market item list — equivalent to passing `format=compact` to the API. |
|
|
70
|
+
| `CompactItemsWithValue(appID, compact_value)`| Compact market item list with a custom timeframe for price values. |
|
|
71
|
+
| `cards()` | Trading card data across all games on Steam. |
|
|
91
72
|
|
|
92
|
-
|
|
73
|
+
|
|
93
74
|
|
|
94
|
-
|
|
75
|
+
### **Images:**
|
|
95
76
|
|
|
96
|
-
|
|
77
|
+
| Method | Description |
|
|
78
|
+
| ------------------- | ---------------------------------------------------- |
|
|
79
|
+
| `itemsImage(appID)` | Image URLs for all items within a given game. |
|
package/examples/getInventory.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const steamapis = require("simplesteamapis");
|
|
2
|
-
const api = new steamapis("API_KEY");
|
|
3
|
-
|
|
4
|
-
(async () => {
|
|
5
|
-
try {
|
|
6
|
-
const inventory = await api.getInventory("76561198027608071", 730, 2);
|
|
7
|
-
console.log(inventory);
|
|
8
|
-
} catch (err) {
|
|
9
|
-
console.log(err);
|
|
10
|
-
}
|
|
11
|
-
})();
|
|
1
|
+
const steamapis = require("simplesteamapis");
|
|
2
|
+
const api = new steamapis("API_KEY");
|
|
3
|
+
|
|
4
|
+
(async () => {
|
|
5
|
+
try {
|
|
6
|
+
const inventory = await api.getInventory("76561198027608071", 730, 2);
|
|
7
|
+
console.log(inventory);
|
|
8
|
+
} catch (err) {
|
|
9
|
+
console.log(err);
|
|
10
|
+
}
|
|
11
|
+
})();
|
package/examples/getItem.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const steamapis = require("simplesteamapis");
|
|
2
|
-
const api = new steamapis("API_KEY"); // Put api key here
|
|
3
|
-
|
|
4
|
-
(async () => {
|
|
5
|
-
try {
|
|
6
|
-
const inventory = await api.item(730, "AK-47 | Redline (Field-Tested)");
|
|
7
|
-
console.log(inventory);
|
|
8
|
-
} catch (err) {
|
|
9
|
-
console.log(err);
|
|
10
|
-
}
|
|
11
|
-
})();
|
|
1
|
+
const steamapis = require("simplesteamapis");
|
|
2
|
+
const api = new steamapis("API_KEY"); // Put api key here
|
|
3
|
+
|
|
4
|
+
(async () => {
|
|
5
|
+
try {
|
|
6
|
+
const inventory = await api.item(730, "AK-47 | Redline (Field-Tested)");
|
|
7
|
+
console.log(inventory);
|
|
8
|
+
} catch (err) {
|
|
9
|
+
console.log(err);
|
|
10
|
+
}
|
|
11
|
+
})();
|
package/index.js
CHANGED
|
@@ -1,98 +1,114 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
1
|
+
class steamapis {
|
|
2
|
+
constructor(api_key) {
|
|
3
|
+
this.api_key = api_key;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
//Added (Optional Query Parameters) as different routes
|
|
7
|
+
async getLegacyInventory(steamID, appID, contextID) {
|
|
8
|
+
return this.baseRequestWithParameter(
|
|
9
|
+
`steam/inventory/${steamID}/${appID}/${contextID}`,
|
|
10
|
+
`legacy=1`,
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async compactItems(appID) {
|
|
15
|
+
return this.baseRequestWithParameter(
|
|
16
|
+
`market/items/${appID}`,
|
|
17
|
+
`format=compact`,
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async CompactItemsWithValue(appID, compact_value) {
|
|
22
|
+
return this.baseRequestWithParameter(
|
|
23
|
+
`market/items/${appID}`,
|
|
24
|
+
`format=compact&compact_value=${compact_value}`,
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Seperated Endpoints for respective categories
|
|
29
|
+
|
|
30
|
+
//Steam Section
|
|
31
|
+
|
|
32
|
+
async getInventory(steamID, appID, contextID) {
|
|
33
|
+
return this.baseRequest(`steam/inventory/${steamID}/${appID}/${contextID}`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async getProfile(steamID) {
|
|
37
|
+
return this.baseRequest(`steam/profile/${steamID}`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Market Endpoint
|
|
41
|
+
|
|
42
|
+
async siteStats() {
|
|
43
|
+
return this.baseRequest("market/stats");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async app(appID) {
|
|
47
|
+
return this.baseRequest(`market/app/${appID}`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async apps() {
|
|
51
|
+
return this.baseRequest("market/apps");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async item(appID, market_hash_name) {
|
|
55
|
+
return this.baseRequest(`market/item/${appID}/${market_hash_name}`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async items(appID) {
|
|
59
|
+
return this.baseRequest(`market/items/${appID}`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async cards() {
|
|
63
|
+
return this.baseRequest("market/items/cards");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Images
|
|
67
|
+
async itemsImage(appID) {
|
|
68
|
+
return this.baseRequest(`image/items/${appID}`);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//TODO: Add Extended optional requests to the endpoints
|
|
72
|
+
|
|
73
|
+
async baseRequest(endpoint) {
|
|
74
|
+
const res = await fetch(
|
|
75
|
+
`http://api.steamapis.com/${endpoint}?api_key=${this.api_key}`,
|
|
76
|
+
{
|
|
77
|
+
method: "GET",
|
|
78
|
+
headers: {
|
|
79
|
+
"User-Agent": "STEAMAPIS NPM PACKAGE",
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
);
|
|
83
|
+
if (!res.ok) {
|
|
84
|
+
const body = await res.json().catch(() => null);
|
|
85
|
+
const err = new Error(`Request failed with status ${res.status}`);
|
|
86
|
+
err.status = res.status;
|
|
87
|
+
err.data = body;
|
|
88
|
+
throw err;
|
|
89
|
+
}
|
|
90
|
+
return res.json();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async baseRequestWithParameter(endpoint, QueryParameter) {
|
|
94
|
+
const res = await fetch(
|
|
95
|
+
`http://api.steamapis.com/${endpoint}?api_key=${this.api_key}&${QueryParameter}`,
|
|
96
|
+
{
|
|
97
|
+
method: "GET",
|
|
98
|
+
headers: {
|
|
99
|
+
"User-Agent": "STEAMAPIS NPM PACKAGE",
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
);
|
|
103
|
+
if (!res.ok) {
|
|
104
|
+
const body = await res.json().catch(() => null);
|
|
105
|
+
const err = new Error(`Request failed with status ${res.status}`);
|
|
106
|
+
err.status = res.status;
|
|
107
|
+
err.data = body;
|
|
108
|
+
throw err;
|
|
109
|
+
}
|
|
110
|
+
return res.json();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
module.exports = steamapis;
|
package/package.json
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "simplesteamapis",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "SteamApis.Com Package for easier use of the API",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|
|
7
7
|
"example": "examples"
|
|
8
8
|
},
|
|
9
|
-
"dependencies": {
|
|
10
|
-
"axios": "^0.21.1"
|
|
11
|
-
},
|
|
9
|
+
"dependencies": {},
|
|
12
10
|
"devDependencies": {},
|
|
13
11
|
"scripts": {
|
|
14
12
|
"test": "echo \"Error: no test specified\" && exit 1"
|