Generate a EAN-8 code barcode as PNG file in Python

Cloudmersive
2 min readJan 13, 2022

The Cloudmersive Barcode API is the ideal solution for all your barcode generation needs — from UPC-A to EAN-8, we have you covered. In this article we’ll run through how you can use the /barcode/generate/ean-8 iteration of the Cloudmersive Barcode API in Python. This iteration enables you to generate 1D EAN-8 barcodes in PNG file format; in just a few simple steps and you’ll have the power to crank out EAN-8 barcodes for your smaller-sized retail products.

Your first step will be installing the Python SDK — you can use the below command for that:

pip install cloudmersive-barcode-api-clientfrom __future__ import print_function
import time
import cloudmersive_barcode_api_client
from cloudmersive_barcode_api_client.rest import ApiException
from pprint import pprint

After that, we can go ahead and copy in the rest of our API callback function (relevant documentation included in the code for your convenience), and you’re all set to go:

# Configure API key authorization: Apikey
configuration = cloudmersive_barcode_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'
# create an instance of the API class
api_instance = cloudmersive_barcode_api_client.GenerateBarcodeApi(cloudmersive_barcode_api_client.ApiClient(configuration))
value = 'value_example' # str | Barcode value to generate from
try:
# Generate a EAN-8 code barcode as PNG file
api_response = api_instance.generate_barcode_ean8(value)
pprint(api_response)
except ApiException as e:
print("Exception when calling GenerateBarcodeApi->generate_barcode_ean8: %s\n" % e)

--

--

Cloudmersive

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