Barcode Generator API

Overview

Barcode Generator API with over 20 barcode types and NodeJS backed super fast response. Customize the design of the final image by changing parameters. Barcode is returned in Base64 encoded format.

Start using this api on RapidAPI for Free

 

Version 2 Documentation

Barcode Generator API accepts GET requests from any app. You have to signup with RapidAPI and use your secret key with each request.

Here is an example request using NodeJS and Axios:


const axios = require("axios");

const options = {
  method: 'GET',
  url: 'https://barcode-generator4.p.rapidapi.com/',
  params: {
    text: '12345678910',
    barcodeType: 'CODE128',
    width: '4',
    height: '40',
    displayValue: 'true',
    textAlign: 'center',
    textPosition: 'bottom',
    textMargin: '2',
    fontSize: '20',
    background: '#ccffff',
    lineColor: '#000000',
    margin: '10',
    marginLeft: '10',
    marginRight: '10',
    marginTop: '10',
    marginBottom: '10',
    mod43: 'false',
    ean128: 'false',
    flat: 'false'
  },
  headers: {
    'X-RapidAPI-Key': 'your_rapid_api_key',
    'X-RapidAPI-Host': 'barcode-generator4.p.rapidapi.com'
  }
};

axios.request(options).then(function (response) {
	console.log(response.data);
	console.log(response.data.status, response.data.msg, response.data.barcode, response.data.number, );
}).catch(function (error) {
	console.error(error);
});

The response will look like the following:

{
  "status": "success",
  "msg": "",
  "barcode": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAdQAAABSCAYAAADtuSUdAAAABmJLR0QA/wD/AP+gvaeTAAAO/ElEQVR4nO3ce3hNV+LG8e9xyQUJFYTENSGUpEwbBHVNqxRpqHZcWo2QqtTTH9qmGUN/VFstUzXqEloUMwaV1LRBXOIuNC4pSqoiKo07UakQSZzMH5EzPTmHBHvc+n6eJ39k7bXXWnufPOfN2nvtbdqVn5+PiIiI3JFS93oAIiIiDwMFqoiIiAEUqCIiIgZQoIqIiBhAgSoiImIABaqIiIgBFKgiIiIGUKCKiIgYQIEqIiJigDIlrehvMt10+64iL1wqWr/o9lttv7j+imuvuPHdafvFudPxFud/fbzF9Vece308Rh9/Ubc6XqP/voq62+frTv8e7vTzNrq/oow+vuLq32n/d9r+//p83e3vm7v1",
  "number": "12345678910"
}

Details of request parameters:

  1. text (required)
    The text that will be converted to a barcode.
    Default: 12345678910
  2. barcodeType (optional)
    Select one from the following barcode type: CODE39, CODE128, CODE128A, CODE128B, CODE128C, EAN13, EAN8, EAN5, EAN2, UPC, UPCE, ITF14, ITF, MSI, MSI10, MSI11, MSI1010, MSI1110, pharmacode, codabar.
    Default: CODE128
  3. width (optional)
    The width of a single bar.
    Default: 4
  4. height (optional)
    The height of the barcode.
    Default: 40
  5. displayValue (optional)
    Show/hide the text of the barcode.
    Default: true.
  6. textAlign (optional)
    Horizontal alignment of the text. Select from left/center/right.
    Default: center
  7. textPosition (optional)
    Vertical position of the text value. Select from top/bottom.
    Default: bottom
  8. textMargin (optional)
    The gap between text and barcode.
    Default: 2
  9. fontSize (optional)
    Font size of the text value.
    Default: 20
  10. background (optional)
    Background color of the barcode in hexadecimal color code.
    Default: #ccffff
  11. lineColor (optional)
    Bar and text color of the barcode in hexadecimal color code.
    Default: #000000
  12. margin (optional)
    Set the space margin around the barcode. If nothing else is set, all sides will inherit this margin property, but they can also be set separately.
    Default: 10
  13. marginLeft (optional)
    Margin on the left side of the barcode. Setting this will override the margin parameter value.
    Default: 10
  14. marginRight (optional)
    Margin on the right side of the barcode. Setting this will override the margin parameter value.
    Default: 10
  15. marginTop (optional)
    Margin on the top side of the barcode. Setting this will override the margin parameter value.
    Default: 10
  16. marginBottom (optional)
    Margin on the bottom side of the barcode. Setting this will override the margin parameter value.
    Default: 10
  17. mod43 (optional)
    Only applicable for CODE39
    CODE39 can be used with an optional Modulo 43 check digit. You can do this by setting the mod43 option to true. If you want to use this feature, you need to enable it in the barcode reader.
    Default: false
  18. ean128 (optional)
    Only applicable for CODE128
    CODE128 can be encoded as GS1-128/EAN-128. Set the ean128 to true to use this feature.
    Default: false
  19. flat (optional)
    Only applicable for EAN13/EAN8/UPC/ UPCE
    EAN13, EAN8, UPC and UPCE barcodes can be rendered without guard bars. If you want a flat rendering, you can specify the flat option and skip the guard bars.
    Default: false

 

