Generate Barcodes via API
import axios from "axios";
import { createFileSync } from "fs";
const options = {
method: 'GET',
url: 'https://text-to-anything.p.rapidapi.com/generateBarcode',
params: {
content: '0123456789',
type: 'code128',
scale: '3',
height: '10',
includeText: 'true'
},
headers: {
'x-rapidapi-key': '{Your-RapidAPI-Key}',
}
};
const response = await axios.request(options);
console.log(response.data);
createFileSync('barcode.png', response.data, 'binary');
Inside of the operation you have the following options:
Option | Type | Description |
---|---|---|
content | string | The content of the barcode. |
type | string | The type of barcode. Can be "code128", "ean13", "ean8", "upca", ect. |
scale | number | The scale of the barcode. The default is "3". |
height | number | The height of the barcode. The default is "10". |
includeText | boolean | Should the barcode include the text? The default is "false". |
Output
The endpoint will return the generated file as result.