Barcode Reader API - Guide for Developers

In this tutorial, we will see how we can read the barcode value using PDF.co web API. If we go to the documentation, the URL to read the barcode is like api.pdf.co/v1/barcode/read/from/url.

Step 1: Enter API Key and Set Input Parameters

The first input parameter is async. If the input file is a speaker and we want to perform this in async version, we can enable this parameter and it will give us the job ID. After that, we can check the status of this job by using the job check API method and upon the success, we can read the values. If you want the output in the encrypted file format, we can enable this parameter. It provides almost all the common barcode types here. We can provide all supported barcode types in the comma separator format. So it will try to read those values only.

These parameters are for the input files. If you want to pass the URL, we can use this parameter. If you want to pass the file directly, we can use this parameter and these parameter pages for the pages we want to read from. For example, if the PDF file contains many pages, and we want to show that a barcode is only on this page or we want to read only from that page – then we can provide the page number.

In the zero page numbers and the output is the array of the barcodes. It is giving the barcode value along with the different useful information like the type of the barcode or the confidence score or the coordinates where the barcode is read. So, this API, let’s see this in action. Here we have the Node.js implementation of the barcode reading. First of all, we have the placeholder for the API keys. We have the PDF file URL as an input file.

Barcode Reader API

Step 2: Select Barcode Types and Generate Query String

It contains several barcodes. We have variable-like barcode types and we have provided four different kinds of barcodes here. It will try to search for these barcodes only. We have left the pages parameter blank, so it will search for all the pages, and here we generate the query part.

So, we are creating the request option and providing the headers here and then we are performing the GET operation. We are trying to parse to the JSON. The JSON file for the error is false, which means basically it successfully passed. Then we are iterating the barcodes array and we console.log all the parameters.

Read BarCodes Tutorial

Step 3: Execute the Node Command and Check the Result

Let’s fire up the console and let’s execute the node command here. It has started the uploading, let’s wait for the response, and here we got the response. It has found barcodes. Let’s see what it contains. The first bar code is up the type code 138, its value test123.

Barcode Reading Tutorial

That is how you can read barcode values with PDF.co web API.

Check this PDF.co video tutorial on how to use PDF.co Web API and follow us on YouTube!

Video Guide

Related Tutorials

See Related Tutorials