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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@loyaltylt/sdk

v1.0.5

Published

Official JavaScript SDK for Loyalty.lt platform

Readme

Loyalty.lt JavaScript SDK

Official JavaScript SDK for Loyalty.lt Shop API - integrate loyalty program functionality into POS systems and partner applications.

Installation

npm install @loyaltylt/sdk ably
# or
yarn add @loyaltylt/sdk ably

For React components:

npm install @loyaltylt/sdk ably qrcode.react

Quick Start

import { LoyaltySDK } from '@loyaltylt/sdk';

const sdk = new LoyaltySDK({
  apiKey: 'lty_xxxxxxxxxxxx',
  apiSecret: 'xxxxxxxxxxxx',
  environment: 'production',
  locale: 'lt'
});

const session = await sdk.generateQrCardSession('POS Terminal 1');
console.log('QR:', session.qr_code);

const subscription = await sdk.subscribeToQrCardScan(session.session_id, (cardData) => {
  console.log('Customer:', cardData.user.name);
  console.log('Points:', cardData.points);
});

React Components

QRLogin Component

import { QRLogin } from '@loyaltylt/sdk/react';
import '@loyaltylt/sdk/styles';

function LoginPage() {
  return (
    <QRLogin
      config={{
        apiKey: process.env.NEXT_PUBLIC_SHOP_API_KEY,
        apiSecret: process.env.NEXT_PUBLIC_SHOP_API_SECRET,
        shopId: 4,
        deviceName: 'My Shop'
      }}
      callbacks={{
        onAuthenticated: (data) => {
          console.log('User:', data.user);
          console.log('Token:', data.token);
        },
        onScanned: () => console.log('QR scanned!'),
        onError: (error) => console.error(error)
      }}
      texts={{
        title: 'Login with Loyalty.lt',
        subtitle: 'Scan QR code to login'
      }}
      showSendLink={true}
      autoRegenerate={true}
    />
  );
}

QRCardDisplay Component

import { QRCardDisplay } from '@loyaltylt/sdk/react';
import '@loyaltylt/sdk/styles';

function MyCard() {
  return (
    <QRCardDisplay
      userToken={userJwtToken}
      size={200}
      showUserInfo={true}
      showPoints={true}
      autoRefresh={true}
      refreshInterval={30000}
      texts={{
        points: 'Points',
        scanToIdentify: 'Scan to identify'
      }}
    />
  );
}

Configuration

const sdk = new LoyaltySDK({
  apiKey: 'lty_xxxxxxxxxxxx',
  apiSecret: 'xxxxxxxxxxxx',
  environment: 'production', // 'production' | 'staging'
  locale: 'lt',
  timeout: 30000
});

QR Card Scan (POS Integration)

const session = await sdk.generateQrCardSession('POS Terminal');

const subscription = await sdk.subscribeToQrCardScan(session.session_id, (cardData) => {
  console.log('Card:', cardData.card_number);
  console.log('Points:', cardData.points);
  
  if (cardData.redemption?.enabled) {
    const discount = Math.floor(cardData.points / cardData.redemption.points_per_currency) 
                     * cardData.redemption.currency_amount;
    console.log('Discount:', discount, 'EUR');
  }
});

subscription.unsubscribe();

QR Login

const session = await sdk.generateQrLogin('Desktop');

const subscription = await sdk.subscribeToQrLogin(session.session_id, (message) => {
  if (message.data.status === 'authenticated') {
    console.log('Logged in:', message.data.user);
    console.log('Token:', message.data.token);
  }
});

Send App Download Link

await sdk.sendAppLink('+37061234567', 4, 'Customer Name', 'lt');

Transactions

const transaction = await sdk.createTransaction({
  card_number: '123-456-789',
  amount: 50.00,
  points_earned: 50
});

Loyalty Cards

const cards = await sdk.getLoyaltyCards({ page: 1, per_page: 10 });

const card = await sdk.getLoyaltyCardInfo({ card_number: '123-456-789' });

const balance = await sdk.getPointsBalance({ card_number: '123-456-789' });

Offers

const offers = await sdk.getOffers({ is_active: true });

const offer = await sdk.createOffer({
  title: 'New Offer',
  description: 'Description',
  points_required: 100
});

await sdk.updateOffer(offer.id, { title: 'Updated' });

await sdk.deleteOffer(offer.id);

Shops

const shops = await sdk.getShops({ is_active: true, is_virtual: false });

Ably Channels

| Feature | Channel | Event | |---------|---------|-------| | QR Login | qr-login:{session_id} | status_update | | QR Card Scan | qr-card:{session_id} | card_identified |

Error Handling

import { LoyaltySDKError } from '@loyaltylt/sdk';

try {
  await sdk.createTransaction({ ... });
} catch (error) {
  if (error instanceof LoyaltySDKError) {
    console.error('Error:', error.message);
    console.error('Code:', error.code);
    console.error('Status:', error.statusCode);
  }
}

Environments

  • Production: https://api.loyalty.lt
  • Staging: https://staging-api.loyalty.lt

Examples

See /examples folder for:

  • pos-full-example.html - Full POS system with customer display
  • qr-card-scan-example.html - Simple QR card scanning
  • basic-usage.js - Node.js usage examples

Documentation

https://docs.loyalty.lt