Skip to main content

Installation

The official Loyalty.lt JavaScript SDK is available on npm and can be used in Node.js, React, Vue, and any JavaScript environment.

NPM / Yarn

npm install @loyaltylt/sdk

CDN (Browser)

For browser-based applications without a build system:
<script src="https://unpkg.com/@loyaltylt/sdk@latest/dist/index.umd.js"></script>
<script>
  const sdk = new LoyaltySDK.LoyaltySDK({
    apiKey: 'lty_xxxxxxxxxxxx',
    apiSecret: 'your_api_secret',
    environment: 'production'
  });
</script>

Requirements

Node.js

Node.js 16.0.0 or higher

TypeScript

TypeScript 4.0+ (optional, types included)

For React Components

If you plan to use the React components (QRLogin, QRCardDisplay), you also need:
npm install react react-dom qrcode.react

Quick Start

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

// Initialize SDK with API credentials
const sdk = new LoyaltySDK({
  apiKey: 'lty_your_api_key',
  apiSecret: 'your_api_secret',
  environment: 'production', // or 'staging'
  locale: 'lt'
});

// Test connection
const shops = await sdk.getShops();
console.log('Connected! Shops:', shops.data);

Configuration Options

OptionTypeDefaultDescription
apiKeystring-Your API Key (required)
apiSecretstring-Your API Secret (required)
environment'production' | 'staging''production'API environment
localestring'lt'API locale (lt, en)
timeoutnumber30000Request timeout in ms
debugbooleanfalseEnable debug logging
retriesnumber3Number of retry attempts

Getting API Credentials

1

Access Partners Portal

Go to partners.loyalty.lt and log in to your account.
2

Navigate to API Credentials

Click API Credentials in the sidebar.
3

Generate Credentials

Click Generate New Credentials to create your API Key and Secret.
4

Copy Credentials

Copy both the API Key (lty_...) and API Secret. Store them securely!
Never expose your API Secret in client-side code. The SDK is designed for server-to-server communication or secure backend integrations.

Next Steps