JavaScript Barcode API Lookup

Many web applications and sites require product data, and given the popularity of JavaScript as a client-side browser scripting language — there's no shortage of JavaScript-powered web 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 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 the client-side scripting language, and meant to run in a web browser.

const product_code = '9781119367956';
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 + '?key=' + api_key;

const opts = {
    method: 'get'
};

fetch(url, opts)
    .then(response => response.json())
    .then((data) => { product_data = data; })
    .catch(err => { throw err });

window.setTimeout(function() {
    console.log("Product Name: 
" + product_data.product.name);
    console.log("Product Description: 
" + product_data.product.description);
    console.log("Product Image URL: 
" + product_data.product.imageUrl);
}, 1000);

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