Web Barcode Scanner SDK - Getting Started
Adding the Dependency
npm
Scanbot Web Barcode Scanner SDK is available as an npm
package:
npm install scanbot-web-sdk --save
You can now import the SDK in your JavaScript or Typescript project:
import ScanbotSDK from 'scanbot-web-sdk'
All SDK modules are available under this ScanbotSDK
object.
When using the ScanbotSDK
object in Typescript projects, most types can be inferred automatically.
However, if necessary, Typescript projects may explicitly include typings by including them from scanbot-web-sdk/@types
, e.g.:
import ScanbotSDK from 'scanbot-web-sdk'
import type { IBarcodeScannerHandle } from 'scanbot-web-sdk/@types'
class MyPage {
// We need to explicitly mention the field's type here. We obtain the type via an `import type` statement from `scanbot-web-sdk/@types`.
private barcodeScanner: IBarcodeScannerHandle;
constructor() {
this.barcodeScanner = ScanbotSDK.createBarcodeScanner();
}
}
Manual Packing
If you are not using npm
in your project, you can still use npm
as a one-time command to download the Scanbot Web SDK package:
# Use npm pack to download the SDK package as a tarball
npm pack scanbot-web-sdk
# Extract the tarball
tar -xf scanbot-web-sdk-*.tgz
Now, you can put a <script src="package/bundle/ScanbotSDK.min.js"></script>
tag in your index.html
.
The script puts the SDK entry point into a global variable named ScanbotSDK
.
Initializing the SDK
After downloading and importing the SDK, you need to initialize it with your license key.
Want to scan longer than one minute?
Generate a free trial license to test the Scanbot SDK thoroughly.
Get your free Trial LicenseWhat do you think of this documentation?
What can we do to improve it? Please be as detailed as you like.