Tutorial

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: [code]https://chart.googleapis.com/chart?[/code]

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 [code]qr[/code], 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.

Shares:
  • kyrul
    December 5, 2011 at 11:09 pm

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

    Reply
  • kyrul
    December 20, 2019 at 2:52 pm

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

    Reply
  • Tom
    Tom
    December 9, 2011 at 6:39 pm

    Good stuff – thanks.

    Reply
  • Tom
    Tom
    December 20, 2019 at 2:52 pm

    Good stuff – thanks.

    Reply
  • ALONZO
    ALONZO
    January 16, 2012 at 8:32 pm

    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

    Reply
  • ALONZO
    ALONZO
    December 20, 2019 at 2:54 pm

    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

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *