JavaScript/Node.js Barcode API Lookup

Many programs require product data, and given the growing popularity of JavaScript as a general-purpose programming language — in particular on the Node.js platform — there's no shortage of JS-based apps that need database access to a broad array of product information.

Go-UPC is an ideal solution for such applications — especially those that need to scan barcodes — as our database is vast, it can provide advanced product information, and it includes products across many niches.

Just provide any UPC or EAN (barcode number) to our API and — if we recognize the product — get back a name, image, description, and more.

Example API Code

Find below sample JavaScript/Node.js code that interacts with our API to look up a product by its UPC. In the sample we log product name, description, and image URL after getting a result.

NOTE: This JavaScript example is for Node JS and requires the node package 'axios'.

const axios = require('axios');

const product_code = '9781617294747';
const api_key = 'YOUR API KEY HERE';

const api_base_url = 'https://go-upc.com/api/v1/code/';
const url = api_base_url + product_code;
const opts = {
    method: 'get',
    url: url,
    headers: {
        'Authorization': 'Bearer ' + api_key
    }
}

axios.request(opts).then(function(response) {
    var product_data = response.data;

    console.log(product_data);

    let product_name = product_data.product.name;
    let product_description = product_data.product.description;
    let product_image = product_data.product.imageUrl;

    console.log("Product Name: " + product_name);
    console.log("Product Description: " + product_description);
    console.log("Product Image URL: " + product_image);
}).catch(function(error) {
    console.error(error);
});

For further information about interacting with the API and product fields available, please see our documentation.