跳至主要内容
QR Code Genius
QR Code Genius
功能定价帮助
登录立即开始
帮助中心/开发者API/Generate a QR Code (POST /qr)

Generate a QR Code (POST /qr)

QR Code Genius团队
更新于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: an http(s) URL or a base64 data: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 an img source, or strip the data: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 the details field for the first offending field), or an image URL 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);

这篇文章有帮助吗?

您的反馈有助于我们改进文档。

QR Code Genius
QR Code Genius

创建。追踪。成长。

产品

  • 功能
  • 价格
  • 帮助与常见问题
  • 开发者 API
  • 网址/网站
  • vCard/数字名片
  • WiFi
  • Crypto (Bitcoin/ETH)
  • 社交媒体
  • Events (iCal)

公司

  • 帮助中心
  • 联系
  • 开始使用
  • 登录

法律

  • 隐私
  • 条款

© 2026 Magpie Nexus, Inc. 保留所有权利。 magpienexus.com

所有系统运行正常