• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Rapid Blog

  • Enterprise
  • API Hub
  • Add Your API
  • About
  • Docs
    • API Glossary
  • Blog
    • What is an API?
    • REST API Tutorials
    • Most Popular APIs
    • Write for Us
  • Sign Up
    • Log In
Blog » API Tutorials » Python API Tutorials » How to add QR Code Functionality to your App or Website

How to add QR Code Functionality to your App or Website

By RapidAPI Staff // September 14, 2020

Table of Contents

  • How to get access to the Custom QR Code with Logo API
    • 1. Sign Up for a RapidAPI user account.
    • 2. Find the Custom QR Code with the Logo API page.
    • 3. Subscribe to the API.
  • How to use the Custom QR Code with Logo API
  • Sample application that uses the Custom QR Code with Logo API
    • 1. Form a request using the RapidAPI interface to create the body and test the request.
    • 2. Copy the Python Code to your Script
    • 3. Finish the Script
    • 4. Test the Application
  • Conclusion

QR (Quick Response) codes are now everywhere. They simplify human lives and are used widely in marketing campaigns, products, banking, media, etc. In the era of smartphones, the value of QR code applications is rapidly increasing. This means that if you develop your web, mobile, or even desktop app, you might need to be able to support QR code generation and recognition. Fortunately, a feature for generating QR codes can be easily done using a special API.

How to get access to the Custom QR Code with Logo API

Custom QR Code with Logo API is available on the RapidAPI platform. To start using this API you should perform the following steps:

1. Sign Up for a RapidAPI user account.

After registration, you will get access to over than 10000 APIs on RapidAPI – the world’s largest APIs marketplace. There are APIs for computer vision, natural language processing, geolocation, finance, gaming, sport, flight booking, and many, many others. All you need to do to find the right one is to choose the features your applications need.

2. Find the Custom QR Code with the Logo API page.

To do this, you can use the direct link, search functionality of the RapidAPI website, or browse the categories menu:

rapidapi

3. Subscribe to the API.

To start using the API on the RapidAPI platform you should choose the pricing plan:

custom qr code api pricing

Hint: there are free basic plans for many APIs which are ideal for exploration.

Now you are ready to use the Custom QR Code with Logo API.

How to use the Custom QR Code with Logo API

Custom QR Code with Logo API is rather easy to use. It has 3 functions:

  1. Create custom QR code (has both GET and POST endpoints);
  2. Create a custom transparent QR code (has both GET and POST endpoints);
  3. Upload an image to be used as a logo or as a background in transparent QR code.

custom qr code api endpoints

In this article, we will be using the Create custom QR code (GET) endpoint. RapidAPI does a pretty good job of describing most parameters. But it is not true for the “config” parameter as it is a JSON and contains a lot of parameters in itself. You can read more about “body” parameters in the official documentation. But we will briefly take a look at some of the key parameters:

  • body – shape of small figures around the QR code;
  • eye – shape of a frame surrounding corner figures;
  • eyeBall – shape of corner figures;
  • bodyColor – color of small figures;
  • bgColor – background color (should be lighter to be scannable);
  • eye/1/2/3/Color – color of a specific “eye”;
  • eyeBall/1/2/3/Color – color of a specific “eyeBall”;
  • logo – usage of uploaded to this website logo;

*Note: all colors should be hex values. E.g. “#000000” for black.

Sample application that uses the Custom QR Code with Logo API

Custom QR Code with Logo from qrcode-monkey.com provides great possibilities in terms of design. The design itself can be used to make a QR logo for a number of URLs. Let’s say you have an eCommerce app and you have to return a QR Code for each payment. In this example, we will do just that.

We could use the Create Custom QR Code GET endpoint for this. But we will use Create Custom QR Code POST because all the data comes in one JSON while GET does not relieve us from using JSON completely.

1. Form a request using the RapidAPI interface to create the body and test the request.

After a little testing and playing with the design we have the following body:

custom qr code api response body

From the sample config, we have changed cosmetic parameters: “bodyColor”, “eye1Color”, etc. Also, we have changed “data” to point to rapidapi.com and logo so we have a logo of RapidAPI on the QR code. Of course, in a practical case, these parameters will point to the payment URL and have (or not, as a logo is optional) your app logo.

2. Copy the Python Code to your Script

In the right section of the RapidAPI interface, we can navigate to “Code snippets” and select the programming language and specific libraries to get the code we need.

rapidapi code snippets

Now we can copy the code and paste it in the script we are going to use.

3. Finish the Script

import requests
import sys

url = "https://qrcode-monkey.p.rapidapi.com/qr/custom"

