@apiverve/slotmachine 1.1.12

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 APIVerve, and EvlarSoft LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,321 @@
1
+ # Slot Machine Simulator API
2
+
3
+ Slot Machine Simulator is a tool for simulating slot machine spins with realistic reel symbols and payout calculations. It supports customizable number of reels, bet amounts, and multiple spins with detailed win/loss statistics.
4
+
5
+ ![Build Status](https://img.shields.io/badge/build-passing-green)
6
+ ![Code Climate](https://img.shields.io/badge/maintainability-B-purple)
7
+ ![Prod Ready](https://img.shields.io/badge/production-ready-blue)
8
+
9
+ This is a Javascript Wrapper for the [Slot Machine Simulator API](https://apiverve.com/marketplace/slotmachine)
10
+
11
+ ---
12
+
13
+ ## Installation
14
+
15
+ Using npm:
16
+ ```shell
17
+ npm install @apiverve/slotmachine
18
+ ```
19
+
20
+ Using yarn:
21
+ ```shell
22
+ yarn add @apiverve/slotmachine
23
+ ```
24
+
25
+ ---
26
+
27
+ ## Configuration
28
+
29
+ Before using the Slot Machine Simulator API client, you have to setup your account and obtain your API Key.
30
+ You can get it by signing up at [https://apiverve.com](https://apiverve.com)
31
+
32
+ ---
33
+
34
+ ## Quick Start
35
+
36
+ [Get started with the Quick Start Guide](https://docs.apiverve.com/quickstart)
37
+
38
+ The Slot Machine Simulator API documentation is found here: [https://docs.apiverve.com/ref/slotmachine](https://docs.apiverve.com/ref/slotmachine).
39
+ You can find parameters, example responses, and status codes documented here.
40
+
41
+ ### Setup
42
+
43
+ ```javascript
44
+ const slotmachineAPI = require('@apiverve/slotmachine');
45
+ const api = new slotmachineAPI({
46
+ api_key: '[YOUR_API_KEY]'
47
+ });
48
+ ```
49
+
50
+ ---
51
+
52
+ ## Usage
53
+
54
+ ---
55
+
56
+ ### Perform Request
57
+
58
+ Using the API is simple. All you have to do is make a request. The API will return a response with the data you requested.
59
+
60
+ ```javascript
61
+ var query = {
62
+ spins: 5,
63
+ reels: 3,
64
+ bet: 1
65
+ };
66
+
67
+ api.execute(query, function (error, data) {
68
+ if (error) {
69
+ return console.error(error);
70
+ } else {
71
+ console.log(data);
72
+ }
73
+ });
74
+ ```
75
+
76
+ ---
77
+
78
+ ### Using Promises
79
+
80
+ You can also use promises to make requests. The API returns a promise that you can use to handle the response.
81
+
82
+ ```javascript
83
+ var query = {
84
+ spins: 5,
85
+ reels: 3,
86
+ bet: 1
87
+ };
88
+
89
+ api.execute(query)
90
+ .then(data => {
91
+ console.log(data);
92
+ })
93
+ .catch(error => {
94
+ console.error(error);
95
+ });
96
+ ```
97
+
98
+ ---
99
+
100
+ ### Using Async/Await
101
+
102
+ You can also use async/await to make requests. The API returns a promise that you can use to handle the response.
103
+
104
+ ```javascript
105
+ async function makeRequest() {
106
+ var query = {
107
+ spins: 5,
108
+ reels: 3,
109
+ bet: 1
110
+ };
111
+
112
+ try {
113
+ const data = await api.execute(query);
114
+ console.log(data);
115
+ } catch (error) {
116
+ console.error(error);
117
+ }
118
+ }
119
+ ```
120
+
121
+ ---
122
+
123
+ ## Example Response
124
+
125
+ ```json
126
+ {
127
+ "status": "ok",
128
+ "error": null,
129
+ "data": {
130
+ "total_spins": 5,
131
+ "num_reels": 3,
132
+ "bet_per_spin": 1,
133
+ "spins": [
134
+ {
135
+ "spin_number": 1,
136
+ "reels": [
137
+ {
138
+ "symbol": "🍒",
139
+ "name": "Cherry"
140
+ },
141
+ {
142
+ "symbol": "⭐",
143
+ "name": "Star"
144
+ },
145
+ {
146
+ "symbol": "🍒",
147
+ "name": "Cherry"
148
+ }
149
+ ],
150
+ "bet": 1,
151
+ "payout": 0,
152
+ "win_type": "none",
153
+ "is_win": false
154
+ },
155
+ {
156
+ "spin_number": 2,
157
+ "reels": [
158
+ {
159
+ "symbol": "🍒",
160
+ "name": "Cherry"
161
+ },
162
+ {
163
+ "symbol": "🍇",
164
+ "name": "Grape"
165
+ },
166
+ {
167
+ "symbol": "🍋",
168
+ "name": "Lemon"
169
+ }
170
+ ],
171
+ "bet": 1,
172
+ "payout": 0,
173
+ "win_type": "none",
174
+ "is_win": false
175
+ },
176
+ {
177
+ "spin_number": 3,
178
+ "reels": [
179
+ {
180
+ "symbol": "🍒",
181
+ "name": "Cherry"
182
+ },
183
+ {
184
+ "symbol": "🔔",
185
+ "name": "Bell"
186
+ },
187
+ {
188
+ "symbol": "🔔",
189
+ "name": "Bell"
190
+ }
191
+ ],
192
+ "bet": 1,
193
+ "payout": 0,
194
+ "win_type": "none",
195
+ "is_win": false
196
+ },
197
+ {
198
+ "spin_number": 4,
199
+ "reels": [
200
+ {
201
+ "symbol": "🍒",
202
+ "name": "Cherry"
203
+ },
204
+ {
205
+ "symbol": "🍊",
206
+ "name": "Orange"
207
+ },
208
+ {
209
+ "symbol": "🍒",
210
+ "name": "Cherry"
211
+ }
212
+ ],
213
+ "bet": 1,
214
+ "payout": 0,
215
+ "win_type": "none",
216
+ "is_win": false
217
+ },
218
+ {
219
+ "spin_number": 5,
220
+ "reels": [
221
+ {
222
+ "symbol": "🍊",
223
+ "name": "Orange"
224
+ },
225
+ {
226
+ "symbol": "🔔",
227
+ "name": "Bell"
228
+ },
229
+ {
230
+ "symbol": "🍋",
231
+ "name": "Lemon"
232
+ }
233
+ ],
234
+ "bet": 1,
235
+ "payout": 0,
236
+ "win_type": "none",
237
+ "is_win": false
238
+ }
239
+ ],
240
+ "total_bet": 5,
241
+ "total_winnings": 0,
242
+ "net_profit": -5,
243
+ "wins": 0,
244
+ "losses": 5,
245
+ "win_percentage": 0,
246
+ "available_symbols": [
247
+ {
248
+ "symbol": "🍒",
249
+ "name": "Cherry",
250
+ "payout_multiplier": 2
251
+ },
252
+ {
253
+ "symbol": "🍋",
254
+ "name": "Lemon",
255
+ "payout_multiplier": 3
256
+ },
257
+ {
258
+ "symbol": "🍊",
259
+ "name": "Orange",
260
+ "payout_multiplier": 5
261
+ },
262
+ {
263
+ "symbol": "🍇",
264
+ "name": "Grape",
265
+ "payout_multiplier": 10
266
+ },
267
+ {
268
+ "symbol": "🔔",
269
+ "name": "Bell",
270
+ "payout_multiplier": 20
271
+ },
272
+ {
273
+ "symbol": "⭐",
274
+ "name": "Star",
275
+ "payout_multiplier": 50
276
+ },
277
+ {
278
+ "symbol": "💎",
279
+ "name": "Diamond",
280
+ "payout_multiplier": 100
281
+ },
282
+ {
283
+ "symbol": "7️⃣",
284
+ "name": "Seven",
285
+ "payout_multiplier": 200
286
+ }
287
+ ]
288
+ }
289
+ }
290
+ ```
291
+
292
+ ---
293
+
294
+ ## Customer Support
295
+
296
+ Need any assistance? [Get in touch with Customer Support](https://apiverve.com/contact).
297
+
298
+ ---
299
+
300
+ ## Updates
301
+
302
+ Stay up to date by following [@apiverveHQ](https://twitter.com/apiverveHQ) on Twitter.
303
+
304
+ ---
305
+
306
+ ## Legal
307
+
308
+ All usage of the APIVerve website, API, and services is subject to the [APIVerve Terms of Service](https://apiverve.com/terms) and all legal documents and agreements.
309
+
310
+ ---
311
+
312
+ ## License
313
+ Licensed under the The MIT License (MIT)
314
+
315
+ Copyright (©) 2025 APIVerve, and EvlarSoft LLC
316
+
317
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
318
+
319
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
320
+
321
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Basic Example - Slot Machine Simulator API
3
+ *
4
+ * This example demonstrates how to use the Slot Machine Simulator API.
5
+ * Make sure to set your API key in the .env file or replace '[YOUR_API_KEY]' below.
6
+ */
7
+
8
+ require('dotenv').config();
9
+ const slotmachineAPI = require('../index.js');
10
+
11
+ // Initialize the API client
12
+ const api = new slotmachineAPI({
13
+ api_key: process.env.API_KEY || '[YOUR_API_KEY]'
14
+ });
15
+
16
+ // Example query
17
+ var query = {
18
+ spins: 5,
19
+ reels: 3,
20
+ bet: 1
21
+ };
22
+
23
+ // Make the API request using callback
24
+ console.log('Making request to Slot Machine Simulator API...\n');
25
+
26
+ api.execute(query, function (error, data) {
27
+ if (error) {
28
+ console.error('Error occurred:');
29
+ if (error.error) {
30
+ console.error('Message:', error.error);
31
+ console.error('Status:', error.status);
32
+ } else {
33
+ console.error(JSON.stringify(error, null, 2));
34
+ }
35
+ return;
36
+ }
37
+
38
+ console.log('Response:');
39
+ console.log(JSON.stringify(data, null, 2));
40
+ });
package/index.d.ts ADDED
@@ -0,0 +1,56 @@
1
+ declare module '@apiverve/slotmachine' {
2
+ export interface slotmachineOptions {
3
+ api_key: string;
4
+ secure?: boolean;
5
+ }
6
+
7
+ export interface slotmachineResponse {
8
+ status: string;
9
+ error: string | null;
10
+ data: SlotMachineSimulatorData;
11
+ code?: number;
12
+ }
13
+
14
+
15
+ interface SlotMachineSimulatorData {
16
+ totalSpins: number;
17
+ numReels: number;
18
+ betPerSpin: number;
19
+ spins: Spin[];
20
+ totalBet: number;
21
+ totalWinnings: number;
22
+ netProfit: number;
23
+ wins: number;
24
+ losses: number;
25
+ winPercentage: number;
26
+ availableSymbols: AvailableSymbol[];
27
+ }
28
+
29
+ interface AvailableSymbol {
30
+ symbol: string;
31
+ name: string;
32
+ payoutMultiplier: number;
33
+ }
34
+
35
+ interface Spin {
36
+ spinNumber: number;
37
+ reels: Reel[];
38
+ bet: number;
39
+ payout: number;
40
+ winType: string;
41
+ isWin: boolean;
42
+ }
43
+
44
+ interface Reel {
45
+ symbol: string;
46
+ name: string;
47
+ }
48
+
49
+ export default class slotmachineWrapper {
50
+ constructor(options: slotmachineOptions);
51
+
52
+ execute(callback: (error: any, data: slotmachineResponse | null) => void): Promise<slotmachineResponse>;
53
+ execute(query: Record<string, any>, callback: (error: any, data: slotmachineResponse | null) => void): Promise<slotmachineResponse>;
54
+ execute(query?: Record<string, any>): Promise<slotmachineResponse>;
55
+ }
56
+ }
package/index.js ADDED
@@ -0,0 +1,124 @@
1
+ const axios = require('axios');
2
+
3
+ class slotmachineWrapper {
4
+
5
+ constructor(options) {
6
+ if (!options || typeof options !== 'object') {
7
+ throw new Error('Options object must be provided. See documentation: https://docs.apiverve.com/ref/slotmachine');
8
+ }
9
+
10
+ const { api_key, secure = true } = options;
11
+
12
+ if (!api_key || typeof api_key !== 'string') {
13
+ throw new Error('API key must be provided as a non-empty string. Get your API key at: https://apiverve.com');
14
+ }
15
+
16
+ // Validate API key format (GUID or alphanumeric with hyphens)
17
+ const apiKeyPattern = /^[a-zA-Z0-9-]+$/;
18
+ if (!apiKeyPattern.test(api_key)) {
19
+ throw new Error('Invalid API key format. API key must be alphanumeric and may contain hyphens. Get your API key at: https://apiverve.com');
20
+ }
21
+
22
+ // Check minimum length (GUIDs are typically 36 chars with hyphens, or 32 without)
23
+ const trimmedKey = api_key.replace(/-/g, '');
24
+ if (trimmedKey.length < 32) {
25
+ throw new Error('Invalid API key. API key appears to be too short. Get your API key at: https://apiverve.com');
26
+ }
27
+
28
+ if (typeof secure !== 'boolean') {
29
+ throw new Error('Secure parameter must be a boolean value.');
30
+ }
31
+
32
+ this.APIKey = api_key;
33
+ this.IsSecure = secure;
34
+
35
+ // secure is deprecated, all requests must be made over HTTPS
36
+ this.baseURL = 'https://api.apiverve.com/v1/slotmachine';
37
+ }
38
+
39
+ async execute(query, callback) {
40
+ // Handle different argument patterns
41
+ if(arguments.length === 0) {
42
+ // execute() - no args
43
+ query = {};
44
+ callback = null;
45
+ } else if(arguments.length === 1) {
46
+ if (typeof query === 'function') {
47
+ // execute(callback)
48
+ callback = query;
49
+ query = {};
50
+ } else {
51
+ // execute(query)
52
+ callback = null;
53
+ }
54
+ } else {
55
+ // execute(query, callback)
56
+ if (!query || typeof query !== 'object') {
57
+ throw new Error('Query parameters must be provided as an object.');
58
+ }
59
+ }
60
+
61
+ var requiredParams = [];
62
+ if (requiredParams.length > 0) {
63
+ for (var i = 0; i < requiredParams.length; i++) {
64
+ if (!query[requiredParams[i]]) {
65
+ throw new Error(`Required parameter [${requiredParams[i]}] is missing. See documentation: https://docs.apiverve.com/ref/slotmachine`);
66
+ }
67
+ }
68
+ }
69
+
70
+ const method = 'GET';
71
+ const url = method === 'POST' ? this.baseURL : this.constructURL(query);
72
+
73
+ try {
74
+ const response = await axios({
75
+ method,
76
+ url,
77
+ headers: {
78
+ 'Content-Type': 'application/json',
79
+ 'x-api-key': this.APIKey,
80
+ 'auth-mode': 'npm-package'
81
+ },
82
+ data: method === 'POST' ? query : undefined
83
+ });
84
+
85
+ const data = response.data;
86
+ if (callback) callback(null, data);
87
+ return data;
88
+ } catch (error) {
89
+ let apiError;
90
+
91
+ if (error.response && error.response.data) {
92
+ apiError = error.response.data;
93
+ } else if (error.message) {
94
+ apiError = { error: error.message, status: 'error' };
95
+ } else {
96
+ apiError = { error: 'An unknown error occurred', status: 'error' };
97
+ }
98
+
99
+ if (callback) {
100
+ callback(apiError, null);
101
+ return; // Don't throw if callback is provided
102
+ }
103
+
104
+ throw apiError;
105
+ }
106
+ }
107
+
108
+ constructURL(query) {
109
+ let url = this.baseURL;
110
+
111
+ if(query && typeof query === 'object')
112
+ {
113
+ if (Object.keys(query).length > 0) {
114
+ const queryString = Object.keys(query)
115
+ .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(query[key])}`)
116
+ .join('&');
117
+ url += `?${queryString}`;
118
+ }
119
+ }
120
+ return url;
121
+ }
122
+ }
123
+
124
+ module.exports = slotmachineWrapper;
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@apiverve/slotmachine",
3
+ "version": "1.1.12",
4
+ "description": "Slot Machine Simulator is a tool for simulating slot machine spins with realistic reel symbols and payout calculations. It supports customizable number of reels, bet amounts, and multiple spins with detailed win/loss statistics.",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "scripts": {
8
+ "test": "mocha",
9
+ "example": "node examples/basic.js"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/apiverve/slotmachine-api.git",
14
+ "directory": "npm"
15
+ },
16
+ "keywords": [
17
+ "slot machine", "slots", "casino simulator", "gambling", "random slots"
18
+ ],
19
+ "author": "APIVerve <hello@apiverve.com> (http://apiverve.com/)",
20
+ "license": "MIT",
21
+ "bugs": {
22
+ "url": "https://github.com/apiverve/slotmachine-api/issues"
23
+ },
24
+ "homepage": "https://apiverve.com/marketplace/slotmachine?utm_source=npm",
25
+ "devDependencies": {
26
+ "mocha": "^11.0.1",
27
+ "chai": "^5.1.2",
28
+ "dotenv": "^16.4.7"
29
+ },
30
+ "dependencies": {
31
+ "node-fetch": "^3.3.2",
32
+ "promise": "^8.3.0",
33
+ "axios": "1.13.2"
34
+ }
35
+ }
package/tmp/build.dat ADDED
@@ -0,0 +1 @@
1
+ #