Installation
Install the official Loyalty.lt JavaScript SDK
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/sdkyarn add @loyaltylt/sdkpnpm add @loyaltylt/sdkCDN (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 16.0.0 or higher
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.reactQuick Start
// 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
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | - | Your API Key (required) |
apiSecret | string | - | Your API Secret (required) |
environment | 'production' | 'staging' | 'production' | API environment |
locale | string | 'lt' | API locale (lt, en) |
timeout | number | 30000 | Request timeout in ms |
debug | boolean | false | Enable debug logging |
retries | number | 3 | Number of retry attempts |
Getting API Credentials
Access Partners Portal
Go to partners.loyalty.lt and log in to your account.
Navigate to API Credentials
Click API Credentials in the sidebar.
Generate Credentials
Click Generate New Credentials to create your API Key and Secret.
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
Learn how to use the SDK for common operations
Implement QR code-based login
Customer identification via QR code
Pre-built React components