Generate a QR code barcode as PNG File in Python
QR Codes are one of the most common forms of barcode, providing rapid access to specific information about a product or service for anyone with a device capable of scanning it (i.e., smartphones). The ability to generate these QR codes quickly is a very useful function for a variety of business needs and the Cloudmersive Barcode API makes it easy to do. Specifically, the /barcode/generate/qrcode iteration of the Cloudmersive Barcode API enables you to generate a QR Barcode in PNG file format, encoding free-form text input of your choosing. Let’s look at how you can run this API in Python.
The first thing we’ll need to do is run the SDK installation command:
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 move on to the meat & potatoes. All you have to do is copy in the API authorization key and the callback function. The below code is documented & ready to run for your convenience.
# 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 | QR code text to convert into the QR code barcodetry:
# Generate a QR code barcode as PNG file
api_response = api_instance.generate_barcode_qr_code(value)
pprint(api_response)
except ApiException as e:
print("Exception when calling GenerateBarcodeApi->generate_barcode_qr_code: %s\n" % e)