Anyline Web SDK
npm install @anyline/anyline-js

Anyline Web SDK enables OCR and barcode scanning directly in the browser.
Live Demo | Documentation | API Reference
- Barcode - QR Code, Data Matrix, Aztec, PDF417, Code 128, EAN, UPC, and more
- ID Scanning - MRZ (passports, ID cards) and driving licenses
- Tire & Automotive - VIN, TIN, tire size, license plates
- Meters - Analog, digital, and dial meters
- OCR - Shipping containers and custom OCR
See the documentation for the full list of supported formats and regions.
``bash`
npm install @anyline/anyline-js
Or via CDN:
`html`
HTML:
`html`
TypeScript/JavaScript:
`typescript
import { init } from '@anyline/anyline-js';
// Initialize the scanner
const anyline = init({
// Your Anyline license key (obtain at anyline.com/request/contact)
license: 'YOUR_LICENSE_KEY',
// DOM element where the scanner will be mounted
element: document.getElementById('scanner-root'),
// Preset for the scan type (see documentation for all presets)
preset: 'vin',
});
// Handle scan results
anyline.onResult = ({ result }) => {
console.log('Scanned:', result);
};
// Start the camera and begin scanning
anyline.startScanning().catch((error) => {
console.error('Failed to start:', error);
});
// Clean up resources when done
window.addEventListener('beforeunload', () => {
anyline.dispose();
});
`
> Note: Web SDK requires HTTPS (except localhost) and camera permissions. The browser will prompt the user to allow camera access.
For available presets and configuration options, see the Getting Started Guide.
By default, the SDK loads assets from Anyline's CDN. To self-host these assets for better performance or to comply with network restrictions:
1. Copy the anylinejs/ folder to your web serveranylinePath
2. Set the option to point to the folder location
`typescript`
const anyline = init({
license: 'YOUR_LICENSE_KEY',
element: document.getElementById('scanner-root'),
preset: 'vin',
anylinePath: '/path/to/anylinejs',
});
See Performance Optimization for CDN configuration and caching details.
- Getting Started - Installation, presets, and configuration
- Examples - Code examples for common use cases
- API Reference - Complete API documentation
- Configuration Guide - Plugin and view configuration
The package includes a demo application. To run it:
1. Request a test license for your domain
2. Edit your hosts file to route your domain to localhost (licenses are domain-restricted)
3. Run the demo:
`bash`
npm run demo
4. Visit http://yourdomain.com:8080/demo
For smartphone testing, use npm run demo:network` (HTTPS on port 8443).
- anylinejs/ - Assets for self-hosting
- docs/ - API documentation
- types/ - TypeScript type definitions
- anyline.js - Main SDK library
- LICENSE.md - Third-party license agreements
- Live Demo
- Example Sheets - Test materials for scanning
- Request a License
This SDK requires a commercial license from Anyline. Request a trial license to get started.
See LICENSE.md for third-party license agreements.