How to lookup a Barcode Value and return Product Data in Python

Cloudmersive
1 min readJun 2, 2020

Barcodes are a crucial aspect of many businesses, so today we will be setting up a method for using them to look up product data. We shall use an API to speed us on our way.

We will install our client first.

pip install cloudmersive-barcode-api-client

Now we can call barcode_lookup_ean_lookup with this code here. This will simply require our barcode value as a string. This value can be obtained from a photo with our scan barcode API function.

from __future__ import print_functionimport timeimport cloudmersive_barcode_api_clientfrom cloudmersive_barcode_api_client.rest import ApiExceptionfrom pprint import pprint# Configure API key authorization: Apikeyconfiguration = cloudmersive_barcode_api_client.Configuration()configuration.api_key['Apikey'] = 'YOUR_API_KEY'# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['Apikey'] = 'Bearer'# create an instance of the API classapi_instance = cloudmersive_barcode_api_client.BarcodeLookupApi(cloudmersive_barcode_api_client.ApiClient(configuration))value = 'value_example' # str | Barcode valuetry:# Lookup a barcode value and return product dataapi_response = api_instance.barcode_lookup_ean_lookup(value)pprint(api_response)except ApiException as e:print("Exception when calling BarcodeLookupApi->barcode_lookup_ean_lookup: %s\n" % e)

Now run the code and your product data will be returned, simple as that.

--

--

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.