@anyline/anyline-js
v55.9.0
Published
Anyline Web SDK
Readme
Anyline Web SDK
Anyline Web SDK enables OCR and barcode scanning directly in the browser.
Live Demo | Documentation | API Reference
Supported Use Cases
- 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.
Installation
npm install @anyline/anyline-jsOr via CDN:
<script src="https://cdn.jsdelivr.net/npm/@anyline/anyline-js/anyline.js"></script>Quick Start
HTML:
<div id="scanner-root" style="width: 100%; height: 100vh;"></div>TypeScript/JavaScript:
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.
Self-Hosting Assets
By default, the SDK loads assets from Anyline's CDN. To self-host these assets for better performance or to comply with network restrictions:
- Copy the
anylinejs/folder to your web server - Set the
anylinePathoption to point to the folder location
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.
Documentation
- Getting Started - Installation, presets, and configuration
- Examples - Code examples for common use cases
- API Reference - Complete API documentation
- Configuration Guide - Plugin and view configuration
Try it Locally
The package includes a demo application. To run it:
- Request a test license for your domain
- Edit your hosts file to route your domain to localhost (licenses are domain-restricted)
- Run the demo:
npm run demo- Visit
http://yourdomain.com:8080/demo
For smartphone testing, use npm run demo:network (HTTPS on port 8443).
Package Contents
- anylinejs/ - Assets for self-hosting
- docs/ - API documentation
- types/ - TypeScript type definitions
- anyline.js - Main SDK library
- LICENSE.md - Third-party license agreements
Resources
- Live Demo
- Example Sheets - Test materials for scanning
- Request a License
License
This SDK requires a commercial license from Anyline. Request a trial license to get started.
See LICENSE.md for third-party license agreements.
