snipe-sdk
v2.0.0
Published
Snipe SDK is a TypeScript library designed for interacting with the Snipe API. It provides a straightforward and efficient way to integrate various Snipe API functionalities into your application, including user signup, tracking events, managing token his
Downloads
3
Readme
Snipe SDK Node.js
Introduction
Snipe SDK is a TypeScript library designed for interacting with the Snipe API. It provides a straightforward and efficient way to integrate various Snipe API functionalities into your application, including user signup, tracking events, managing token history, and accessing coin data.
Installation
Before you can use the Snipe SDK, you need to install it in your project. You can do this using npm:
npm install snipe-sdk-ts --save
Usage
To start using the Snipe SDK, import it into your project and initialize it with your API key.
Initialization
import { SnipeSdk } from "snipe-sdk-ts";
const apiKey = "your_api_key";
const snipeSdk = new SnipeSdk(apiKey);
Example Usage
Sign Up
let snipe_id = "";
const hash = "user_hash";
snipeSdk.signUp(hash)
.then(res => {
console.log(res.data.value.snipe_id);
snipe_id = res.data.value.snipe_id;
})
.catch(err => {
console.log(err);
});
Track Event
const eventOptions = {
eventId: "event_id",
snipeUserId: "user_id",
transactionAmount: 100, // Optional
partialPercentage: 50, // Optional
debitTokens: { token1: 10, token2: 20 } // Optional
};
snipeSdk.trackEvent(eventOptions)
.then(res => {
console.log("trackEvent: ", res);
})
.catch(err => {
console.log(err);
});
Get Token History
snipeSdk.getokenHistory({ snipeUserId: "user_id" })
.then(res => {
console.log("getokenHistory: ", res);
})
.catch(err => {
console.log(err);
});
Get Token Details
snipeSdk.getokenDetails({ snipeUserId: "user_id" })
.then(res => {
console.log("getokenDetails: ", res);
})
.catch(err => {
console.log(err);
});
Get Coin Data
snipeSdk.getCoinData({ snipeUserId: "user_id" })
.then(res => {
console.log("getCoinData: ", res);
})
.catch(err => {
console.log(err);
});
Get Token History with Filters
snipeSdk.getokenHistoryWithFilter({
snipeUserId: "user_id",
queryParameters: {
page: 1,
page_size: 10,
transaction_type: "credit"
}
})
.then(res => {
console.log("getokenHistoryWithFilter: ", res);
})
.catch(err => {
console.log(err);
});
Note: Ensure to replace "your_api_key" with your actual API key and adjust the example parameters as per your application's context.