cloudmersive.barcode
Module cloudmersive.barcode
API
Definitions
ballerinax/cloudmersive.barcode Ballerina library
Overview
The Cloudmersive Barcode connector provides programmatic access to the Cloudmersive Barcode API, which lets you generate barcode images and recognize values from images of barcodes. This connector supports version 1 of the API and lets Ballerina applications scan barcode images, look up product data for EAN codes, and generate QR, UPC, EAN and Code 128 barcodes with a few remote method calls.
Key features
- Recognize the value and type of a barcode in an image, including advanced AI recognition of multiple barcodes and QR codes
- Look up product details for an EAN barcode value
- Generate QR, UPC-A, UPC-E, EAN-8, EAN-13 and Code 128 barcodes as PNG images
- Submit QR code recognition as a batch job and poll its status
- Authenticate with a single Cloudmersive API key
Setup guide
To use this connector you need a Cloudmersive API key.
- Sign up or log in at the Cloudmersive portal.
- Open the API Keys page of your account.
- Create a new API key, or copy an existing one.
- Supply the key as the
apikeyfield when you initialize the client. Keep it out of source control, for example by reading it fromConfig.toml.
Quickstart
-
Add the import:
import ballerinax/cloudmersive.barcode; -
Create a
Config.tomlwith your API key:apiKey = "<YOUR_API_KEY>" -
Declare the configurable for the API key:
configurable string apiKey = ?; -
Create the client and invoke an operation:
public function main() returns error? { barcode:Client barcodeClient = check new ({apikey: apiKey}); barcode:BarcodeLookupResponse _ = check barcodeClient->lookupEanBarcode("5901234123457"); }
Examples
The Cloudmersive Barcode connector provides practical examples illustrating usage in various scenarios. Explore these examples, covering the following use cases:
- product_label_generation - Look up a product by EAN and generate its barcode label image.
- barcode_image_lookup - Read a barcode from an image and look up the matching product.
Clients
cloudmersive.barcode: Client
Barcode APIs let you generate barcode images, and recognize values from images of barcodes.
Constructor
Gets invoked to initialize the connector.
init (ApiKeysConfig apiKeyConfig, ConnectionConfig config, string serviceUrl)- apiKeyConfig ApiKeysConfig - API keys for authorization
- config ConnectionConfig {} - The configurations to be used when initializing the
connector
- serviceUrl string "https://api.cloudmersive.com/barcode" - URL of the target service
lookupEanBarcode
function lookupEanBarcode(string payload, map<string|string[]> headers) returns BarcodeLookupResponse|errorLookup EAN barcode value, return product data
Parameters
- payload string - Barcode value
Return Type
- BarcodeLookupResponse|error - Product data for the matched barcode
scanBarcodeImage
function scanBarcodeImage(ScanBarcodeImageRequest payload, map<string|string[]> headers) returns BarcodeScanResult|errorScan and recognize an image of a barcode
Parameters
- payload ScanBarcodeImageRequest -
Return Type
- BarcodeScanResult|error - Recognized value and type of the barcode in the image
scanBarcodeImageAdvanced
function scanBarcodeImageAdvanced(ScanBarcodeImageRequest payload, map<string|string[]> headers) returns BarcodeAdvancedScanResult|errorAdvanced AI scan and recognition of an image of one or more barcodes of any type
Parameters
- payload ScanBarcodeImageRequest -
Return Type
- BarcodeAdvancedScanResult|error - Recognized barcodes found in the image
scanQrBarcodeImageAdvanced
function scanQrBarcodeImageAdvanced(ScanBarcodeImageRequest payload, ScanQrBarcodeImageAdvancedHeaders headers) returns BarcodeScanQRAdvancedResult|errorAdvanced AI scan and recognition of an image of one or more QR barcodes
Parameters
- payload ScanBarcodeImageRequest -
- headers ScanQrBarcodeImageAdvancedHeaders (default {}) - Headers to be sent with the request
Return Type
- BarcodeScanQRAdvancedResult|error - Recognized QR barcodes found in the image
createQrScanBatchJob
function createQrScanBatchJob(ScanBarcodeImageRequest payload, CreateQrScanBatchJobHeaders headers) returns BarcodeBatchJobResult|errorAdvanced AI scan and recognition of an image of one or more QR barcodes as a Batch Job
Parameters
- payload ScanBarcodeImageRequest -
- headers CreateQrScanBatchJobHeaders (default {}) - Headers to be sent with the request
Return Type
- BarcodeBatchJobResult|error - Identifier of the created barcode batch job
getBatchJobStatus
function getBatchJobStatus(map<string|string[]> headers, *GetBatchJobStatusQueries queries) returns BarcodeBatchJobStatusResult|errorGet the status and result of a Barcode Batch Job
Parameters
- queries *GetBatchJobStatusQueries - Queries to be sent with the request
Return Type
- BarcodeBatchJobStatusResult|error - Status and, once completed, result of the barcode batch job
generateQrCode
function generateQrCode(string payload, GenerateQrCodeHeaders headers) returns byte[]|errorGenerate a QR code barcode as PNG file
Parameters
- payload string - QR code text to convert into the QR code barcode
- headers GenerateQrCodeHeaders (default {}) - Headers to be sent with the request
Return Type
- byte[]|error - PNG image of the generated QR code
generateUpcABarcode
function generateUpcABarcode(string payload, GenerateUpcABarcodeHeaders headers) returns byte[]|errorGenerate a UPC-A code barcode as PNG file
Parameters
- payload string - UPC-A barcode value to generate from
- headers GenerateUpcABarcodeHeaders (default {}) - Headers to be sent with the request
Return Type
- byte[]|error - PNG image of the generated UPC-A barcode
generateUpcEBarcode
function generateUpcEBarcode(string payload, GenerateUpcEBarcodeHeaders headers) returns byte[]|errorGenerate a UPC-E code barcode as PNG file
Parameters
- payload string - UPC-E barcode value to generate from
- headers GenerateUpcEBarcodeHeaders (default {}) - Headers to be sent with the request
Return Type
- byte[]|error - PNG image of the generated UPC-E barcode
generateEan13Barcode
function generateEan13Barcode(string payload, GenerateEan13BarcodeHeaders headers) returns byte[]|errorGenerate a EAN-13 code barcode as PNG file
Parameters
- payload string - Barcode value to generate from
- headers GenerateEan13BarcodeHeaders (default {}) - Headers to be sent with the request
Return Type
- byte[]|error - PNG image of the generated EAN-13 barcode
generateEan8Barcode
function generateEan8Barcode(string payload, GenerateEan8BarcodeHeaders headers) returns byte[]|errorGenerate a EAN-8 code barcode as PNG file
Parameters
- payload string - Barcode value to generate from
- headers GenerateEan8BarcodeHeaders (default {}) - Headers to be sent with the request
Return Type
- byte[]|error - PNG image of the generated EAN-8 barcode
generateCode128Barcode
function generateCode128Barcode(string payload, GenerateCode128BarcodeHeaders headers) returns byte[]|errorGenerate a Code 128 barcode as PNG file
Parameters
- payload string - Barcode value to generate from
- headers GenerateCode128BarcodeHeaders (default {}) - Headers to be sent with the request
Return Type
- byte[]|error - PNG image of the generated Code 128 barcode
Records
cloudmersive.barcode: ApiKeysConfig
Provides API key configurations needed when communicating with a remote HTTP endpoint.
Fields
- apikey string - API Key Authentication
cloudmersive.barcode: BarcodeAdvancedResultItem
Advanced barcode scan result instance
Fields
- rawText? string - The barcode text
- barcodeType? string - Type of the barcode; supported barcode types include AZTEC, CODABAR, CODE_39, CODE_93, CODE_128, DATA_MATRIX, EAN_8, EAN_13, ITF, MAXICODE, PDF_417, QR_CODE, RSS_14, RSS_EXPANDED, UPC_A, UPC_E, All_1D, UPC_EAN_EXTENSION, MSI, PLESSEY, IMB
cloudmersive.barcode: BarcodeAdvancedScanResult
Result of the advanced barcode scan
Fields
- barcodeCount? Signed32 - Number of barcodes read
- resultBarcodes? BarcodeAdvancedResultItem[] - Results of performing the barcode scan operation
- errorMessage? string - Error message if any
- successful? boolean - True if the operation was successful, false otherwise
cloudmersive.barcode: BarcodeBatchJobResult
Result of creating a barcode batch job
Fields
- asyncJobID? string - When creating a job, an Async Job ID is returned. Use the GetAsyncJobStatus API to check on the status of this job using the AsyncJobID and get the result when it finishes
- successful? boolean - True if successful, false otherwise
cloudmersive.barcode: BarcodeBatchJobStatusResult
Result of checking on the status of a barcode batch job
Fields
- qRScanResult? BarcodeScanQRAdvancedResult -
- asyncJobID? string - Job ID
- errorMessage? string - Error message (if any)
- successful? boolean - True if the operation to check the status of the job was successful, false otherwise
- asyncJobStatus? string - Returns the job status of the Async Job, if applicable. Possible states are STARTED and COMPLETED
cloudmersive.barcode: BarcodeLookupResponse
Result of performing a barcode lookup
Fields
- matches? ProductMatch[] - Resulting product matches for the input barcode
- successful? boolean - True if operation was successful, false otherwise
cloudmersive.barcode: BarcodeQRResultItem
QR barcode instance
Fields
- rawText? string - The barcode text
cloudmersive.barcode: BarcodeScanQRAdvancedResult
Result of the advanced QR barcode scan
Fields
- barcodeCount? Signed32 - Number of barcodes read
- resultBarcodes? BarcodeQRResultItem[] - Results of performing the QR barcode scan operation
- errorMessage? string - Error message if any
- successful? boolean - True if the operation was successful, false otherwise
cloudmersive.barcode: BarcodeScanResult
Result of the barcode scan
Fields
- rawText? string - The barcode text
- successful? boolean - True if the operation was successful, false otherwise
- barcodeType? string - The type of the barcode; possible values are AZTEC, CODABAR, CODE_39, CODE_93, CODE_128, DATA_MATRIX, EAN_8, EAN_13, ITF, MAXICODE, PDF_417, QR_CODE, RSS_14, RSS_EXPANDED, UPC_A, UPC_E, All_1D, UPC_EAN_EXTENSION, MSI, PLESSEY, IMB
cloudmersive.barcode: ConnectionConfig
Provides a set of configurations for controlling the behaviours when communicating with a remote HTTP endpoint.
Fields
- httpVersion HttpVersion(default http:HTTP_2_0) - The HTTP version understood by the client
- http1Settings ClientHttp1Settings(default {}) - Configurations related to HTTP/1.x protocol
- http2Settings ClientHttp2Settings(default {}) - Configurations related to HTTP/2 protocol
- timeout decimal(default 30) - The maximum time to wait (in seconds) for a response before closing the connection
- forwarded string(default "disable") - The choice of setting
forwarded/x-forwardedheader
- followRedirects? FollowRedirects - Configurations associated with Redirection
- poolConfig? PoolConfiguration - Configurations associated with request pooling
- cache CacheConfig(default {}) - HTTP caching related configurations
- compression Compression(default http:COMPRESSION_AUTO) - Specifies the way of handling compression (
accept-encoding) header
- circuitBreaker? CircuitBreakerConfig - Configurations associated with the behaviour of the Circuit Breaker
- retryConfig? RetryConfig - Configurations associated with retrying
- cookieConfig? CookieConfig - Configurations associated with cookies
- responseLimits ResponseLimitConfigs(default {}) - Configurations associated with inbound response size limits
- secureSocket? ClientSecureSocket - SSL/TLS-related options
- proxy? ProxyConfig - Proxy server related options
- socketConfig ClientSocketConfig(default {}) - Provides settings related to client socket configuration
- validation boolean(default true) - Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
- laxDataBinding boolean(default true) - Enables relaxed data binding on the client side. When enabled,
nilvalues are treated as optional, and absent fields are handled asnilabletypes. Enabled by default.
cloudmersive.barcode: CreateQrScanBatchJobHeaders
Represents the Headers record for the operation: createQrScanBatchJob
Fields
- preprocessing? string - Optional, preprocessing mode, default is 'Auto'. Possible values are None (no preprocessing of the image), SmoothEdges, SmoothEdgesPlus, and Auto (automatic image enhancement of the image - including automatic unrotation of the image - before OCR is applied; this is recommended). Set this to 'None' if you do not want to use automatic image unrotation and enhancement. Set to SmoothEdges to smooth harsh edges in the input image to enhance recognition accuracy. Set to SmoothEdgesPlus to smooth harsh edges to a higher degree
- recognitionMode? string - Optional, recognitionMode mode, default is 'Advanced'. Possible values are Advanced, and Advanced2 which provides the most advanced available barcode recognition
cloudmersive.barcode: GenerateCode128BarcodeHeaders
Represents the Headers record for the operation: generateCode128Barcode
Fields
- width? int - Optional: width of the barcode in pixels. Minimum value of 10
- includeLabel? boolean - Optional: show text label on the image of the barcode value, default is true
- height? int - Optional: height of the barcode in pixels. Minimum value of 10
cloudmersive.barcode: GenerateEan13BarcodeHeaders
Represents the Headers record for the operation: generateEan13Barcode
Fields
- width? int - Optional: width of the barcode in pixels. Minimum value of 10
- includeLabel? boolean - Optional: show text label on the image of the barcode value, default is true
- height? int - Optional: height of the barcode in pixels. Minimum value of 10
cloudmersive.barcode: GenerateEan8BarcodeHeaders
Represents the Headers record for the operation: generateEan8Barcode
Fields
- width? int - Optional: width of the barcode in pixels. Minimum value of 10
- includeLabel? boolean - Optional: show text label on the image of the barcode value, default is true
- height? int - Optional: height of the barcode in pixels. Minimum value of 10
cloudmersive.barcode: GenerateQrCodeHeaders
Represents the Headers record for the operation: generateQrCode
Fields
- width? int - Optional: width of the barcode in pixels. Minimum value of 10
- height? int - Optional: height of the barcode in pixels. Minimum value of 10
cloudmersive.barcode: GenerateUpcABarcodeHeaders
Represents the Headers record for the operation: generateUpcABarcode
Fields
- width? int - Optional: width of the barcode in pixels. Minimum value of 10
- includeLabel? boolean - Optional: show text label on the image of the barcode value, default is true
- height? int - Optional: height of the barcode in pixels. Minimum value of 10
cloudmersive.barcode: GenerateUpcEBarcodeHeaders
Represents the Headers record for the operation: generateUpcEBarcode
Fields
- width? int - Optional: width of the barcode in pixels. Minimum value of 10
- includeLabel? boolean - Optional: show text label on the image of the barcode value, default is true
- height? int - Optional: height of the barcode in pixels. Minimum value of 10
cloudmersive.barcode: GetBatchJobStatusQueries
Represents the Queries record for the operation: getBatchJobStatus
Fields
- asyncJobID string - Job ID for the batch job to get the status of
cloudmersive.barcode: ProductMatch
Matching product for the input barcode
Fields
- eAN? string - EAN code for the product
- title? string - Title of the product
cloudmersive.barcode: ScanBarcodeImageRequest
Fields
- imageFile record { fileContent byte[], fileName string } - Image file to perform the operation on. Common file formats such as PNG, JPEG are supported
cloudmersive.barcode: ScanQrBarcodeImageAdvancedHeaders
Represents the Headers record for the operation: scanQrBarcodeImageAdvanced
Fields
- preprocessing? string - Optional, preprocessing mode, default is 'Auto'. Possible values are None (no preprocessing of the image), SmoothEdges, SmoothEdgesPlus, and Auto (automatic image enhancement of the image - including automatic unrotation of the image - before OCR is applied; this is recommended). Set this to 'None' if you do not want to use automatic image unrotation and enhancement. Set to SmoothEdges to smooth harsh edges in the input image to enhance recognition accuracy. Set to SmoothEdgesPlus to smooth harsh edges to a higher degree
- recognitionMode? string - Optional, recognitionMode mode, default is 'Advanced'. Possible values are Advanced, and Advanced2 which provides the most advanced available barcode recognition
Import
import ballerinax/cloudmersive.barcode;Metadata
Released date: 1 day ago
Version: 2.0.0
License: Apache-2.0
Security
Direct vulnerabilities: No known direct vulnerabilities
Indirect vulnerabilities:
Checked on 2026-11-21 via OSV.dev
Compatibility
Platform: any
Ballerina version: 2201.12.0
GraalVM compatible: Yes
Pull count
Total: 50
Current verison: 1
Weekly downloads
Keywords
Vendor/Cloudmersive
Area/Developer Tools
Type/Connector
Contributors