simplesteamapis 0.0.3 → 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 CHANGED
@@ -1,53 +1,79 @@
1
- <h1 align="center">Welcome to SimpleSteamApis 👋</h1>
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
- > SteamApis.Com Package for easier use of the API
3
+ [![Version](https://img.shields.io/badge/version-1.0.1-blue.svg?cacheSeconds=2592000)](#)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](#)
10
5
 
11
- ### 🏠 [Homepage](steamapis.com)
6
+ > A simple, zero-dependency Node.js wrapper for the [SteamApis.com](http://steamapis.com) API using native `fetch`.
12
7
 
13
- ## Install
8
+ &nbsp;
14
9
 
15
- ```sh
16
- yarn add simplesteamapis
17
- ```
10
+ ## 📋 Requirements:
11
+
12
+ - Node.js **18+**
13
+ - A [SteamApis.com](http://steamapis.com) API key
14
+
15
+ &nbsp;
18
16
 
19
- or
17
+ ## 📦 Install:
18
+
19
+ Use your preferred package manager:
20
20
 
21
21
  ```sh
22
- npm i simplesteamapis
22
+ npm install simplesteamapis
23
+ # or: yarn add simplesteamapis | pnpm add simplesteamapis | bun add simplesteamapis
23
24
  ```
24
25
 
25
- ## Usage
26
+ &nbsp;
26
27
 
27
- Example:
28
+ ## 🚀 Usage:
28
29
 
29
- ```sh
30
- const steamapis = require("simplesteamapis");
31
- const api = new steamapis("API_KEY");
32
-
33
- (async () => {
34
- try {
35
- const inventory = await api.getInventory("76561198027608071", 730, 2);
36
- console.log(inventory);
37
- } catch (err) {
38
- console.log(err);
39
- }
40
- })();
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();
41
42
  ```
42
43
 
43
- ## Author
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
+ &nbsp;
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
+ &nbsp;
44
59
 
45
- 👤 **Ashley Bridges**
60
+ ### **Market:**
46
61
 
47
- - Github: [@idefinehd](https://github.com/idefinehd)
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. |
48
72
 
49
- ## Show your support
73
+ &nbsp;
50
74
 
51
- Give a ⭐️ if this project helped you!
75
+ ### **Images:**
52
76
 
53
- ---
77
+ | Method | Description |
78
+ | ------------------- | ---------------------------------------------------- |
79
+ | `itemsImage(appID)` | Image URLs for all items within a given game. |
@@ -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
+ })();
@@ -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
- const axios = require("axios");
2
-
3
- class steamapis {
4
- constructor(api_key) {
5
- this.api_key = api_key;
6
- }
7
-
8
- //Added (Optional Query Parameters) as different routes
9
- async getLegacyInventory(steamID, appID, contextID) {
10
- return this.baseRequestWithParameter(
11
- `steam/inventory/${steamID}/${appID}/${contextID}`,
12
- `legacy=1`
13
- );
14
- }
15
-
16
- async compactItems(appID) {
17
- return this.baseRequestWithParameter(
18
- `market/items/${appID}`,
19
- `format=compact`
20
- );
21
- }
22
-
23
- async CompactItemsWithValue(appID, compact_value) {
24
- return this.baseRequestWithParameter(
25
- `market/items/${appID}`,
26
- `format=compact&compact_value=${compact_value}`
27
- );
28
- }
29
-
30
- // Seperated Endpoints for respective categories
31
-
32
- //Steam Section
33
-
34
- async getInventory(steamID, appID, contextID) {
35
- return this.baseRequest(`steam/inventory/${steamID}/${appID}/${contextID}`);
36
- }
37
-
38
- async getProfile(steamID) {
39
- return this.baseRequest(`steam/profile/${steamID}`);
40
- }
41
-
42
- // Market Endpoint
43
-
44
- async siteStats() {
45
- return this.baseRequest("market/stats");
46
- }
47
-
48
- async app(appID) {
49
- return this.baseRequest(`market/app/${appID}`);
50
- }
51
-
52
- async apps() {
53
- return this.baseRequest("market/apps");
54
- }
55
-
56
- async item(appID, market_hash_name) {
57
- return this.baseRequest(`market/item/${appID}/${market_hash_name}`);
58
- }
59
-
60
- async items(appID) {
61
- return this.baseRequest(`market/items/${appID}`);
62
- }
63
-
64
- async cards() {
65
- return this.baseRequest("market/items/cards");
66
- }
67
-
68
- // Images
69
- async itemsImage(appID) {
70
- return this.baseRequest(`image/items/${appID}`);
71
- }
72
-
73
- //TODO: Add Extended optional requests to the endpoints
74
-
75
- async baseRequest(endpoint) {
76
- const res = await axios({
77
- url: `http://api.steamapis.com/${endpoint}?api_key=${this.api_key}`,
78
- method: "GET",
79
- headers: {
80
- "User-Agent": "STEAMAPIS NPM PACKAGE",
81
- },
82
- });
83
- return res.data;
84
- }
85
-
86
- async baseRequestWithParameter(endpoint, QueryParameter) {
87
- const res = await axios({
88
- url: `http://api.steamapis.com/${endpoint}?api_key=${this.api_key}&${QueryParameter}`,
89
- method: "GET",
90
- headers: {
91
- "User-Agent": "STEAMAPIS NPM PACKAGE",
92
- },
93
- });
94
- return res.data;
95
- }
96
- }
97
-
98
- module.exports = steamapis;
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": "0.0.3",
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"
package/renovate.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": [
3
+ "config:base"
4
+ ]
5
+ }