To generate QR codes, choose the shortest value that does the job. A QR code moves a short piece of text from a screen to a phone. It works well for a URL, a ticket number or a Wi-Fi setup string. It works poorly for a long paragraph or a value that changes every few seconds.
The QR generator returns a PNG with the encoded data.
curl "https://api2.globus.studio/v2/qr?data=https%3A%2F%2Fapp.globus.studio%2F&size=300" -o qr.png
Parameters
To generate QR codes, pass the text in data. Encode a URL before you put it in the query string. size is the image size in pixels. ecc sets the error correction level: L, M, Q or H. A higher level survives more damage and leaves less room for data.
Test with a phone
A code that looks fine on a monitor can fail on a phone. Check the contrast, the quiet zone around the code and the physical size if it will be printed. A code on a dark background needs a light border.
When a QR code is the wrong tool
When you generate QR codes for a login page, the code can confuse a phone that is not signed in. A code that points to a page behind a login is confusing unless the phone is already signed in. A code with a long URL is dense and harder to scan. Use a short link when you control the redirect. A code that changes every minute needs a display that can refresh it.
Caching and tracking
A generated QR code is an image with no built-in analytics. If you need to count scans, point the code at a URL you control and log the request there. Do not encode personal data that you would not put on a printed page.
Generate QR codes that survive damage
In a generate QR codes request, level L recovers about 7 percent of damaged modules. Level H recovers about 30 percent and produces a denser code. For a sticker or a label that may get scratched, H is a reasonable choice. For a clean screen, M is enough.
Limits
The data length has a cap. Generate QR codes at the size you will print, not at a size you scale later. The endpoint returns PNG, not SVG. Read the endpoint documentation for parameters, limits and examples.
Size and print resolution
A screen code can be 300 pixels wide. A printed code needs more pixels per centimetre. For a label, generate at 600 or 1000 pixels and print at the physical size you need. A small PNG scaled up in a layout editor looks blurry and scans poorly.
Short links
A long URL makes a dense code. If you control the destination, use a short path and redirect. The code stays simple, and you can change the destination later without reprinting. Keep the redirect page fast and mobile friendly.
curl "https://api2.globus.studio/v2/qr?data=https%3A%2F%2Fapp.globus.studio%2Fapi%2F&size=600&ecc=M" -o api-qr.png
Error correction and damage
A higher error correction level adds redundancy. A code printed on a menu that may get greasy can use level Q or H. A code on a clean screen can use M. The tradeoff is density: more redundancy means more modules for the same data, which can make a small print harder to scan.
When you generate QR codes for print, test the final print, not only the screen. A code that scans on a monitor can fail on paper under a different light. Scan the proof with two phones and a cheap reader app. A code that only works in the app you built the page with is not ready for a label.
The quiet zone
Every code needs a margin of empty space around it. If the background is dark or the layout crops the image, the reader may not find the three corner markers. Leave a light border and keep other elements out of it. A code pasted on a busy photo is hard to scan even when the modules are correct.
Related reading
When you generate QR codes for a printed page, pair the code with a placeholder image while the artwork is in review. If the code points to a page with copy, use placeholder text until the real content arrives.
Further reading: QR code reference.