QR Code Generator API
Generate QR codes as PNG or SVG with one GET request: URLs, text, WiFi logins, vCards, e-mail, SMS, phone and geo links. Custom colours, size and ECC.
The QR Code API turns any text or URL into a QR code image. Call GET /v1/qr?text=... and you get a PNG back (or an SVG with format=svg), ready to use directly in an <img> tag, an e-mail or a print template. With format=json you get the encoded data, the QR version, the module count, the SVG markup and a base64 PNG in one JSON response.
Besides plain text, the type parameter builds the standard payloads that phone cameras understand: wifi (ssid, password, encryption, hidden), vcard (first_name, last_name, org, title, phone, email, website, address), email (to, subject, body), sms (phone, message), tel (phone) and geo (lat, lng). You no longer have to remember the WIFI:T:WPA;S:...;; syntax or escape special characters yourself.
You control the size (64–2000 px, default 300), the quiet-zone margin (0–20 modules, default 4), the foreground and background colours (hex such as 1e90ff or a basic colour name) and the error-correction level ecc (L, M, Q, H; default M). PNG output uses whole pixels per module, so the image can be a few pixels smaller than the requested size to stay perfectly sharp. The encoded data is limited to about 2,900 characters.
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
text | body|query | string | yes | Text or URL to encode (aliases: data, url). Required when type is text (default). Max ~2,900 characters. | |
type | body|query | string | no | text | Payload type: text, wifi, vcard, email, sms, tel or geo. |
format | body|query | string | no | png | png (image), svg (image) or json (data, version, modules, ecc, svg, png_base64). |
size | body|query | number | no | 300 | Image width/height in pixels, 64–2000. |
margin | body|query | number | no | 4 | Quiet zone around the code, in modules (0–20). |
color | body|query | string | no | 000000 | Foreground colour: hex (1e90ff, #333) or black, white, red, green, blue, gray. |
background | body|query | string | no | ffffff | Background colour (same formats as color). |
ecc | body|query | string | no | M | Error correction level: L, M, Q or H. |
ssid | body|query | string | no | type=wifi: network name. Also password, encryption (WPA, WEP, nopass; default WPA) and hidden (true/false). | |
first_name | body|query | string | no | type=vcard: contact fields first_name, last_name, org, title, phone, email, website, address. | |
to | body|query | string | no | type=email: recipient, with optional subject and body. | |
phone | body|query | string | no | type=tel or sms: phone number (sms also takes message); also used by vcard. | |
lat | body|query | number | no | type=geo: latitude, with lng for the longitude. |
Example
curl "https://apibox.io.vn/v1/qr?text=https://apibox.io.vn&size=300&color=1e3a8a" \
-H "Authorization: Bearer YOUR_API_KEY" \
-o outputconst res = await fetch('https://apibox.io.vn/v1/qr?text=https://apibox.io.vn&size=300&color=1e3a8a', {
method: 'GET',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
},
});
const blob = await res.blob();import requests
res = requests.get(
"https://apibox.io.vn/v1/qr?text=https://apibox.io.vn&size=300&color=1e3a8a",
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=30,
)
open("output", "wb").write(res.content)<?php
$ch = curl_init('https://apibox.io.vn/v1/qr?text=https://apibox.io.vn&size=300&color=1e3a8a');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY'],
]);
$response = curl_exec($ch);
file_put_contents('output', $response);Response
binary image/png (QR code, 297×297 px)
Use cases
- Print QR codes on invoices, tickets and product labels
- Let café or hotel guests join the WiFi by scanning a code
- Add a vCard QR code to business cards and e-mail signatures
- Generate payment or tracking links on the fly in a web app
FAQ
Can I use the QR code URL directly in an <img> tag?
Yes. A GET request returns the image itself (image/png or image/svg+xml) with a one-day cache header. Keep in mind that the request must carry your API key, so for public pages it is better to generate the image on your server and store it.
How do I create a WiFi QR code?
Call /v1/qr?type=wifi&ssid=MyCafe&password=secret123. Optional: encryption=WPA|WEP|nopass (default WPA) and hidden=true for a hidden network. The API escapes special characters in the SSID and password for you.
Which error correction level should I choose?
M (15% recovery) is the default and fine for most cases. Use Q or H (25–30%) if the code will be printed small, may get dirty, or if you want to place a logo over its centre; L gives the smallest code for long URLs.
Related APIs
Barcode Generator
Create Code 128 barcodes for labels, SKUs and shipping with a single request. SVG with human-readable text or PNG, custom height, width and colours.
▭Placeholder Image
Get placeholder images of any size for mockups and tests: /v1/placeholder/600x400.png. SVG with custom text and colours, or a solid-colour PNG.
VQRVietQR Generator
Create VietQR / NAPAS 247 bank transfer QR codes with bank, account, amount and transfer note as PNG, SVG or JSON payload. Decode existing VietQR codes.