spinclient v1.1.4
SpinClient
SpinClient is a JavaScript SDK designed to facilitate easier integration with the spin.ac API.
Table of Contents
Installation
To install SpinClient, use your preferred package manager:
# Using npm
npm install spinclient
# Using yarn
yarn add spinclient
# Using pnpm
pnpm add spinclient
Usage
To use SpinClient, you need to create an instance of the SpinClient
class with your API credentials and the base URLs for the API, your website, and the cashier page. You can then use the methods provided by the SpinClient
class to interact with the Spin API.
import { SpinClient } from 'spinclient';
const client = new SpinClient("api_login", "api_password", "https://url.to.api.com", "https://url.to.your.page.com", "https://url.to.cashier.page.com");
// Example: Initializing a game session in demo mode
const demo = await client.getGameDemo("softswiss/DiceBonanza", "USD", "en");
Methods
The following methods are available on the SpinClient
class:
createPlayer
createPlayer(username: string, password: string, currency: string)
playerExists (deprecated)
playerExists(username: string, currency: string)
getGameList
getGameList(
show_systems: 0 | 1,
currency: string,
list_type?: 1 | 2,
show_additional?: boolean
)
getGame
getGame(
username: string,
password: string,
currency: string,
gameid: string,
lang: Language,
play_for_fun: 0 | 1 = 0
)
getGameDemo
getGameDemo(gameid: string, currency: string, lang: Language)
getFreeRounds
getFreeRounds(username: string, password: string, currency: string)
addFreeRounds
addFreeRounds(
username: string,
password: string,
currency: string,
gameid: string,
freespins: number,
bet_level: number,
valid_days: number
)
deleteFreeRounds
deleteFreeRounds(
username: string,
password: string,
currency: string,
gameid: string
)
deleteAllFreeRounds
deleteAllFreeRounds(
username: string,
password: string,
currency: string
)
Helper Functions
The following helper functions are available on the SpinClient
class:
validateWebhook
validateWebhook(
key: string,
timestamp: string,
salt: string,
)
Error Handling
To handle errors in the SpinClient
SDK, you can use the SpinError
class. Here is an example:
import { SpinClient, SpinError } from "spinclient";
const sdk = new SpinClient("api_login", "api_password", "https://url.to.api.com", "https://url.to.your.page.com", "https://url.to.cashier.page.com");
try {
await sdk.deleteAllFreeRounds("example", "password", "USD");
} catch (e) {
if (e instanceof SpinError) {
console.error(`Caught a SpinError with code ${e.code} and message ${e.message}`);
} else {
console.error(`Caught an error with message ${e.message}`);
}
}
Contributing
If you find any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.