Enhanced QR Code API
From build 2025-03-07, there’s a new enhanced API for generating QR codes. It gives you more control over the parameters that control the appearance of the code. You can also use the API to generate QR codes suitable for print.
The source of the API is /QR/ on the domain your Neuron® runs at. The text after the /, and before any ? contains the URL Encoded text that gets encoded into the QR code. After the ? follows optional query parameters you can use to control the appearance of the code. If arguments are left out, their default values will be used. Following is a table of query parameters recognized by the QR Code API:
| QR Code API query parameters | ||
|---|---|---|
| Parameter | Default Value | Description |
w |
400 | Width of QR code, in pixels. |
h |
400 | Height of QR code, in pixels. |
fg |
Black | Foreground color (dots) of the code. A special value of Theme can be used to select the text color of the current theme of the Neuron® |
bg |
White | Background color of the code. A special value of Theme can be used to select the background color of the current theme of the Neuron® |
c |
depends on URI scheme | Color of icon overlaid on the QR code. The icon depends on the URI scheme encoded into the code. Using the c parameter allows you to control the color of the icon. |
mc |
same as icon color | Foreground color of the markers in the QR code. |
omc |
blended between mc and fg |
The Foreground color of the outer markers in the QR code. |
ac |
same as icon color | Foreground color of the alignment in the QR code. |
oac |
blended between mc and fg |
The Foreground color of the outer alignment in the QR code. |
q |
1 | Quality of the image. It is the number of points in each dimension calculated per pixel. Provides anti-aliasing of the QR code, improving the quality of the image. |
Examples
Consider the following URL, of a legal identity: iotid:2be3be1f-0f8f-7e1b-0808-cc7844e9e732@legal.lab.tagroot.io. We can encode it into a simple QR code as follows:
We can add smoothness to the code, by adding ?q=2 to the code:
If we want the code to adapt to the current theme of the web page, we add &fg=Theme&bg=Theme for instance:
If we want to generate a code for a client displaying the page in black-mode for instance, we can control the colors using the various color arguments available. Example:
If we want to use it for print, we can add (for example) ?q=3&w=1200&h=1200:
This article is being written