The go-pdf service provides a comprehensive QR code generation endpoint that supports multiple QR code types including URLs, WiFi networks, contact information, events, geographic coordinates, and more.
POST /api/v1/qrcode
Content-Type: application/json
Response: PNG image (image/png)
{
"type": "string", // Required: QR code type
"content": "string", // Main content (varies by type)
"size": 256, // Optional: Image size in pixels (64-2048, default: 256)
// Type-specific fields
"password": "string", // For WiFi: network password
"latitude": 0.0, // For geo: latitude coordinate
"longitude": 0.0, // For geo: longitude coordinate
"label": "string", // For geo: location label/name
// Contact fields (for vcard/mecard)
"first_name": "string",
"last_name": "string",
"organization": "string",
"phone": "string",
"email": "string",
"address": "string",
"website": "string", // For vcard only
"note": "string", // For vcard only
// Event fields
"summary": "string", // Event title
"description": "string", // Event description
"location": "string", // Event location
"start_time": "string", // Event start time (RFC3339 or YYYYMMDDTHHMMSS)
"end_time": "string" // Event end time (RFC3339 or YYYYMMDDTHHMMSS)
}Generate a QR code containing plain text.
Type: text or plaintext
Required Fields:
content: The text to encode
Example:
{
"type": "text",
"content": "Hello, World!",
"size": 256
}Generate a QR code containing a URL. Automatically adds https:// if no scheme is provided.
Type: url
Required Fields:
content: The URL (e.g., "https://example.com" or "example.com")
Example:
{
"type": "url",
"content": "https://www.google.com",
"size": 256
}{
"type": "url",
"content": "example.com",
"size": 256
}Generate a QR code that allows devices to connect to a WiFi network.
Type: wifi
Required Fields:
content: SSID (network name)password: Network password (optional, if not provided, network is open)
Example:
{
"type": "wifi",
"content": "MyNetwork",
"password": "MySecurePassword123",
"size": 256
}Open Network (No Password):
{
"type": "wifi",
"content": "PublicWiFi",
"size": 256
}Generate a QR code that opens an email client with pre-filled recipient, subject, and body.
Type: email
Required Fields:
contentoremail: Email address
Optional Query Parameters:
subject: Email subject linebody: Email body text
Example:
{
"type": "email",
"content": "contact@example.com",
"size": 256
}With Subject and Body (via query parameters):
POST /api/v1/qrcode?subject=Hello&body=This%20is%20a%20test
Content-Type: application/json
{
"type": "email",
"content": "contact@example.com",
"size": 256
}
Generate a QR code that opens the SMS app with a pre-filled phone number and message.
Type: sms
Required Fields:
contentorphone: Phone number
Optional Query Parameters:
body: SMS message text
Example:
{
"type": "sms",
"content": "+1234567890",
"size": 256
}With Message:
POST /api/v1/qrcode?body=Hello%20from%20QR
Content-Type: application/json
{
"type": "sms",
"content": "+1234567890",
"size": 256
}
Generate a QR code containing a phone number for dialing.
Type: phone
Required Fields:
contentorphone: Phone number
Example:
{
"type": "phone",
"content": "+1234567890",
"size": 256
}Generate a QR code containing contact information in vCard 3.0 format (RFC 6350).
Type: vcard
Required Fields:
- At least one of:
first_name,last_name, orcontent
Optional Fields:
first_name: First namelast_name: Last nameorganization: Company/organization namephone: Phone numberemail: Email addressaddress: Physical addresswebsite: Website URLnote: Additional notes
Example:
{
"type": "vcard",
"first_name": "John",
"last_name": "Doe",
"organization": "Example Corp",
"phone": "+1234567890",
"email": "john.doe@example.com",
"address": "123 Main St, City, State 12345",
"website": "www.example.com",
"note": "VP of Engineering",
"size": 256
}Minimal vCard:
{
"type": "vcard",
"content": "John Doe",
"email": "john@example.com",
"size": 256
}Generate a QR code containing contact information in MeCard format (simplified format used by many QR code readers).
Type: mecard
Required Fields:
- At least one of:
first_name,last_name, orcontent
Optional Fields:
first_name: First namelast_name: Last nameorganization: Company/organization namephone: Phone numberemail: Email addressaddress: Physical address
Example:
{
"type": "mecard",
"first_name": "Jane",
"last_name": "Smith",
"organization": "Tech Inc",
"phone": "+1234567890",
"email": "jane@example.com",
"address": "456 Oak Ave, City, State",
"size": 256
}Generate a QR code containing geographic coordinates that opens in a maps application.
Type: geo
Required Fields:
- Either
latitudeandlongitude, ORcontentas "latitude,longitude"
Optional Fields:
label: Location name/label
Example (using latitude/longitude fields):
{
"type": "geo",
"latitude": 40.7128,
"longitude": -74.0060,
"label": "New York City",
"size": 256
}Example (using content field):
{
"type": "geo",
"content": "40.7128,-74.0060",
"label": "Statue of Liberty",
"size": 256
}Without Label:
{
"type": "geo",
"latitude": 51.5074,
"longitude": -0.1278,
"size": 256
}Generate a QR code containing a calendar event in iCalendar/VEVENT format.
Type: event
Required Fields:
summaryorcontent: Event title
Optional Fields:
description: Event descriptionlocation: Event locationstart_time: Start date/time (RFC3339, YYYYMMDDTHHMMSS, or YYYYMMDD)end_time: End date/time (RFC3339, YYYYMMDDTHHMMSS, or YYYYMMDD)
Supported Date/Time Formats:
- RFC3339:
2024-12-25T10:00:00Zor2024-12-25T10:00:00-05:00 - iCalendar:
20241225T100000or20241225T100000Z - Date only:
2024-12-25or20241225(assumes 00:00:00)
Example:
{
"type": "event",
"summary": "Team Meeting",
"description": "Monthly team sync meeting",
"location": "Conference Room A",
"start_time": "2024-12-25T10:00:00Z",
"end_time": "2024-12-25T11:00:00Z",
"size": 256
}Simple Date Format:
{
"type": "event",
"summary": "Birthday Party",
"location": "My House",
"start_time": "20241225T180000",
"end_time": "20241225T220000",
"size": 256
}Generate a QR code containing a deep link URL for mobile apps or web applications.
Type: deeplink
Required Fields:
content: Deep link URL (must include scheme, e.g.,myapp://actionorhttps://app.com/link)
Example:
{
"type": "deeplink",
"content": "myapp://profile/12345",
"size": 256
}Web Deep Link:
{
"type": "deeplink",
"content": "https://app.example.com/login?token=abc123",
"size": 256
}Content-Type: image/png
Headers:
Content-Type:image/pngContent-Disposition:inline; filename=qrcode-{type}.pngX-QR-Type: The QR code type that was generatedX-Generated-At: Timestamp (RFC3339)
Body: PNG image bytes
Invalid request format or missing required fields.
{
"error": "Content is required",
"message": "The 'content' field cannot be empty for type: url"
}Failed to generate QR code.
{
"error": "Failed to generate QR code",
"message": "Error details..."
}Text QR Code:
curl -X POST http://localhost:8080/api/v1/qrcode \
-H "Content-Type: application/json" \
-d '{"type":"text","content":"Hello World","size":256}' \
-o qrcode-text.pngWiFi QR Code:
curl -X POST http://localhost:8080/api/v1/qrcode \
-H "Content-Type: application/json" \
-d '{"type":"wifi","content":"MyNetwork","password":"MyPassword123","size":256}' \
-o qrcode-wifi.pngvCard QR Code:
curl -X POST http://localhost:8080/api/v1/qrcode \
-H "Content-Type: application/json" \
-d '{
"type":"vcard",
"first_name":"John",
"last_name":"Doe",
"email":"john@example.com",
"phone":"+1234567890",
"organization":"Example Corp",
"size":256
}' \
-o qrcode-vcard.pngGeo Coordinates QR Code:
curl -X POST http://localhost:8080/api/v1/qrcode \
-H "Content-Type: application/json" \
-d '{
"type":"geo",
"latitude":40.7128,
"longitude":-74.0060,
"label":"New York City",
"size":256
}' \
-o qrcode-geo.pngEvent QR Code:
curl -X POST http://localhost:8080/api/v1/qrcode \
-H "Content-Type: application/json" \
-d '{
"type":"event",
"summary":"Team Meeting",
"location":"Conference Room A",
"start_time":"2024-12-25T10:00:00Z",
"end_time":"2024-12-25T11:00:00Z",
"size":256
}' \
-o qrcode-event.pngText QR Code:
Invoke-RestMethod -Uri "http://localhost:8080/api/v1/qrcode" `
-Method Post `
-ContentType "application/json" `
-Body '{"type":"text","content":"Hello World","size":256}' `
-OutFile "qrcode-text.png"WiFi QR Code:
$body = @{
type = "wifi"
content = "MyNetwork"
password = "MyPassword123"
size = 256
} | ConvertTo-Json
Invoke-RestMethod -Uri "http://localhost:8080/api/v1/qrcode" `
-Method Post `
-ContentType "application/json" `
-Body $body `
-OutFile "qrcode-wifi.png"URL QR Code:
fetch('http://localhost:8080/api/v1/qrcode', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
type: 'url',
content: 'https://www.example.com',
size: 256
})
})
.then(response => response.blob())
.then(blob => {
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'qrcode.png';
a.click();
});vCard QR Code:
fetch('http://localhost:8080/api/v1/qrcode', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
type: 'vcard',
first_name: 'John',
last_name: 'Doe',
email: 'john@example.com',
phone: '+1234567890',
organization: 'Example Corp',
size: 256
})
})
.then(response => response.blob())
.then(blob => {
const url = window.URL.createObjectURL(blob);
const img = document.createElement('img');
img.src = url;
document.body.appendChild(img);
});-
Size Limits: QR code size is limited between 64 and 2048 pixels. Default is 256 pixels.
-
URL Auto-completion: For
urltype, if no scheme is provided (http:// or https://),https://is automatically prepended. -
Date/Time Formats: The
eventtype accepts multiple date/time formats for convenience, including RFC3339, iCalendar format, and simple date formats. -
Field Flexibility: Many types support alternative fields. For example,
emailtype can use eithercontentoremailfield.phonetype can use eithercontentorphonefield. -
Query Parameters: Some types (like
emailandsms) support additional query parameters for URL-based features. -
Encoding: Special characters in contact cards and events are automatically escaped according to their respective format specifications (vCard, MeCard, iCalendar).
Use the provided test scripts to test all QR code types:
# Linux/Mac
./test-qrcode.sh
# Windows PowerShell
.\test-qrcode.ps1These scripts generate QR codes for all supported types and save them as PNG files.