GET
POST
单个二维码生成
GET https://你的域名/index.php?action=qr&content=要编码的内容
POST https://你的域名/index.php body: {"action":"qr","content":"要编码的内容"}
仅 content 必填,其余参数有默认值。支持 GET 查询串和 POST 请求体两种调用方式。返回 PNG 图像二进制流,可直接保存或用于页面展示。
| 参数 | 类型 | 必填 | 默认值 | 说明 |
| content |
string |
必填 |
- |
要编码的内容,最长 2000 字符 |
| size |
int |
选填 |
300 |
图像像素尺寸(100–1000) |
| color |
string |
选填 |
#000000 |
前景色(6 位 hex) |
| bgColor |
string |
选填 |
#ffffff |
背景色(6 位 hex) |
https://你的域名/index.php?action=qr&content=https://example.com
https://你的域名/index.php?action=qr&content=https://example.com&size=400&color=4f46e5
curl -X POST -H "Content-Type: application/json" \
-d '{"action":"qr","content":"https://example.com"}' \
https://你的域名/index.php -o code.png
fetch('/index.php', {
method: 'POST',
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ action: "qr", content: "https://example.com" })
}).then(r => r.blob()).then(blob => {
const url = URL.createObjectURL(blob);
document.getElementById('my-qr').src = url;
});
GET
POST
批量二维码生成
GET https://你的域名/index.php?action=qr-batch&content=line1\nline2
POST https://你的域名/index.php body: {"action":"qr-batch","content":"line1\nline2"}
多行内容用 \n 分隔,每行生成一张二维码。支持 offset + limit 分页。返回 JSON,包含每张图的 Base64 编码。支持 PNG 或 SVG 格式。
| 参数 | 类型 | 必填 | 默认值 | 说明 |
| content |
string |
必填 |
- |
多行文本,换行分隔,每行一个二维码内容 |
| size |
int |
选填 |
300 |
图像像素尺寸 |
| color |
string |
选填 |
#000000 |
前景色 |
| bgColor |
string |
选填 |
#ffffff |
背景色 |
| format |
string |
选填 |
png |
输出格式:png 或 svg |
| errorLevel |
string |
选填 |
M |
纠错等级:L(7%) / M(15%) / Q(25%) / H(30%) |
| max |
int |
选填 |
2000 |
最多生成数量(1–2000) |
| offset |
int |
选填 |
0 |
分页偏移量,配合 limit 使用 |
| limit |
int |
选填 |
0 |
每页数量,0 表示全部 |
curl -X POST -H "Content-Type: application/json" \
-d '{"action":"qr-batch","content":"line1\nline2\nline3"}' \
https://你的域名/index.php
{
"success": true,
"total": 3,
"offset": 0,
"limit": 0,
"success_count": 3,
"results": [
{ "index": 1, "content": "line1", "success": true,
"data": "data:image/png;base64,..." },
{ "index": 2, "content": "line2", "success": true,
"data": "data:image/png;base64,..." },
{ "index": 3, "content": "line3", "success": true,
"data": "data:image/png;base64,..." }
]
}