Generate a QR Code (POST /qr)
Équipe QR Code Genius
Mis à jour le 7/23/2026
6 min read
POST /api/v1/qr renders a single, fully-styled QR code and returns it inline as a base64 PNG data URL. Nothing is saved to your account — use bulk generation if you need the results stored and trackable.
Authentication uses the Authorization: Bearer header — see API Authentication.
Request
curl -X POST https://www.qrcodegenius.com/api/v1/qr \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"data": "https://example.com",
"width": 512,
"height": 512,
"dotsOptions": { "type": "rounded", "color": "#111827" },
"backgroundOptions": { "color": "#ffffff" }
}'
Fields
data(string, required) — the content to encode, 1–4296 characters. Any text works: URLs, Wi-Fi strings, vCards, plain text.width,height(integer, optional) — output size in pixels, 50–2000.margin(integer, optional) — quiet-zone padding in pixels, 0–100.shape(string, optional) —"square"(default) or"circle".image(string, optional) — a logo to embed in the center: anhttp(s)URL or a base64data:image/...URI (png, jpeg, webp, or svg), up to 2,000,000 characters.qrOptions,imageOptions,dotsOptions,cornersSquareOptions,cornersDotOptions,backgroundOptions(objects, optional) — full design control. See the styling reference for every field.
The request schema is strict: unknown fields are rejected with a 400 error rather than silently ignored. This catches typos like dotOptions early.
Response
{
"success": true,
"data": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",
"meta": {
"usage_count": 5,
"remaining": 995,
"strategy": "monthly"
}
}
data— the PNG as a data URL. Use it directly as animgsource, or strip thedata:image/png;base64,prefix and decode it to get the raw bytes.meta.usage_count— requests used so far this period.meta.remaining— requests left before hitting your limit.meta.strategy—"monthly"if this request counted against your monthly quota,"credits"if it was drawn from purchased credits.
Errors
400— malformed JSON, a validation failure (see thedetailsfield for the first offending field), or animageURL that could not be fetched.401— missing or invalid API key.429— quota exhausted; see Errors and rate limits.
{ "error": "Invalid request body", "details": "data: Required" }
Saving the result
A common pattern is decoding the data URL and writing it to a file or object storage:
const res = await fetch("https://www.qrcodegenius.com/api/v1/qr", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.QR_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ data: "https://example.com", width: 512 }),
});
const { data } = await res.json();
const png = Buffer.from(data.split(",")[1], "base64");
await fs.promises.writeFile("qr.png", png);
Cet article vous a-t-il été utile ?
Vos commentaires nous aident à améliorer notre documentation.