📱 QR Code Generator API

Generate QR codes for text, URLs, vCards, events, Wi-Fi & phone numbers

📖 Overview

The QR Code Generator API creates QR codes for various data types including plain text, URLs, contact information (vCard), calendar events, Wi-Fi credentials, and phone numbers. Powered by goQR.me REST API for reliable, high-quality QR code generation.

📝 Multiple Data Types

Support for text, URLs, vCards, events, Wi-Fi, and phone numbers

🎨 Customizable Output

Choose size, format (PNG, GIF, JPEG, SVG), and error correction level

🔒 Error Correction

Built-in error correction (L, M, Q, H levels) for damaged codes

📦 Flexible Responses

Direct image output or base64 encoded JSON response

Powered by goQR.me: QR code generation uses the goQR.me REST API, a reliable and free service for QR code generation. Supports all standard QR code types and formats.

🌐 Base URL

https://api.lorwongam.com/api/qr-code-generator/

🔐 Authentication

No authentication required. This is a public API that can be accessed without any API keys or tokens.

📡 API Endpoints

GET / POST / Generate QR Code

Generate a QR code for one of six content types. Parameters can be supplied via the query string or as a JSON body; the same names are used in both. The format response mode decides whether you get the image bytes directly (image/png/svg) or a JSON wrapper with a base64-encoded payload (json/data).

Request Parameters

Parameter Type Required Default Description
type string Optional text One of text, vcard, event, url, wifi, phone
format string Optional json Response mode: image/png/svg for raw bytes, json/data for a JSON envelope with base64
file_type string Optional png Output format passed to goQR.me: png, gif, jpeg, jpg, svg, eps. Anything else silently falls back to png. The legacy alias gformat is also accepted.
size integer Optional 300 Pixel size (10–1000). Values outside this range are clamped.
ecc string Optional M Error correction level: L, M, Q, H. Anything else falls back to M.
qzone integer Optional 2 Quiet zone size (0–100, clamped).
margin integer Optional 1 Margin (0–50, clamped).
charset_source string Optional UTF-8 Source charset: UTF-8 or ISO-8859-1
charset_target string Optional UTF-8 Target charset: UTF-8 or ISO-8859-1
color string Optional 0-0-0 Foreground colour as R-G-B with hyphen separators (e.g. 0-0-0)
bgcolor string Optional 255-255-255 Background colour as R-G-B

Type-Specific Fields

Fields other than the ones above are forwarded to the payload builder for the chosen type.

