Get QR Code with Google Chart API

  • Avinash
  • 3
  • Nov 23, 2011
  • Tutorial

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%2Fwww.xpertdeveloper.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.

Related Posts

Written by Avinash

Avinash Zala is leading various projects which deals with the various technology involved with the web. A combination of perfect technical and management skills. Avinash would like to chat with you and convert your imagination into the working system. You can get in touch with him on Facebook and Twitter.

View all posts by:

  • http://kyrul.com kyrul

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

  • http://www.atominsight.com Tom

    Good stuff – thanks.

  • ALONZO

    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