@wiicode/wiiqr
v1.0.0
Published
TypeScript SDK for WiiQR dynamic QR code service
Maintainers
Readme
@wiicode/wiiqr
TypeScript SDK for the WiiQR dynamic QR code service.
Installation
npm install @wiicode/wiiqrUsage
import { WiiQRClient } from '@wiicode/wiiqr';
const client = new WiiQRClient({
serverUrl: 'https://api.wiiqr.com',
apiKey: 'wqr_your_api_key_here',
});
// List all QR codes
const { data: qrcodes } = await client.listQRCodes();
// Get a specific QR code
const qrcode = await client.getQRCode('qr-code-id');
// Create a new QR code
const newQR = await client.createQRCode({
destination: 'https://example.com/menu',
label: 'Restaurant Menu',
});
// Update destination (the QR code image stays the same!)
await client.updateQRCode(newQR.id, {
destination: 'https://example.com/new-menu',
});
// Get QR code image as buffer
const imageBuffer = await client.getQRImage(newQR.id);
// Get the redirect URL
const redirectUrl = client.getRedirectUrl(newQR.shortCode);
// => "https://api.wiiqr.com/r/abc123"API Reference
WiiQRClient
Constructor
new WiiQRClient(config: WiiQRConfig)serverUrl: The WiiQR API server URLapiKey: Your tenant API key (starts withwqr_)
Methods
| Method | Description |
|--------|-------------|
| listQRCodes(page?, limit?) | List all QR codes for your tenant |
| getQRCode(id) | Get a specific QR code by ID |
| getQRImage(id) | Get QR code PNG image as ArrayBuffer |
| createQRCode(dto) | Create a new QR code |
| updateQRCode(id, dto) | Update a QR code's destination or metadata |
| deleteQRCode(id) | Delete a QR code |
| getRedirectUrl(shortCode) | Get the public redirect URL |
Dynamic QR Codes
WiiQR generates dynamic QR codes with static URLs. When scanned, the QR code redirects to your configured destination. You can change the destination at any time without regenerating the QR code image.
QR Code → /r/{shortCode} → 302 Redirect → Your Destination URLLicense
MIT
