Getting Started
This guide shows you how to install and initialize the Anyline Web SDK for browser-based scanning.
Supported Use Cases
The Web SDK supports scanning for:
-
IDs: MRZ (passports) and AT/DE Driving Licenses
-
Barcodes: 1D, 2D and stacked barcodes
-
Meters: Analog, digital, and dial meters
-
Automotive: VIN, TIN, tire size, tire ID, license plates
-
OCR: Shipping containers, custom OCR
Requirements
-
Devices: Released after 2017 (iOS 10+, Android 7+)
-
Browsers: Chrome (latest) on Android, Safari (latest) on iOS
-
Camera: 1080p recommended (720p minimum)
-
HTTPS: Required for camera access (except localhost for development). Use a local dev server instead of opening files directly.
|
License Requirements The Web SDK license is domain-restricted:
|
Installation
Quick Start
Basic Initialization
import { init } from '@anyline/anyline-js';
const anyline = init({
license: 'YOUR_LICENSE_KEY',
element: document.getElementById('scanner-root'),
preset: 'vin'
});
anyline.onResult = ({ result }) => {
console.log('Scanned:', result);
};
anyline.startScanning();
Self-Hosting Assets
Copy the SDK assets to your public directory:
cp -r node_modules/@anyline/anyline-js/dist/anylinejs public/
Then reference them:
const anyline = init({
license: 'YOUR_LICENSE_KEY',
element: document.getElementById('scanner-root'),
preset: 'vin',
anylinePath: '/anylinejs' // Path to copied assets (absolute from web root)
});
See Performance Optimization for CDN configuration.
Initialization Parameters
Required Parameters
- license (string)
-
Your Anyline license key.
- element (HTMLElement)
-
DOM container where the scanner will be mounted.
const element = document.getElementById('scanner-root');
Optional Parameters
- preset (string)
-
Pre-configured settings for specific use cases. Custom
configvalues override preset defaults while preserving other preset settings.Available Presets
Category Preset Description Barcode
qrQR code scanning only
all_barcode_formatsAll supported 1D and 2D barcode formats
barcode_pdf417PDF417 barcode scanning
barcode_pdf417_parsedPDF417 with AAMVA parsing (US driver’s licenses)
ID Scanning
universalid_mrzMachine Readable Zone (passports, ID cards)
universalid_dl_at_deAustrian and German driving licenses
universalid_dl_at_de_strictAT/DE driving licenses with strict validation
universalid_es_it_ptSpanish, Italian, and Portuguese driving licenses
License Plates
lptGeneral license plate recognition
lpt_euEuropean license plates
lpt_usUnited States license plates
lpt_canadaCanadian license plates
Tire & Automotive
vinVehicle Identification Number (fast mode)
vin_with_user_guidanceVIN with real-time user guidance feedback
tinTire Identification Number
tin_dotTire DOT number
tire_sizeTire size information
tire_idComplete tire identification
Containers
containerHorizontal shipping container codes
containerVerticalVertical shipping container codes
Meters
meterAnalog and digital meter reading
dialmeterDial meter reading
verbundVerbund utility meter
OCR
ocrGeneral optical character recognition
legacy_barcodeLegacy barcode engine (compatibility mode)
See Plugin Configuration for preset customization.
- config (object)
-
Manual plugin configuration. See Plugin Configuration.
- viewConfig (object)
-
UI customization (cutout style, colors, animations). See ViewConfig Reference.
- anylinePath (string)
-
Location of SDK assets. Defaults to CDN if not specified.
anylinePath: '/anylinejs'
Requesting a License
Web SDK licenses are bound to a specific domain. For details on license types and how to request one, see the License Key Generation guide.
SDK Methods
Result Callback
Handle scan results using the onResult callback:
anyline.onResult = ({ result, fullImage }) => {
console.log('Scanned:', result);
};
Callback parameters:
-
result- Scanned data (structure varies by plugin) -
fullImage- Full camera frame (ImageData, may beundefined)
Complete Example
import { init } from '@anyline/anyline-js';
const anyline = init({
license: 'YOUR_LICENSE_KEY',
element: document.getElementById('scanner-root'),
preset: 'vin'
});
// Handle results
anyline.onResult = ({ result }) => {
console.log('Scanned:', result);
anyline.stopScanning();
};
// Start scanning with error handling
anyline.startScanning().catch((error) => {
console.error('Failed to start:', error);
});
// Cleanup when done
window.addEventListener('beforeunload', () => {
anyline.dispose();
});
Next Steps
-
General Examples - Ready-to-use code examples
-
Plugin Configuration - Learn about presets and custom configs
-
API Reference - Complete API documentation
Additional Resources
-
Web SDK Repository - Source code and examples
-
Hosted API Docs - Generated API documentation
-
Example Sheets - Test materials for scanning
-
Generate a License - License creation guide