NiceQR.me Docs

Tạo QR

Tạo QR code tùy biến bằng public endpoint dùng API Keys.

Endpoint

Đây hiện là public API endpoint duy nhất được tài liệu hóa cho client bên ngoài dùng API key.

POST /v1/qr/generate

Xác thực:

X-Api-Key: nq_live_your_api_key

Quyền bắt buộc trong Dashboard > API Keys:

  • Generate QR Code (qr:generate)

Request Body

FieldTypeDefaultMô tả
datastringrequiredNội dung cần encode (tối đa 4096 ký tự)
widthint300Chiều rộng theo pixel (50–2000)
heightint300Chiều cao theo pixel (50–2000)
marginint0Lề xung quanh QR code
errorCorrectionLevelstring"M"Mức sửa lỗi: L, M, Q, H
includeSvgRootbooltrueCó bao gồm thẻ <svg> gốc hay không
transparentBackgroundboolfalseNền trong suốt
bodyStylestring"square"Kiểu module từ danh sách tùy chọn
bodyShapestringShape: Circle, Heart, Diamond, Hexagon, Star, RoundedSquare
bodyBrushBrushMàu/gradient cho body
outerEyeStylestring"square"Pattern mắt ngoài
outerEyeBrushBrushMàu mắt ngoài
innerEyeStylestring"square"Pattern mắt trong
innerEyeBrushBrushMàu mắt trong
backgroundBrushBrushMàu nền
transparentBackgroundboolfalseNền trong suốt
logoLogoLogo ở giữa
templatestringTên template

Brush Object

Backend kỳ vọng giá trị PascalCase cho type.

Solid color:

{ "type": "Solid", "color": "#000000" }

Linear gradient:

{
  "type": "LinearGradient",
  "startColor": "#06b6d4",
  "endColor": "#a855f7",
  "rotation": 45.0
}

Radial gradient:

{
  "type": "RadialGradient",
  "centerColor": "#06b6d4",
  "edgeColor": "#0e7490"
}

Logo Object

FieldTypeDefaultMô tả
sourcestringrequiredNội dung SVG của logo hoặc data URI
widthintautoChiều rộng logo
heightintautoChiều cao logo
paddingint0Padding quanh logo
removeBackgroundBehindboolfalseXóa module phía sau logo
cornerRadiusint0Bo góc vùng logo

Ví dụ

curl -X POST https://api.niceqr.me/v1/qr/generate \
  -H "X-Api-Key: nq_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "data": "https://niceqr.me",
    "width": 400,
    "height": 400,
    "errorCorrectionLevel": "H",
    "bodyStyle": "rounded",
    "bodyShape": "Circle",
    "bodyBrush": {
      "type": "LinearGradient",
      "startColor": "#06b6d4",
      "endColor": "#a855f7",
      "rotation": 135
    },
    "outerEyeStyle": "rounded",
    "outerEyeBrush": { "type": "Solid", "color": "#06b6d4" },
    "backgroundBrush": { "type": "Solid", "color": "#ffffff" }
  }'

Response

{
  "success": true,
  "data": {
    "svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" ...>...</svg>"
  }
}

Ghi chú

  • Endpoint trả về SVG bên trong standard response envelope.
  • Các trường hợp thiếu, sai, revoked, expired hoặc suspended API key sẽ cố ý trả về 404 Not Found với body rỗng.
  • Nếu templateAccessLevelpremium, tài khoản phải có quyền gói phù hợp cho tùy chọn QR đó.

On this page