QR Code Generation API
Welcome to the QR Code Generation API documentation! This guide will help you get started with generating customized QR codes using various parameters.
Quick Start
To generate a QR code, make a GET request to the following endpoint:
https://fetchqr.org/api?YOUR_TEXT_HERE
Replace YOUR_TEXT_HERE with the content you want to encode in the QR code.
QR Code Parameters
Customize your QR code using the following query parameters. Some parameters are optional, and default values are provided.
| Parameter Name | Description | Required? | Default Value |
|---|---|---|---|
data | Content of the QR code (can be a URL or any other string) | Yes | |
format | Format of QR code, either png, jpg, jpeg, pdf, or svg | No | png |
width | Width of the QR code image in pixels | No | 150 |
height | Height of the QR code image in pixels | No | 150 |
margin | Whitespace around QR code image in pixels | No | 4 |
color | Hex color code of "dark" QR grid cells (e.g., #000000) | No | #000000 (black) |
bg_color | Hex color code of the QR code background (e.g., #ffffff) | No | #ffffff (white) |
error_correction | Error correction level (L, M, Q, H) | No | M |
image | URL of the image to show in the center. Must be URL-encoded. | No | |
image_size | Coefficient of the image size (between 0.0 and 1.0) | No | 0.5 |
image_margin | Margin of the image in pixels | No | 0 |
caption | Caption text to display below the QR code | No | |
caption_font_family | Font family of the caption text | No | sans-serif |
caption_font_size | Font size of the caption text in pixels | No | 10 |
Customizing QR Code Appearance
-
Colors: Use
colorandbg_colorto set the QR code's foreground and background colors. Thecolorparameter should be a hex color code (e.g.,#000000for black). For a transparent background, setbg_colorto#0000. -
Size and Margin: Adjust the
width,height, andmarginparameters to control the QR code's dimensions and whitespace around it. -
Error Correction: Use
error_correctionto set the level of error correction. Valid values areL,M,Q, andH, withHoffering the highest level of correction.
Adding Images to QR Codes
To include an image in the center of your QR code, use the image parameter. Ensure that the URL is URL-encoded.
Example:
https://fetchqr.org/api?data=Here's%20my%20textimage=https%3A%2F%2Fexample.com%2Fimage.png
You can adjust the image size using the image_size parameter (between 0.0 and 1.0) or specify exact image_width and image_height.
Adding Captions
Add a caption below the QR code using caption, caption_font_family, and caption_font_size parameters.
Example:
https://fetchqr.org/api?data=abc123&caption=My%20QR%20Code&caption_font_family=mono&caption_font_size=20
Example Requests
Basic QR Code
Generate a QR code with default settings:
https://fetchqr.org/api?data=Hello%20World
Customized QR Code with Image and Caption
Generate a QR code with a custom color, an embedded image, and a caption:
https://fetchqr.org/api?data=Custom%20QR%20Code&color=ff0000&bg_color=0000ff&image=https%3A%2F%2Fexample.com%2Flogo.png&image_size=0.5&caption=Your%20Caption&caption_font_size=16
Troubleshooting
- Image Issues: Ensure the image URL is accessible and properly URL-encoded.
- Formatting Problems: Verify that all query parameters are correctly formatted.
For more details, refer to the Docusaurus documentation for further customization options and best practices.
Happy coding!