QrRapido/Content/DevTutoriais/gerando-qrcodes-pela-api.en.md

4.2 KiB
Raw Blame History

title description keywords author date lastmod image
How to Generate QR Codes via API: All Supported Types Complete guide to generating QR codes via REST API using each available type: URL, Pix, Wi-Fi, vCard, WhatsApp, SMS, email and free text. api qr code, generate qr code api, qr code rest api, qrrapido api, qr code types QRRapido 2026-03-08 2026-03-08

How to Generate QR Codes via API: All Supported Types

The QRRapido API supports 8 QR code types. All use the same endpoint — the only difference is the type field and the specific fields that make up the content.

Endpoint

POST /api/v1/QRManager/generate
X-API-Key: your_key_here
Content-Type: application/json

Base Request Structure

{
  "content": "...",
  "type": "url",
  "size": 400,
  "primaryColor": "#000000",
  "backgroundColor": "#FFFFFF",
  "outputFormat": "png"
}
Field Type Default Description
content string required QR code content
type string "url" QR code type (see below)
size int 300 Size in pixels (1002000)
primaryColor string "#000000" Module color (hex)
backgroundColor string "#FFFFFF" Background color (hex)
outputFormat string "png" Format: png, webp, svg

The simplest: any valid URL.

{
  "type": "url",
  "content": "https://yoursite.com/product/123"
}

Use https:// whenever possible. QR codes with HTTP may be blocked by some modern readers.


Type pix — Pix Payment

The content must be the Pix key of the recipient. The generation produces a static Pix QR code (without connection to the Central Bank — see the dedicated Pix tutorial).

{
  "type": "pix",
  "content": "contact@yourcompany.com"
}

Accepted keys: CPF/CNPJ (digits only), email, phone in +5511999999999 format, or random key (UUID).


Type wifi — Wi-Fi Network

The content uses the standard WIFI: format:

{
  "type": "wifi",
  "content": "WIFI:S:NetworkName;T:WPA;P:NetworkPassword;;"
}
Parameter Meaning Values
S: SSID (network name) text
T: Security type WPA, WEP, nopass
P: Password text
H: Hidden network (optional) true / false

Type vcard — Business Card

The content must be a complete vCard v3:

{
  "type": "vcard",
  "content": "BEGIN:VCARD\nVERSION:3.0\nFN:John Smith\nORG:Company Inc\nTEL:+15559876543\nEMAIL:john@company.com\nURL:https://company.com\nEND:VCARD"
}

{
  "type": "whatsapp",
  "content": "https://wa.me/15559876543?text=Hi%2C%20I%27d%20like%20to%20know%20more"
}

The number must include country code and area code, without spaces or symbols. The text parameter is optional.


Type email — Email with subject and body

{
  "type": "email",
  "content": "mailto:contact@company.com?subject=Subject&body=Initial%20message"
}

Type sms — Pre-filled SMS

{
  "type": "sms",
  "content": "sms:+15559876543?body=Hi%2C%20I%20want%20more%20information"
}

Type texto — Free Text

Any string up to 2048 characters:

{
  "type": "texto",
  "content": "Table 12 — Priority service available at the main counter."
}

Success Response

{
  "success": true,
  "qrCodeBase64": "iVBORw0KGgo...",
  "qrId": "abc123",
  "generationTimeMs": 180,
  "remainingCredits": 42,
  "fromCache": false,
  "format": "png",
  "mimeType": "image/png"
}

To display the image directly in HTML:

<img src="data:image/png;base64,{{ qrCodeBase64 }}" alt="QR Code" />

General Tips

  • Colors: maintain high contrast between primaryColor and backgroundColor. Avoid yellow on white or light gray on white.
  • Minimum printed size: use size ≥ 400 for printing. For digital use (screens), 300 is sufficient.
  • Cache: identical requests return fromCache: true without consuming additional credit.
  • Rate limit: the X-RateLimit-Remaining and X-Quota-Remaining headers in the response indicate your current balance.