MrQR API Documentation


The MrQR API lets you generate customizable QR Codes with just a URL so you can make your dynamic QR Codes. This guide walks you through using the API, covering the available parameters, examples, and how to display generated QR codes directly on your website.



API Endpoint

https://mrqr.net/api/v1/

Parameters

  • size (required)
    • Description: Specifies the dimensions of the QR code.
    • Format: widthxheight (e.g., 300x300, 1000x1000 Max)
    • Example: size=300x300

  • color (required)
    • Description: Sets the QR code’s foreground color using a hex code (without #).
    • Format: Hex color code (e.g., ff0000 for red)
    • Example: color=ff0000

  • bgcolor (optional)
    • Description: Defines the background color. Defaults to transparent if not provided.
    • Format: Hex color code (e.g., ffffff for white)
    • Example: bgcolor=ffffff

  • data (required)
    • Description: The content you want to encode in the QR code.
    • Format: Any string (e.g., Hello World, https://example.com)
    • Example: data=Hello+World


Usage Instructions

  1. Constructing the URL:
    • Start with the base endpoint: https://mrqr.net/api/v1/
    • Add the required and optional parameters, separated by &.

  2. URL Encoding:
    • Ensure special characters in data are URL encoded. For example, spaces become + or %20.

  3. Testing the API:
    • Use a browser or tools like curl or Postman to test the API.


Example URLs

  • QR Code with a transparent background:

    Creates a 300x300 red QR code encoding "Hello".

  • https://mrqr.net/api/v1/?size=300x300&color=ff0000&data=Hello

  • QR Code with a white background:

    Creates a 300x300 red QR code with a white background encoding "Hello".

  • https://mrqr.net/api/v1/?size=300x300&color=ff0000&bgcolor=ffffff&data=Hello

  • Simple QR Code with Red Foreground:

    Generates a QR code with red foreground and transparent background encoding "Simple QR Code".

    https://mrqr.net/api/v1/?size=300x300&color=ff0000&data=Simple+QR+Code

  • QR Code with Custom Background:

    Generates a blue QR code with a light gray background encoding "Custom Background".

    https://mrqr.net/api/v1/?size=400x400&color=0000ff&bgcolor=cccccc&data=Custom+Background

  • QR Code Encoding a URL:

    Generates a green QR code with a transparent background encoding a URL.

    https://mrqr.net/api/v1/?size=500x500&color=00ff00&data=https://example.com


Customization Options

  • Change Foreground Color:
    • Modify the color parameter.
    • Example: color=ff00ff for magenta.

  • Change Background Color:
    • Add or modify the bgcolor parameter.
    • Example: bgcolor=000000 for black.

  • Adjust Size:
    • Modify the size parameter.
    • Example: size=600x600 for a larger QR code.


Display QR Code in HTML

You can directly display the generated QR code on your website using the <img> tag by constructing the API URL and setting it as the image source.

<img src="https://mrqr.net/api/v1/?size=300x300&color=ff0000&data=Hello" alt="MrQR API">


Error Handling

  • Missing Parameters:

    If required parameters (size, color, data) are missing, you’ll see an error.

    Missing required parameters. Please provide size, color, and data.

  • Invalid Size Format:

    If the size format is incorrect, you’ll see:

    Invalid size format. Expected format: widthxheight (e.g., 150x150)

Conclusion

The MrQR API is a free-to-use API for generating customizable QR codes from URLs. Modify parameters to create the QR Code that fits your needs. Experiment with different combinations, and refer to error messages if you encounter any issues.