npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

snipe-sdk-ts

v1.1.6

Published

Sure, here's the updated README.md markup for your TypeScript code with the new structure:

Downloads

5

Readme

Sure, here's the updated README.md markup for your TypeScript code with the new structure:

# Snipe SDK

The Snipe SDK is a TypeScript library that provides a convenient interface for interacting with the Snipe API. This SDK allows you to perform various actions such as user registration, event tracking, and token management in both development and production environments.

## Installation

To use the Snipe SDK in your TypeScript project, you can install it via npm:

```bash
npm install snipe-sdk-ts

Usage

Initialization

First, you need to initialize the Snipe SDK by providing your API key. The API key determines whether you are using the development or production environment.

import { SnipeSdk } from 'snipe-sdk-ts';

// Initialize with your API key
const apiKey = 'your_api_key';
const snipeSdk = new SnipeSdk(apiKey);

User Registration

You can use the SDK to register users with Snipe. Pass the user's hash as a parameter to the signUp method.

const hash = 'user_hash';
const registrationResponse = await snipeSdk.signUp(hash);
console.log('User Registration Response:', registrationResponse);

Event Tracking

Track events using the trackEvent method. You can specify various event parameters like eventId, transactionAmount, partialPercentage, and debitTokens.

const eventOptions = {
  eventId: 'event_id',
  snipeUserId: 'user_snipe_id',
  // Optional parameters
  transactionAmount: 100,
  partialPercentage: 50,
  debitTokens: { token1: 10, token2: 20 },
};

const eventResponse = await snipeSdk.trackEvent(eventOptions);
console.log('Event Tracking Response:', eventResponse);

Token Management

Retrieve token history and details using the getTokenHistory and getTokenDetails methods.

const tokenHistoryOptions = {
  snipeUserId: 'user_snipe_id',
};

const tokenHistoryResponse = await snipeSdk.getTokenHistory(tokenHistoryOptions);
console.log('Token History Response:', tokenHistoryResponse);

const tokenDetailsOptions = {
  snipeUserId: 'user_snipe_id',
};

const tokenDetailsResponse = await snipeSdk.getTokenDetails(tokenDetailsOptions);
console.log('Token Details Response:', tokenDetailsResponse);

Coin Data Retrieval

Fetch coin data for a user using the getCoinData method.

const coinDataOptions = {
  snipeUserId: 'user_snipe_id',
};

const coinDataResponse = await snipeSdk.getCoinData(coinDataOptions);
console.log('Coin Data Response:', coinDataResponse);

API Key Configuration

The SDK automatically detects whether your API key is for the development or production environment. If your API key is not valid, you will receive an "Invalid API key" response.

Error Handling

Make sure to handle errors appropriately in your code, as network errors or API failures may occur during requests. The SDK will throw errors in case of failures.

try {
  // Your SDK method calls here
} catch (error) {
  console.error('An error occurred:', error);
}

License

This SDK is provided under the MIT License. See the LICENSE file for details.


Please replace `'your_api_key'`, `'user_hash'`, `'event_id'`, `'user_snipe_id'`, and other placeholders with actual values when using the SDK.