187 lines
4.2 KiB
Markdown
187 lines
4.2 KiB
Markdown
---
|
||
title: "How to Generate QR Codes via API: All Supported Types"
|
||
description: "Complete guide to generating QR codes via REST API using each available type: URL, Pix, Wi-Fi, vCard, WhatsApp, SMS, email and free text."
|
||
keywords: "api qr code, generate qr code api, qr code rest api, qrrapido api, qr code types"
|
||
author: "QRRapido"
|
||
date: 2026-03-08
|
||
lastmod: 2026-03-08
|
||
image: ""
|
||
---
|
||
|
||
# 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
|
||
|
||
```json
|
||
{
|
||
"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 (100–2000) |
|
||
| `primaryColor` | string | `"#000000"` | Module color (hex) |
|
||
| `backgroundColor` | string | `"#FFFFFF"` | Background color (hex) |
|
||
| `outputFormat` | string | `"png"` | Format: `png`, `webp`, `svg` |
|
||
|
||
---
|
||
|
||
## Type `url` — Link / URL
|
||
|
||
The simplest: any valid URL.
|
||
|
||
```json
|
||
{
|
||
"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).
|
||
|
||
```json
|
||
{
|
||
"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:
|
||
|
||
```json
|
||
{
|
||
"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:
|
||
|
||
```json
|
||
{
|
||
"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` — WhatsApp Link
|
||
|
||
```json
|
||
{
|
||
"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
|
||
|
||
```json
|
||
{
|
||
"type": "email",
|
||
"content": "mailto:contact@company.com?subject=Subject&body=Initial%20message"
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
## Type `sms` — Pre-filled SMS
|
||
|
||
```json
|
||
{
|
||
"type": "sms",
|
||
"content": "sms:+15559876543?body=Hi%2C%20I%20want%20more%20information"
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
## Type `texto` — Free Text
|
||
|
||
Any string up to 2048 characters:
|
||
|
||
```json
|
||
{
|
||
"type": "texto",
|
||
"content": "Table 12 — Priority service available at the main counter."
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
## Success Response
|
||
|
||
```json
|
||
{
|
||
"success": true,
|
||
"qrCodeBase64": "iVBORw0KGgo...",
|
||
"qrId": "abc123",
|
||
"generationTimeMs": 180,
|
||
"remainingCredits": 42,
|
||
"fromCache": false,
|
||
"format": "png",
|
||
"mimeType": "image/png"
|
||
}
|
||
```
|
||
|
||
To display the image directly in HTML:
|
||
|
||
```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.
|