How to Generate an EAN-8 Barcode Image using Python

2 min readJan 31


If you’re shipping products to a global market, and those products are too small (lacking physical real estate) for placing barcode labels, chances are high that you’re going to use EAN-8 barcodes to label your products. With your EAN-8 numbers acquired, you can use the below API solution in Python to quickly and seamlessly convert your barcode numbers into 1D PNG EAN-8 barcode images.

This is a limited free-to-use solution when you register a free account on our website (this account provides a limit of 800 API calls per month with NO additional commitments — i.e., you won’t be charged when you reach that limit, your total will reset).

To take advantage of this solution, first install the SDK by running the below command:

pip install cloudmersive-barcode-api-client

To call the function, first add the imports & copy in the remaining code below:

from __future__ import print_function
import time
import cloudmersive_barcode_api_client
from import ApiException
from pprint import pprint

# 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

# Generate a EAN-8 code barcode as PNG file
api_response = api_instance.generate_barcode_ean8(value)
except ApiException as e:
print("Exception when calling GenerateBarcodeApi->generate_barcode_ean8: %s\n" % e)

All done! Now you can generate barcodes at scale with a quick & powerful service at your disposal.




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