QR Codes¶
4 endpoints for generating, decoding, and bulk-creating QR codes.
| Method |
Endpoint |
Purpose |
POST |
/v1/qr/generate |
Generate styled QR output as base64 PNG or SVG markup |
GET |
/v1/qr/generate |
Stream raw QR image bytes (PNG or SVG) |
POST |
/v1/qr/decode |
Decode QR codes and barcodes from an image |
POST |
/v1/qr/bulk |
Generate up to 20 QR codes in one request |
Python SDK Examples¶
Generate a QR code (PNG)¶
from toolkitapi import Barcode
bc = Barcode(api_key="tk_...")
result = bc.qr_generate(
data="https://toolkitapi.io",
size=450,
error_correction="M",
format="png",
)
# Base64 PNG payload
png_b64 = result["image"]
print(result["has_logo"]) # False
Generate a styled QR code with logo¶
from toolkitapi import Barcode
bc = Barcode(api_key="tk_...")
result = bc.qr_generate(
data="WIFI:S:OfficeGuest;T:WPA;P:SuperSecret;H:false;;",
size=700,
error_correction="H",
format="png",
fg_color="#0f172a",
bg_color="#f8fafc",
module_shape="rounded",
logo_url="https://toolkitapi.io/assets/logo.png",
logo_size=0.22,
)
print(result["has_logo"]) # True
Stream raw QR image bytes and save to disk¶
Use the GET variant through qr_generate_image.
from toolkitapi import Barcode
bc = Barcode(api_key="tk_...")
image_bytes = bc.qr_generate_image(
data="https://toolkitapi.io/pricing",
size=512,
format="png",
module_shape="circle",
output_path="pricing-qr.png",
)
print(len(image_bytes))
Decode from an image URL¶
from toolkitapi import Barcode
bc = Barcode(api_key="tk_...")
decoded = bc.qr_decode(url="https://toolkitapi.io/qr/menu.png")
print(decoded["found"])
for item in decoded["results"]:
print(item["type"], item["data"])
Bulk-generate QR codes¶
from toolkitapi import Barcode
bc = Barcode(api_key="tk_...")
result = bc.qr_bulk(
items=[
{"data": "https://toolkitapi.io/a", "size": 300, "module_shape": "square"},
{"data": "https://toolkitapi.io/b", "size": 300, "module_shape": "rounded"},
{"data": "https://toolkitapi.io/c", "size": 300, "module_shape": "gapped"},
]
)
print(result["total"]) # 3
Request Parameters – POST /v1/qr/generate¶
| Parameter |
Type |
Description |
data |
string |
Content to encode, 1 to 4296 characters |
size |
integer |
Output width/height in pixels, 100 to 2000 |
error_correction |
string |
One of L, M, Q, H |
format |
string |
png or svg |
fg_color |
string |
Foreground hex color |
bg_color |
string |
Background hex color |
module_shape |
string |
square, rounded, circle, gapped |
logo |
string |
Base64 logo image (PNG output only) |
logo_url |
string |
Public URL to logo image (PNG output only) |
logo_size |
float |
Logo scale relative to QR, 0.05 to 0.40 |
Request Parameters – POST /v1/qr/decode¶
| Parameter |
Type |
Description |
image |
string |
Base64 image containing one or more symbols |
url |
string |
Public URL to an image containing one or more symbols |
Exactly one of image or url is required.
Request Parameters – POST /v1/qr/bulk¶
| Parameter |
Type |
Description |
items |
array |
1 to 20 QR generation specs |
format |
string |
png only |
Response Fields – Generate¶
| Field |
Type |
Description |
image |
string |
Base64 PNG result when format is png |
svg |
string |
SVG markup when format is svg |
format |
string |
Output format used |
data |
string |
Encoded value |
size |
integer |
Generated image size |
error_correction |
string |
Error correction level applied |
module_shape |
string |
Module shape applied |
has_logo |
boolean |
Whether logo embedding was used |
Response Fields – Decode¶
| Field |
Type |
Description |
found |
integer |
Number of detected symbols |
results |
array |
Decoded items with data, type, quality, and position |
Tip
If you embed a logo, use error_correction="H" for the best reliability. The API enforces high correction automatically when a logo is present.