Type Required field(s) Optional fields
text text —
url url (auto-prefixes https:// if missing) —
phone phone —
wifi ssid password, encryption (WPA/WEP/nopass), hidden
event summary, start end, location, description
vcard at least one of: name part, nickname, organization legacy fields: first_name, middle_name, last_name, prefix, suffix, nickname, organization, title, note, work_email, home_email, work_phone, home_phone, mobile, fax, website, address, city, region, postcode, country. Dynamic lists: names[][type/value], nicknames[][type/value], emails[][type/value], phones[][type/value], urls[][value], addresses[][...]

Example Request — Text

curl "https://api.lorwongam.com/api/qr-code-generator/?type=text&text=Hello%20World&format=image"

Example Request — URL

curl "https://api.lorwongam.com/api/qr-code-generator/?type=url&url=https://github.com&size=300&ecc=M&format=json"

Example Request — Wi-Fi

curl "https://api.lorwongam.com/api/qr-code-generator/?type=wifi&ssid=MyWiFi&password=pass123&encryption=WPA&format=json"

Example Request — Event

curl "https://api.lorwongam.com/api/qr-code-generator/?type=event&summary=Meeting&start=2025-12-01T10:00&end=2025-12-01T11:00&location=Office&format=json"

Example Request — Phone

curl "https://api.lorwongam.com/api/qr-code-generator/?type=phone&phone=+1234567890&format=image"

Example Request — vCard (POST JSON)

curl -X POST "https://api.lorwongam.com/api/qr-code-generator/?format=json" \ -H "Content-Type: application/json" \ -d '{ "type": "vcard", "first_name": "John", "last_name": "Doe", "organization": "Acme Corp" }'

Dynamic lists must be sent as query-string / form parameters, not JSON keys. Single-value fields such as type, first_name, last_name and organization are read from the JSON body, but multi-value lists — emails[][type/value], phones[][type/value], names[][type/value], nicknames[][type/value], urls[][value], addresses[][...] — are only parsed from query-string / form-encoded arrays. Include them in the URL:

curl "https://api.lorwongam.com/api/qr-code-generator/?type=vcard&format=json&first_name=John&last_name=Doe&organization=Acme+Corp&emails[0][type]=WORK&emails[0][value][email protected]&phones[0][type]=CELL,VOICE&phones[0][value]=%2B1234567890"

📊 Response Format

JSON envelope (format=json or format=data)

{ "success": true, "message": "QR code generated successfully", "type": "wifi", "payload": "WIFI:T:WPA;S:MyWiFi;P:pass123;H:false;", "qr_url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...", "goqr_url": "https://api.qrserver.com/v1/create-qr-code/?data=WIFI%3AT%3AWPA%3B...", "file_type": "png", "params": { "size": 300, "ecc": "M", "format": "png", "qzone": 2, "margin": 1, "charset-source": "UTF-8", "charset-target": "UTF-8", "color": "0-0-0", "bgcolor": "255-255-255" } }

The qr_url field is a fully-qualified data: URL (MIME + base64) so you can drop it straight into an <img src> tag. goqr_url is the underlying goQR.me URL for debugging.

Direct image (format=image / png / svg)

The API returns the raw image bytes with the appropriate Content-Type header (image/png, image/svg+xml, etc.) and Content-Disposition: inline; filename="qr-code.<ext>".

Error Response

All errors come back as JSON with HTTP 400 (bad request) or 500 (upstream failure).

Unsupported type

{ "error": "Bad request", "message": "Unsupported type 'banana'. Allowed: text, vcard, event, url, wifi, phone" }

Missing required field for a type

{ "error": "Bad request", "message": "vCard requires at least one name part, a nickname, or Organization" }

Invalid format response mode

{ "error": "Invalid format parameter", "message": "Supported formats: image, json, svg" }

Upstream failure (goQR.me unreachable / non-200)

{ "error": "Internal server error", "message": "Failed to fetch QR code from goQR.me: HTTP 502" }

🔧 Error Correction Levels

QR codes include built-in error correction that allows them to be read even when partially damaged. Choose the appropriate level based on your use case:

Level Recovery Capacity Use Case
L (Low) ~7% Clean environments, small QR codes
M (Medium) ~15% General purpose, balanced
Q (Quartile) ~25% Outdoor use, potential damage
H (High) ~30% Harsh environments, logos overlay

💡 Common Use Cases

🔗 Marketing & URLs

Link to websites, landing pages, app downloads, or promotional content.

📇 Contact Sharing

vCard QR codes for business cards or networking events.

📅 Event Management

Embed events into calendars with summary, start, end and location.

📶 Wi-Fi Access

Share WPA/WEP/nopass credentials for guests to auto-connect.

📞 Quick Call

Encode a phone number so a scan starts a call on most phones.

📝 Plain Text

Encode arbitrary text snippets, serial numbers, or short messages.

✨ Best Practices

  • Sizing: Use 300px for most web display, 600–1000px for print. Defaults are tuned for typical web use.
  • Error correction: Use H when overlaying logos or printing on curved/harsh surfaces.
  • Colours: Always keep the background lighter than the foreground and use high contrast.
  • Quiet zone: Keep qzone ≥ 2 so scanners can latch onto the code reliably.
  • Output type: Use format=image (or png/svg) when you only want the bytes; use format=json when you need the raw payload string alongside the image.
  • Payload inspection: The payload field in JSON responses is the raw string that was encoded — useful for debugging or generating equivalent codes yourself.

⚠️ Error Codes

The API does not return a numeric code field. Every error has the shape { "error": "<title>", "message": "<details>" } with an appropriate HTTP status:

HTTP status error When
400 Bad request Unsupported type, or a required type-specific field is missing / malformed
400 Invalid format parameter format is not one of image, json, svg, png, data
500 Internal server error goQR.me call failed (non-200 response, network error, malformed payload)

Note: an unsupported file_type (e.g. bmp) is not an error — the server silently falls back to png so old clients keep working.

🔗 Integration Examples

HTML display

Point an <img> tag straight at the endpoint with the raw image format (format=image / png / svg):

<img src="https://your-host/api/qr-code-generator/?type=url&url=https://example.com&format=image" alt="QR code" />

JavaScript fetch (JSON)

fetch('/api/qr-code-generator/?type=url&url=https://example.com&format=json') .then(r => r.json()) .then(data => { document.getElementById('qr').src = data.qr_url; // data:image/png;base64,... console.log('Encoded payload:', data.payload); // "https://example.com" });

JavaScript fetch (raw bytes)

fetch('/api/qr-code-generator/?type=wifi&ssid=Demo&encryption=nopass&format=image') .then(r => r.blob()) .then(blob => { document.getElementById('qr').src = URL.createObjectURL(blob); });

POST JSON body

fetch('/api/qr-code-generator/?format=json', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ type: 'vcard', first_name: 'John', last_name: 'Doe', organization: 'Acme Corp' // Note: dynamic lists (emails[], phones[], ...) are read from // query-string/form parameters only — not from the JSON body. }) }) .then(r => r.json()) .then(data => console.log(data.qr_url));

🚦 Rate Limits

This endpoint is rate-limited per client identity (IP address, or API key when one is supplied): 30 requests per minute. When the budget is exhausted the API responds with HTTP 429 and includes X-RateLimit-* headers so clients can self-throttle. The exact policy is configured in api/includes/api_config.php.

🎯 Ready to Try?

Test the QR Code Generator API with our interactive web interface or start integrating it into your application.

Try Web Interface Test API Endpoint