Get QR Code with Google Chart API

From the arrival of the smartphone we can say technology have found another creative way to share the data. QR Code is one of the method to share the data in very effective way.

QR Code stands for “Quick Response code”. Now a days QR is widely used for sharing the data in easy and effective way. You just have to point your app in front of the code and you got the data.

QR Code stands for “Quick Response code”

In this article I am going to show how to generate the QR Code for the data you want to share either it is link or any other data.

I will lead you to very easy way to perform this task.

As we all now Google has large number of API and chart API is one of them. With this API we can draw various charts but in this article I will show drawing of the QR Code only.

So let’s start with that:

We can get this QR Code with simple GET request only. Here is the base URL for this request.

Base URL: https://chart.googleapis.com/chart?

We have to pass various parameter to get the QR Code image based on our requirements.

1) cht=qr

This is the required parameter and value must be set to qr, so google can understand that I have to server the QR Code.

2) chs=[width]x[height]

This is required parameter and which provide the size of the images to serve.

3) chl=[data]

This is also an required parameter and this parameter will contain the main information which we want to share using the QR Code. It can be either link or plain text data.

This parameter can contain number, characters and binary byte of data. We have to limit the size of the data as we are passing it in GET request which has limit of 2KB.

We have to encode this data before passing to the URL.

Other two parameter are optional and which are useful to define the output encoding and error correction level.

So finally our url will looks like below:

https://chart.googleapis.com/chart?cht=qr&chs=150×150&chl=http:%2F%2Fxpertdeveloper.com

Final Output

Expert Developer QR Code

It would be great to share if you have any other way to generate the QR Code effectively.

About the Author: Avinash

Experienced full stack freelance web developer with a track record of producing excellent results for 11+ years. Excellent communication and collaboration skills, managing with a team of 20+ people. I’m motivated to make a positive impact on your revenue through the customer web portal development project.

3 Comments

  1. kyrul December 5, 2011 at 11:09 pm - Reply

    nice tuto dude! in my blog also have a post on how to create a qr code.Chek it out

  2. kyrul December 20, 2019 at 2:52 pm - Reply

    nice tuto dude! in my blog also have a post on how to create a qr code.Chek it out

  3. Tom December 9, 2011 at 6:39 pm - Reply

    Good stuff – thanks.

  4. Tom December 20, 2019 at 2:52 pm - Reply

    Good stuff – thanks.

  5. ALONZO January 16, 2012 at 8:32 pm - Reply

    How can I create a VCAL QR code that driven by a variable spread sheet with google chart? I’ve been struggling with this for a while

    Thanks

  6. ALONZO December 20, 2019 at 2:54 pm - Reply

    How can I create a VCAL QR code that driven by a variable spread sheet with google chart? I’ve been struggling with this for a while

    Thanks

Leave A Comment

FREE QUOTE

Do you need help with services? Request a free quote to get in touch.