target_url = sys.argv[1]

payload = "{'data':{target_url},'config':{'body':'leaf','eye':'frame1','eyeBall':'ball0','erf1':[],'erf2':[],'erf3':[],'brf1':[],'brf2':[],'brf3':[],'bodyColor':'#1c4473','bgColor':'#FFFFFF','eye1Color':'#71859c','eye2Color':'#71859c','eye3Color':'#71859c','eyeBall1Color':'#1c4473','eyeBall2Color':'#1c4473','eyeBall3Color':'#1c4473','gradientColor1':'#526a8c','gradientColor2':'#526a8c','gradientType':'linear','gradientOnEyes':false,'logo':'https://www.finsmes.com/wp-content/uploads/2018/03/rapidapi.jpg'},'size':600,'download':false,'file':'png'}"

headers = {
    'x-rapidapi-host': "qrcode-monkey.p.rapidapi.com",
    'x-rapidapi-key': "***************************************",
    'content-type': "application/json",
    'accept': "application/json"
    }

r = requests.request("POST", url, data=payload, headers=headers)

if r.status_code == 200:
    with open('result.png', 'wb') as f:
        for chunk in r:
            f.write(chunk)

You may notice  that there are few changes to the script:

  • We added ‘sys’ library and used ‘sys.argv[1]’ to get the URL we want our QR to point to from the command line.
  • “(double quotes) in payload replaced with ‘(single quotes). This way the string is more readable and can be used as an ‘f-string’.
  • Finally, at the end of the script, we added some commands to decode and save the image as a file for further use.

4. Test the Application

To test the script we only need to start it from the command line:

python script.py rapidapi.com

where “rapidapi.com” is the target URL.
Just like that, we got the custom QR Code downloaded:

python custom qr code rapidapi

Conclusion

QR codes can be used for a wide variety of scenarios in your applications. For example, you can send your customers QR codes so that they can just scan it and immediately get sent to the payment page. As the URLs of the payment pages can be unique, your system will recognize completed payments. This can help in the monitoring of business metrics as well as in accounting.

The perfect use case for QR code application would be a situation when you need to conveniently and quickly share some information with somebody. To simplify it, you can use the Custom QR Code with Logo API in your application. In this tutorial, that we hope was helpful for you, we tried to cover the basic functionality of the API. Note, that the RapidAPI platform has a lot of other useful APIs so you can make your applications more powerful and efficient.

5/5 - (1 vote)
« Top 7 Best PHP API Frameworks for REST APIs
How to Use Microsoft Azure Cognitive Services on RapidAPI »

Related Blog Posts

How to Use the Telize API with Python, PHP, Ruby & Javascript Examples
How to Use the Telize API with Python, PHP, Ruby & Javascript Examples

How to Use the Currency Exchange API with PHP, Python, Ruby & JavaScript Examples
How to Use the Currency Exchange API with PHP, Python, Ruby & JavaScript Examples

How to Use the Custom QR Code with Logo API with Python, PHP, Ruby & Javascript Examples
How to Use the Custom QR Code with Logo API with Python, PHP, Ruby & Javascript Examples

How to Use the Love Calculator API with Python, PHP, Ruby & JavaScript Examples
How to Use the Love Calculator API with Python, PHP, Ruby & JavaScript Examples

How To Scrape Hashtags with Twitter API using Python
How To Scrape Hashtags with Twitter API using Python

How to use Google Vision API with Python
How to use Google Vision API with Python


Filed Under: Python API Tutorials, REST API Tutorials Tagged With: custom qr code with logo, python, qr code, qr code generator

Avatar photo

RapidAPI Staff

The RapidAPI staff consists of various writers in the RapidAPI organization. For support, please email us at support@rapidapi.com.

Reader Interactions

Comments

  1. shaik laiq says

    July 7, 2020 at 5:32 am

    i want to use in C# can you give me example

    Reply

Leave a Reply

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

Primary Sidebar

Build anything with APIs, faster.

Discover, evaluate, and integrate with any API. RapidAPI is the world’s largest API Hub with over 4 Million developers and 35,000 APIs.

Browse APIs »

Footer

  • API Guides
  • API Courses
  • API Glossary
  • API Testing
  • API Management
  • How to use an API
  • For API Providers
  • Most Popular APIs
  • For Developers
  • Free APIs List
  • Learn REST API
  • Build API’s
  • About
  • Team
  • Careers
  • Contact Us
  • Write for Us
  • API Directory
  • Press Room
  • Privacy Policy
  • Terms of Use

© 2023 RapidAPI. All rights reserved.