Web data & toolsQR Code
QR Code Generator API: Wi-Fi, SEPA Payment and Barcodes That Always Scan
QR code generator API tutorial: Wi-Fi, event and SEPA payment QR codes, EAN and GS1 barcodes with check digits, and a reader that parses codes, in Python.
A restaurant prints 2,000 table cards with a QR code in its brand colours and its logo in the middle. The proof looked fine on screen. On the tables, half the phones cannot read it: the logo covers too many modules for the error correction level, and the light green on cream sits under the contrast scanners need. The other classic failure is quieter: a payment QR code on an invoice with one wrong digit in the IBAN, found when the first transfer bounces.
A QR code generator API should refuse to ship a code that does not scan. This one decodes every image it produces before returning it, checks colours against a contrast threshold, validates IBANs and barcode check digits, and reads codes back from photos with their content already parsed.
This article covers how QR codes and barcodes hold data, then generates links, Wi-Fi logins, calendar events, SEPA payment codes, branded codes with a logo, EAN-13 and GS1 barcodes in Python, and reads a GS1 DataMatrix from a medicine box.
How a QR code holds data, and why some do not scan
A QR code is a grid of modules. Version 1 is 21 × 21 modules; each version adds 4 per side, up to version 40 at 177 × 177. Reed-Solomon error correction lets a reader rebuild damaged parts, at four levels:
| Level | Damage it can recover | When to use it |
|---|---|---|
| L | about 7 % | Screens, short links, smallest code |
| M | about 15 % | Print, the usual default |
| Q | about 25 % | Rough surfaces, small prints |
| H | about 30 % | A logo in the middle |
Three things break codes in practice: a logo hiding more modules than the error correction can rebuild, poor contrast between dark and light, and a missing quiet zone (QR codes need 4 empty modules around them). The fourth is the content itself. Phones act on a few text formats:
| Content | Format phones read | Example |
|---|---|---|
| Wi-Fi login | WIFI:T:WPA;S:<ssid>;P:<password>;; |
Join a network in one tap |
| Contact | vCard 3.0 or MeCard | Add to contacts |
| Calendar event | iCalendar VEVENT |
Add to calendar |
| SEPA transfer | EPC069-12 (BCD header), also called GiroCode |
Pre-filled transfer in a banking app |
| Email, SMS, call, map | mailto:, SMSTO:, tel:, geo: |
Open the right app |
Escaping is where hand-built strings fail: a Wi-Fi password containing ; or : must be escaped, and an event's time must be written in UTC. The API builds these strings from JSON fields, so you never write them yourself.
Generate a QR code in Python
GET /v1/qr/qrcode encodes a text or URL. By default it answers with the PNG itself; format=svg gives a vector file and output=json returns the image in base64 with what was encoded.
import base64
import requests
HOST = "qr-code-generator-reader-barcodes-logo-svg.p.rapidapi.com"
API = f"https://{HOST}"
HEADERS = {"x-rapidapi-key": "YOUR_API_KEY", "x-rapidapi-host": HOST}
r = requests.get(
f"{API}/v1/qr/qrcode",
headers=HEADERS,
params={"data": "https://helenis-api.com/apis/qr/", "output": "json"},
timeout=30,
)
r.raise_for_status()
code = r.json()
with open("qr.png", "wb") as f:
f.write(base64.b64decode(code["base64"]))
print(code["version"], code["error_correction"], code["verified"])
The real response, base64 shortened:
{
"symbology": "qr_code",
"format": "png",
"mime_type": "image/png",
"width": 400,
"height": 400,
"base64": "iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQCAIAAAAP...",
"content": "https://helenis-api.com/apis/qr/",
"version": "3",
"error_correction": "Q",
"modules": 29,
"verified": true,
"warnings": []
}
The default level is M, but this link fits in version 3 at level Q too, so the level was raised for free: same size, more damage tolerance. verified: true means the PNG was decoded back and gave the exact content. Without output=json, the same information comes in the headers X-Code-Verified, X-QR-Version and X-QR-Error-Correction, and r.content is the file to save.
The same code as an SVG in a brand colour on a transparent background, with curl (# is %23 in a URL):
curl "https://qr-code-generator-reader-barcodes-logo-svg.p.rapidapi.com/v1/qr/qrcode?data=https://helenis-api.com/apis/qr/&format=svg&dark=%231A3D7C&light=transparent" \
-H "X-RapidAPI-Key: YOUR_API_KEY" \
-H "X-RapidAPI-Host: qr-code-generator-reader-barcodes-logo-svg.p.rapidapi.com" \
-o qr.svg
The GET endpoint can sit behind an <img> tag, but not with your API key in the page: call it from your server (or at build time), cache the file, and serve it yourself. Codes are static, so one call per code is enough.
Wi-Fi, calendar event and SEPA payment QR codes
POST /v1/qr/qrcode takes a type and the matching object. A Wi-Fi login:
wifi = {
"type": "wifi",
"wifi": {"ssid": "Cafe Lumiere", "password": "croissant42", "security": "WPA"},
"output": "json",
}
r = requests.post(f"{API}/v1/qr/qrcode", headers=HEADERS, json=wifi, timeout=30)
print(r.json()["content"])
The encoded content is WIFI:T:WPA;S:Cafe Lumiere;P:croissant42;; (version 3, level M, verified). An event given in Paris time is converted to UTC, as iCalendar readers expect:
{
"content": "BEGIN:VEVENT\nSUMMARY:Product launch\nDTSTART:20261210T173000Z\nDTEND:20261210T190000Z\nLOCATION:Paris\nEND:VEVENT",
"version": "7",
"error_correction": "M",
"verified": true
}
That came from "start": "2026-12-10T18:30:00+01:00": 18:30 in Paris is 17:30 UTC.
SEPA payment QR codes (EPC, GiroCode)
The EPC QR code, defined by the European Payments Council in document EPC069-12, lets a banking app pre-fill a SEPA credit transfer: beneficiary, IBAN, amount and reference. It is common on invoices, in Germany and Austria in particular.
payment = {
"type": "epc",
"epc": {
"name": "Red Cross Belgium",
"iban": "BE72000000001616",
"bic": "BPOTBEB1",
"amount": 25.0,
"text": "Donation",
},
"output": "json",
}
r = requests.post(f"{API}/v1/qr/qrcode", headers=HEADERS, json=payment, timeout=30)
{
"symbology": "qr_code",
"content": "BCD\n002\n1\nSCT\nBPOTBEB1\nRed Cross Belgium\nBE72000000001616\nEUR25.00\n\n\nDonation",
"version": "5",
"error_correction": "M",
"modules": 37,
"verified": true,
"warnings": []
}
Line by line: the BCD service tag, version 002, character set 1 (UTF-8), SCT (SEPA credit transfer), the BIC (optional in version 002), the name, the IBAN, the amount, then an empty purpose code, an empty structured reference and the free text. A structured creditor reference (RF..., ISO 11649) goes in reference and is checked too.
Before anything is drawn, the IBAN is checked against its country's length and the ISO 13616 checksum (the country code and check digits moved to the end, letters turned into numbers, the whole number modulo 97 must equal 1). Change the last digit and the call is refused, billed 0:
{
"error": {
"status": 400,
"code": "invalid_iban",
"message": "The IBAN is not valid (length or checksum)."
}
}
If you extract supplier IBANs from documents, the invoice OCR API returns them from PDFs and photos, ready for this call.
Brand colours, a logo, and the contrast check
dark and light take hex colours (#RRGGBBAA with alpha, or transparent), and logo_url puts an image in the middle, at logo_size 10 to 30 % of the width:
branded = {
"type": "url",
"data": "https://helenis-api.com/blog/",
"dark": "#1A3D7C",
"logo_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/8/80/"
"Wikipedia-logo-v2.svg/250px-Wikipedia-logo-v2.svg.png",
"logo_size": 0.25,
"size": 600,
"output": "json",
}
r = requests.post(f"{API}/v1/qr/qrcode", headers=HEADERS, json=branded, timeout=30)
The answer: version 4, error_correction: "H", 600 × 600 px, verified: true. With a logo, the level is forced to H. Asked for level L with a 30 % logo, the code comes back at H with the warning "Error correction raised to H to make room for the logo."; if a logo still hid too much, the call would fail with unscannable and not be billed.
A logo that cannot be downloaded is refused with the reason. Wikimedia, for instance, only serves thumbnails at standard widths, which is why the URL above uses 250px; the same URL at 200px returns:
{
"error": {
"status": 400,
"code": "site_unreachable",
"message": "Could not download `logo_url`: The file server answered HTTP 400. Wikimedia only serves thumbnails at its standard widths (250px, 330px, 500px, 960px, 1280px...): change the NNNpx- part of the URL, or use the original file."
}
}
Colours are checked with the WCAG contrast ratio, which must reach 3:1, and the dark colour must be darker than the light one (some readers miss inverted codes). A grey that looks fine on a monitor:
{
"error": {
"status": 400,
"code": "low_contrast",
"message": "These colours contrast 2.5:1; scanners need at least 3:1. Use a darker dark or a lighter light colour."
}
}
Barcodes with check digits: EAN-13 and GS1
GET /v1/qr/barcode draws 16 types: EAN-13, EAN-8, UPC-A, UPC-E, ISBN, ITF-14, Code 128, GS1-128, Code 39, Code 93, ITF, Codabar, Data Matrix, GS1 DataMatrix, PDF417 and Aztec. For retail codes, send 12 digits and the check digit is computed (weights 1 and 3 alternately, then the complement to the next multiple of 10):
{
"symbology": "ean_13",
"width": 339,
"height": 174,
"content": "4006381333931",
"check_digit": "1",
"verified": true
}
Send 13 digits with a wrong last one and the API tells you which digit was expected: "The check digit of 4006381333932 is wrong: it should be 1 (4006381333931). Send 12 digits to have it computed."
GS1-128 and GS1 DataMatrix carry GS1 Application Identifiers in brackets: (01) the GTIN, (17) an expiry date as YYMMDD, (10) a batch, (21) a serial. The GTIN's check digit is verified before drawing:
r = requests.get(
f"{API}/v1/qr/barcode",
headers=HEADERS,
params={
"type": "gs1_128",
"data": "(01)09506000134376(17)271231(10)LOT42",
"format": "svg",
},
timeout=30,
)
with open("pallet-label.svg", "wb") as f:
f.write(r.content)
With output=json the same request reports "symbology": "code_128" (GS1-128 is Code 128 with the FNC1 start that marks GS1 data), an 825 × 174 px image and verified: true.
Read QR codes and barcodes from a photo
POST /v1/qr/read takes an image URL (or an upload at /v1/qr/read/upload) and returns every code in it, rotated or inverted, with its position and parsed content. A GS1 DataMatrix printed on a medicine box:
r = requests.post(
f"{API}/v1/qr/read",
headers=HEADERS,
json={
"url": "https://upload.wikimedia.org/wikipedia/commons/5/5f/"
"Kod_DataMatrix_na_opakowaniu_leku.jpg"
},
timeout=60,
)
for found in r.json()["codes"]:
print(found["format"], found["text"])
{
"count": 1,
"codes": [
{
"format": "data_matrix",
"format_name": "Data Matrix",
"text": "(01)05909990670413(21)100214999470(17)220331(10)JDL1U00",
"content_type": "gs1",
"position": { "box": { "x": 465, "y": 75, "width": 80, "height": 80 } },
"parsed": {
"kind": "gs1",
"gs1": [
{ "ai": "01", "name": "GTIN", "value": "05909990670413" },
{ "ai": "21", "name": "Serial number", "value": "100214999470" },
{ "ai": "17", "name": "Expiration date", "value": "220331", "date": "2022-03-31" },
{ "ai": "10", "name": "Batch or lot number", "value": "JDL1U00" }
],
"product": {
"gtin": "05909990670413",
"check_digit_valid": true,
"prefix_country": "Poland",
"restricted": false
}
}
}
],
"image": { "width": 576, "height": 259, "mime_type": "image/jpeg" }
}
The expiry 220331 became 2022-03-31, and the GTIN prefix 590 was attributed to GS1 Poland. This is the serialisation code European medicine packs carry, so a pharmacy or logistics app gets batch, expiry and serial in one call.
A photo of Japanese book covers returned 5 EAN-13 codes, read in rows from top to bottom: two ISBNs (9784847040672, 9784048944830, with "isbn" set in parsed) and three codes starting with 192, the second barcode of Japanese books, which carries the classification code and the price. A landscape with no code returns "count": 0 and a note on how to take a better picture; the image was read, so the call is billed.
Cost
Generating a code (QR or barcode) uses 1 credit; reading an image uses 5, whatever the number of codes in it, because decoding a photo takes 20 to 100 times the work. The free BASIC plan gives 10 credits a day. PRO is $3.99 a month for 50,000 credits, $0.00008 per generated code and $0.0004 per image read; ULTRA gives 150,000 credits for $9.99 and MEGA 500,000 for $29.99. Errors are not billed. For comparison, the best-known QR code API on RapidAPI charges $0.006 per code and the logo-focused ones $0.019 to $0.045. Plans are on the QR code API page, parameters in the API reference.
Codes came back in 1.3 to 3.5 seconds over the network in these calls (two runs), most of it round trip (generation itself takes about 30 ms); photo reads took 2 to 6 seconds. Nothing is stored: codes and images are computed in memory. To print EAN labels for a catalogue, the product description generator API can write the listings that go with them.
What the QR code generator API does not do
- Static codes only. No dynamic QR codes with redirects, editable targets or scan statistics; the content is in the code.
- Printing still matters. The check uses a strong decoder on the exact image. Very small prints, glossy surfaces or poor lighting can still defeat a phone: keep at least 2 mm per module in print and the quiet zone, and test a print at final size.
- The reader needs a sharp, close picture. In our battery of 95 real photos (posters, packaging, tickets, books, business cards) codes were read in 65; most misses were codes too small, blurred, cut off or deliberately pixelated. One of the photos tried for this article, of QR codes in a museum, also returned
count: 0. - No PDFs. Send each page as an image. Tiled HEIC photos straight from an iPhone camera are refused; send a JPEG.
prefix_countryis not the origin. It names the GS1 member organisation that issued the company prefix, not where the product was made.
Frequently asked questions
How do I generate a QR code with an API in Python?
Call GET /v1/qr/qrcode?data=<your text or URL> with requests and save r.content as a PNG, or add format=svg for a vector file. For Wi-Fi, contacts, events or payments, POST a JSON body with type and the matching object, and the API writes the format phones expect.
How do I make a Wi-Fi QR code?
Send {"type": "wifi", "wifi": {"ssid": "...", "password": "...", "security": "WPA"}}. The API escapes special characters in the SSID and password and encodes WIFI:T:WPA;S:...;P:...;;, which iOS and Android cameras read to join the network in one tap.
What is an EPC QR code or GiroCode?
It is the European Payments Council's standard for SEPA credit transfers: a QR code holding the beneficiary, IBAN, amount and reference, which most European banking apps read to pre-fill a transfer. The API builds it to EPC069-12 and verifies the IBAN checksum first.
Can I put my logo in the middle of a QR code?
Yes, with logo_url and logo_size from 0.1 to 0.3. Error correction is raised to H to make room, and the finished image is scanned back; if the logo hides too much, the call is refused and not billed.
How much data can a QR code hold?
Up to 2,953 bytes of binary data at version 40 with level L, much less at higher levels. The API caps text at 2,000 characters by GET and 4,000 by POST, and refuses content that does not fit with content_too_long.
Get started
QR Code Generator & Reader API
QR code and barcode generator (PNG, SVG, logo, Wi-Fi, vCard, SEPA) plus a reader for photos.
- QR Code
- Barcodes
- Payments
- Python
- Retail


