Python Barcode API Lookup

Many applications require product data, and given the popularity of Python as a programming language there's no shortage of Python-based apps and tools that need 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, can provide advanced product information, and includes products in many niches. Provide any UPC or EAN number and (if the product is known) you'll get back a product name, image, description, and more.

Example API Code

Find below sample Python code that interacts with our API to look up a product by UPC. In the sample we print product name, description, and image URL after receiving a result.

This code assumes Python 3, but you should be able to easily adapt it for use in Python 2.

            import urllib.request
            import json
            import pprint

            from urllib.request import Request, urlopen

            upc_to_look_up = '843248155091'
            api_key = 'YOUR API KEY HERE'

            req = Request('https://go-upc.com/api/v1/code/' + upc_to_look_up)
            req.add_header('Authorization', 'Bearer ' + api_key)

            content = urlopen(req).read()
            data = json.loads(content.decode())

            product_name = data["product"]["name"]
            product_description = data["product"]["description"]
            product_image = data["product"]["imageUrl"]

            print("Product Name: " + product_name + "\n")
            print("Product Description: " + product_description + "\n")
            print("Product Image URL: " + product_image + "\n")
          

For further information about interacting with the Go-UPC API and the particular fields and product details provided, please see our documentation.