Aspose.BarCode Cloud SDK for Node.js
- API version: 4.0
- Package version: 26.6.0
SDK and API Version Compatibility:
- SDK Version 25.1 and Later: Starting from SDK version 25.1, all subsequent versions are compatible with API Version v4.0.
- SDK Version 24.12 and Earlier: These versions are compatible with API Version v3.0.
Demo applications
| Scan QR | Generate Barcode | Recognize Barcode |
|---|---|---|
![]() |
![]() |
![]() |
| Generate Wi-Fi QR | Embed Barcode | Scan Barcode |
![]() |
![]() |
![]() |
Aspose.BarCode for Cloud is a REST API for Linear, 2D and postal barcode generation and recognition in the cloud. API recognizes and generates barcode images in a variety of formats. Barcode REST API allows to specify barcode image attributes like image width, height, border style and output image format in order to customize the generation process. Developers can also specify the barcode type and text attributes such as text location and font styles in order to suit the application requirements.
This repository contains Aspose.BarCode Cloud SDK for Node.js source code.
To use these SDKs, you will need Client Id and Client Secret which can be looked up at Aspose Cloud Dashboard (free registration in Aspose Cloud is required for this).
Requirements
- Node.js 18 or later (native
fetchrequired).
How to use the SDK
The complete source code is available in this repository folder. You can either directly use it in your project via source code or get nmpjs distribution (recommended).
AI Agent Skills
This repository includes an AI-agent skill in skills/generate-and-scan-barcode-node/SKILL.md. Point your coding agent to it when working with this SDK so it follows the repo workflow and SDK-specific API patterns.
Install Aspose.BarCode for Cloud via NPM
From the command line:
npm install aspose-barcode-cloud-node --save
Sample usage
The examples below show how your application have to generate QR code and save it on local storage:
const fs = require('fs');
const Barcode = require('aspose-barcode-cloud-node');
const config = new Barcode.Configuration(
'Client Id from https://dashboard.aspose.cloud/applications',
'Client Secret from https://dashboard.aspose.cloud/applications',
null,
process.env['TEST_CONFIGURATION_ACCESS_TOKEN']
);
async function generateBarcode(api) {
const request = new Barcode.GenerateRequestWrapper(
Barcode.EncodeBarcodeType.Qr,
'Aspose.BarCode for Cloud Sample');
request.qrParams = new Barcode.QrParams();
request.qrParams.qrEncodeMode = Barcode.QREncodeMode.Auto;
request.qrParams.qrErrorLevel = Barcode.QRErrorLevel.LevelM;
request.qrParams.qrVersion = Barcode.QRVersion.Auto;
request.qrParams.qrAspectRatio = 0.75;
const oneBarcode = await api.generate(request);
const fileName = 'QR.png'
fs.writeFileSync(fileName, oneBarcode.body);
return fileName;
}
async function scanBarcode(api, fileName) {
const scanRequest = new Barcode.ScanMultipartRequestWrapper(fs.readFileSync(fileName));
const result = await api.scanMultipart(scanRequest);
return result.body.barcodes;
}
const genApi = new Barcode.GenerateApi(config);
const scanApi = new Barcode.ScanApi(config);
console.log('Generating barcode...');
generateBarcode(genApi)
.then(fileName => {
console.log('Barcode saved to ' + fileName);
console.log('Trying to recognize barcode...');
scanBarcode(scanApi, fileName)
.then(barcodes => {
console.log('Recognized barcodes are:');
console.log(JSON.stringify(barcodes, null, 2));
});
})
.catch(err => {
console.error("Error: " + JSON.stringify(err, null, 2));
process.exitCode = 1;
});
Every method returns a chainable promise.
Licensing
All Aspose.BarCode for Cloud SDKs, helper scripts and templates are licensed under MIT License.
Resources
Documentation for API Endpoints
All URIs are relative to https://api.aspose.cloud/v4.0/
| Class | Method | HTTP request | Description |
|---|---|---|---|
| GenerateApi | generate | GET /barcode/generate/{barcodeType} | Generate a barcode using a GET request with parameters in the route and query string. |
| GenerateApi | generateBody | POST /barcode/generate-body | Generate a barcode using a POST request with parameters in the request body in JSON or XML format. |
| GenerateApi | generateMultipart | POST /barcode/generate-multipart | Generate a barcode using a POST request with parameters in a multipart form. |
| RecognizeApi | recognize | GET /barcode/recognize | Recognize a barcode from a file on an Internet server using a GET request with a query string parameter. For recognizing files from your hard drive, use `recognize-body` or `recognize-multipart` endpoints instead. |
| RecognizeApi | recognizeBase64 | POST /barcode/recognize-body | Recognize a barcode from a file in the request body using a POST request with JSON or XML body parameters. |
| RecognizeApi | recognizeMultipart | POST /barcode/recognize-multipart | Recognize a barcode from a file in the request body using a POST request with multipart form parameters. |
| ScanApi | scan | GET /barcode/scan | Scan a barcode from a file on an Internet server using a GET request with a query string parameter. For scanning files from your hard drive, use `scan-body` or `scan-multipart` endpoints instead. |
| ScanApi | scanBase64 | POST /barcode/scan-body | Scan a barcode from a file in the request body using a POST request with a JSON or XML body parameter. |
| ScanApi | scanMultipart | POST /barcode/scan-multipart | Scan a barcode from a file in the request body using a POST request with a multipart form parameter. |