Types of Barcodes and Examples

CODE39: CODE39 is a barcode type that can encode numbers, uppercase letters and a number of special characters (-, ., $, /, +, %, and space). It is not as common as CODE128, but it may be used for legacy reasons.

CODE39

CODE128/CODE128A/CODE128B/CODE128C: CODE128 is a versatile barcode that supports all 128 ASCII characters, as well as numbers. It has three modes (A/B/C), and can switch between them at any time. CODE128 is the default barcode that this API will choose if no other barcode is specified.

CODE128

EAN13/EAN8/EAN5/EAN2/UPC/UPCE: EAN is a barcode standard that is used to identify products. The most common form of EAN is EAN-13, which is used worldwide to mark the identity of products. This API supports the EAN-13, EAN-8, and UPC formats, as well as the EAN-5 and EAN-2 barcode add-ons.

EAN13

ITF14/ITF: The ITF-14 barcode is used to encode a Global Trade Item Number. ITF-14 symbols are generally used on packaging levels of a product, such as a case box of 24 cans of soup. The ITF-14 will always encode 14 digits. The last digit of an ITF-14 barcode is an checksum. It is normally included but this API can automatically calculate it for you if it is left out.

ITF14

MSI/MSI10/MSI11/MSI1010/MSI1110: MSI or Modified Plessey is a barcode developed by the MSI Data Corporation and is primarily used for inventory control, marking storage containers and shelves in warehouse environments. It supports digits 0-9. This API provides automatic checksum calculation of Mod 10, Mod 11, Mod 1010 and Mod 1110. This barcode is used to increase efficiency and accuracy in warehouse inventory management. This API provides a checksum calculation feature that helps to ensure the validity of the code.

MSI

pharmacode: Pharmacode is a barcode used in the pharmaceutical industry that can encode numbers from 3 to 131070. This barcode system is used to track and manage inventory in pharmacies, as well as to identify and authenticate prescription medications.

pharmacode

codabar: Codabar is a barcode type that can encode numbers and a number of special characters (–, $, :, /, +, .). You can set start and stop characters to A, B, C or D but if no start and stop character is defined A will be used. Codabar allows you to encode data in a variety of ways, making it a versatile barcode type.
codabar

 

Version 1 Documentation (deprecated)

Field: imageType(Types of output images)
PNG (Default)/JPG/SVG

Field: barcodeType(Types of barcodes)

C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128 (Default), C128A, C128B, C128C, EAN2, EAN5, EAN8, EAN13, UPCA, UPCE, MSI, MSI+, POSTNET, PLANET, RMS4CC, KIX, IMB, CODABAR, CODE11, PHARMA, PHARMA2T

Example request for version 1:

import axios from "axios";

const options = {
  method: 'GET',
  url: 'https://barcode-generator4.p.rapidapi.com/',
  params: {text: '123456', barcodeType: 'C128', imageType: 'PNG'},
  headers: {
    'X-RapidAPI-Key': 'your_rapid_api_key',
    'X-RapidAPI-Host': 'barcode-generator4.p.rapidapi.com'
  }
};

axios.request(options).then(function (response) {
	console.log(response.data);
}).catch(function (error) {
	console.error(error);
});

The response will look like the following:

{
  "status": "success",
  "msg": "",
  "barcode": "data:image/PNG;base64,iVBORw0KGgoAAAANSUhEUgAAAIgAAAAeCAQAAABdjJ6HAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QA/4ePzL8AAAB3SURBVFjD7dBBDoAgDAXRX+9/57qQBU5o9ADzNhKhkEyl86gkvb5Z62x72fb78H86m4/ZaX6a6WG2Dvf8eQtvXNGLQcAgYBAwCBgEDAIGAYOAQcAgYBAwCBgEDAIGAYOAQcAgYBAwCBgEDAIGAYOAQcAgYBAwCNzLfRM7iDfwNAAAAABJRU5ErkJggg=="
}