二维码
创建带徽标、颜色、样式和内容类型的二维码,然后列出或更新它们。
支持的类型
将 type 设为下列键之一。内容字段随类型变化。
- text
- url
- phone
- sms
- facetime
- location
- wifi
- event
- vcard
- crypto
- paypal
- upi
- epc
- pix
POST/api/v1/qr-codes创建 二维码
在请求体中发送 JSON。name 和 type 为必填。url 类型需传 url。添加 style、颜色和 qr_code_logo 以匹配工作室中的设计。API 不支持 file 类型。
| 名称 | 类型 | 必填 | 默认 | 描述 |
|---|---|---|---|---|
| name | string | 是 | — | 保存在资源上的标签。 |
| type | string | 是 | url | 内容类型。受支持的 QR 键之一,不包括 file。 |
| url | string | 否 | — | 目标 URL。当 type 为 url 时必填。 |
| text | string | 否 | — | 纯文本。当 type 为 text 时必填。批量文本请在此字段中分行。 |
| url_dynamic | boolean | 否 | false | 若为 true,会创建短链接,二维码编码该链接,以便日后更改目标。 |
| project_id | integer | 否 | — | 要将资源附加到的项目。 |
| is_bulk | boolean | 否 | false | 若为 true 且 type 为 text,则 text 中每行创建一个二维码。 |
| style | string | 否 | square | 模块形状。例如:square、dot、rounded、heart、hexagon。 |
| inner_eye_style | string | 否 | square | 内定位图案形状。例如:square、dot、circle、rounded。 |
| outer_eye_style | string | 否 | square | 外定位图案形状。例如:square、circle、rounded、flower。 |
| size | integer | 否 | 500 | 图像尺寸(像素),50–2000。 |
| margin | integer | 否 | 0 | 静区模块数,0–25。 |
| ecc | string | 否 | M | 纠错级别:L、M、Q 或 H。添加徽标时使用 H。 |
| foreground_type | string | 否 | color | color 或 gradient。 |
| foreground_color | string | 否 | #000000 | 模块颜色,HEX。 |
| foreground_gradient_style | string | 否 | horizontal | vertical、horizontal、diagonal、inverse_diagonal 或 radial。 |
| foreground_gradient_one | string | 否 | — | 渐变第一种 HEX 颜色。 |
| foreground_gradient_two | string | 否 | — | 渐变第二种 HEX 颜色。 |
| background_color | string | 否 | #ffffff | 背景 HEX 颜色。请保持比模块更浅。 |
| background_color_transparency | integer | 否 | 0 | 背景透明度,0–100。 |
| custom_eyes_color | boolean | 否 | false | 若为 true,码眼使用 eyes_inner_color 和 eyes_outer_color。 |
| eyes_inner_color | string | 否 | #000000 | 内码眼 HEX 颜色。 |
| eyes_outer_color | string | 否 | #000000 | 外码眼 HEX 颜色。 |
| qr_code_logo | string | 否 | — | 徽标图片 URL 或已上传文件键。 |
| qr_code_logo_size | number | 否 | 25 | 徽标占二维码的百分比,5–40。 |
| frame | string | 否 | — | 工作室中的可选边框键。 |
| frame_text | string | 否 | — | 绘制在边框上的说明文字。 |
按类型划分的内容字段
| 名称 | 类型 | 必填 | 默认 | 描述 |
|---|---|---|---|---|
| phone | string | 否 | — | 当 type 为 phone 时的电话号码。 |
| sms | string | 否 | — | 当 type 为 sms 时的电话号码。 |
| sms_body | string | 否 | — | SMS 正文。 |
| string | 否 | — | 当 type 为 email 时的收件人。 | |
| email_subject | string | 否 | — | 邮件主题。 |
| email_body | string | 否 | — | 邮件正文。 |
| string | 否 | — | WhatsApp 号码,仅数字。 | |
| whatsapp_body | string | 否 | — | WhatsApp 预填文本。 |
| wifi_ssid | string | 否 | — | 当 type 为 wifi 时的网络名称。 |
| wifi_password | string | 否 | — | Wi-Fi 密码。 |
| wifi_encryption | string | 否 | WPA | nopass、WEP、WPA 或 WPA/WPA2。 |
| location_latitude | number | 否 | — | 当 type 为 location 时的纬度。 |
| location_longitude | number | 否 | — | 当 type 为 location 时的经度。 |
| event | string | 否 | — | 当 type 为 event 时的活动标题。 |
| event_start_datetime | string | 否 | — | 活动开始的 ISO 日期时间。 |
| vcard first_name / last_name / email | string | 否 | — | vCard 字段:first_name、last_name、email 及其他工作室键。 |
请求示例
curl -X POST 'https://forqrcode.com/api/v1/qr-codes' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"name": "Website QR",
"type": "url",
"url": "https://forqrcode.com",
"style": "rounded",
"size": 500,
"ecc": "M",
"foreground_color": "#17191c",
"background_color": "#ffffff",
"qr_code_logo": "https://forqrcode.com/logo.png",
"qr_code_logo_size": 25
}'更多示例
渐变二维码
curl -X POST 'https://forqrcode.com/api/v1/qr-codes' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"name": "Gradient QR",
"type": "url",
"url": "https://forqrcode.com",
"style": "dot",
"inner_eye_style": "circle",
"outer_eye_style": "rounded",
"foreground_type": "gradient",
"foreground_gradient_style": "radial",
"foreground_gradient_one": "#5c8b29",
"foreground_gradient_two": "#25492f",
"background_color": "#ffffff",
"size": 600
}'Wi-Fi 二维码
curl -X POST 'https://forqrcode.com/api/v1/qr-codes' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"name": "Office Wi-Fi",
"type": "wifi",
"wifi_ssid": "Guest",
"wifi_password": "correct-horse",
"wifi_encryption": "WPA",
"style": "square",
"ecc": "H"
}'响应示例
{
"data": {
"id": 1,
"type": "url",
"name": "Website QR",
"qr_code": "https://…/qr-codes/…/qr.svg",
"settings": {
"style": "rounded",
"size": 500,
"ecc": "M"
}
}
}GET/api/v1/qr-codes列出 二维码
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| page | integer | 否 | Page number (default 1) |
| results_per_page | integer | 否 | Items per page (default 25, max 100) |
| search | string | 否 | Search term |
| search_by | string | 否 | Column to search |
| order_by | string | 否 | Sort column |
| order_type | string | 否 | asc or desc |
| datetime_start | string | 否 | ISO datetime filter start |
| datetime_end | string | 否 | ISO datetime filter end |
| project_id | integer | 否 | — |
| type | string | 否 | — |
curl -X GET 'https://forqrcode.com/api/v1/qr-codes' \ -H 'Authorization: Bearer YOUR_API_KEY'
GET/api/v1/qr-codes/{id}读取一个 二维码
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| id | integer | 是 | — |
curl -X GET 'https://forqrcode.com/api/v1/qr-codes/{id}' \
-H 'Authorization: Bearer YOUR_API_KEY'PATCH/api/v1/qr-codes/{id}更新 二维码
| 名称 | 类型 | 必填 | 默认 | 描述 |
|---|---|---|---|---|
| id | integer | 是 | — | — |
| name | string | 否 | — | 保存在资源上的标签。 |
| type | string | 否 | url | 内容类型。受支持的 QR 键之一,不包括 file。 |
| url | string | 否 | — | 目标 URL。当 type 为 url 时必填。 |
| text | string | 否 | — | 纯文本。当 type 为 text 时必填。批量文本请在此字段中分行。 |
| url_dynamic | boolean | 否 | false | 若为 true,会创建短链接,二维码编码该链接,以便日后更改目标。 |
| project_id | integer | 否 | — | 要将资源附加到的项目。 |
| is_bulk | boolean | 否 | false | 若为 true 且 type 为 text,则 text 中每行创建一个二维码。 |
| style | string | 否 | square | 模块形状。例如:square、dot、rounded、heart、hexagon。 |
| inner_eye_style | string | 否 | square | 内定位图案形状。例如:square、dot、circle、rounded。 |
| outer_eye_style | string | 否 | square | 外定位图案形状。例如:square、circle、rounded、flower。 |
| size | integer | 否 | 500 | 图像尺寸(像素),50–2000。 |
| margin | integer | 否 | 0 | 静区模块数,0–25。 |
| ecc | string | 否 | M | 纠错级别:L、M、Q 或 H。添加徽标时使用 H。 |
| foreground_type | string | 否 | color | color 或 gradient。 |
| foreground_color | string | 否 | #000000 | 模块颜色,HEX。 |
| foreground_gradient_style | string | 否 | horizontal | vertical、horizontal、diagonal、inverse_diagonal 或 radial。 |
| foreground_gradient_one | string | 否 | — | 渐变第一种 HEX 颜色。 |
| foreground_gradient_two | string | 否 | — | 渐变第二种 HEX 颜色。 |
| background_color | string | 否 | #ffffff | 背景 HEX 颜色。请保持比模块更浅。 |
| background_color_transparency | integer | 否 | 0 | 背景透明度,0–100。 |
| custom_eyes_color | boolean | 否 | false | 若为 true,码眼使用 eyes_inner_color 和 eyes_outer_color。 |
| eyes_inner_color | string | 否 | #000000 | 内码眼 HEX 颜色。 |
| eyes_outer_color | string | 否 | #000000 | 外码眼 HEX 颜色。 |
| qr_code_logo | string | 否 | — | 徽标图片 URL 或已上传文件键。 |
| qr_code_logo_size | number | 否 | 25 | 徽标占二维码的百分比,5–40。 |
| frame | string | 否 | — | 工作室中的可选边框键。 |
| frame_text | string | 否 | — | 绘制在边框上的说明文字。 |
请求示例
curl -X PATCH 'https://forqrcode.com/api/v1/qr-codes/{id}' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"url": "https://forqrcode.com/pricing",
"foreground_color": "#5d2a1a"
}'DELETE/api/v1/qr-codes/{id}删除 二维码
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| id | integer | 是 | — |
curl -X DELETE 'https://forqrcode.com/api/v1/qr-codes/{id}' \
-H 'Authorization: Bearer YOUR_API_KEY'参数名与 JSON 示例为英文。请将 YOUR_API_KEY 替换为您的密钥。