二维码

创建带徽标、颜色、样式和内容类型的二维码,然后列出或更新它们。

支持的类型

将 type 设为下列键之一。内容字段随类型变化。

  • text
  • url
  • phone
  • sms
  • email
  • whatsapp
  • 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 类型。

名称类型必填默认描述
namestring保存在资源上的标签。
typestringurl内容类型。受支持的 QR 键之一,不包括 file。
urlstring目标 URL。当 type 为 url 时必填。
textstring纯文本。当 type 为 text 时必填。批量文本请在此字段中分行。
url_dynamicbooleanfalse若为 true,会创建短链接,二维码编码该链接,以便日后更改目标。
project_idinteger要将资源附加到的项目。
is_bulkbooleanfalse若为 true 且 type 为 text,则 text 中每行创建一个二维码。
stylestringsquare模块形状。例如:square、dot、rounded、heart、hexagon。
inner_eye_stylestringsquare内定位图案形状。例如:square、dot、circle、rounded。
outer_eye_stylestringsquare外定位图案形状。例如:square、circle、rounded、flower。
sizeinteger500图像尺寸(像素),50–2000。
margininteger0静区模块数,0–25。
eccstringM纠错级别:L、M、Q 或 H。添加徽标时使用 H。
foreground_typestringcolorcolor 或 gradient。
foreground_colorstring#000000模块颜色,HEX。
foreground_gradient_stylestringhorizontalvertical、horizontal、diagonal、inverse_diagonal 或 radial。
foreground_gradient_onestring渐变第一种 HEX 颜色。
foreground_gradient_twostring渐变第二种 HEX 颜色。
background_colorstring#ffffff背景 HEX 颜色。请保持比模块更浅。
background_color_transparencyinteger0背景透明度,0–100。
custom_eyes_colorbooleanfalse若为 true,码眼使用 eyes_inner_color 和 eyes_outer_color。
eyes_inner_colorstring#000000内码眼 HEX 颜色。
eyes_outer_colorstring#000000外码眼 HEX 颜色。
qr_code_logostring徽标图片 URL 或已上传文件键。
qr_code_logo_sizenumber25徽标占二维码的百分比,5–40。
framestring工作室中的可选边框键。
frame_textstring绘制在边框上的说明文字。

按类型划分的内容字段

名称类型必填默认描述
phonestring当 type 为 phone 时的电话号码。
smsstring当 type 为 sms 时的电话号码。
sms_bodystringSMS 正文。
emailstring当 type 为 email 时的收件人。
email_subjectstring邮件主题。
email_bodystring邮件正文。
whatsappstringWhatsApp 号码,仅数字。
whatsapp_bodystringWhatsApp 预填文本。
wifi_ssidstring当 type 为 wifi 时的网络名称。
wifi_passwordstringWi-Fi 密码。
wifi_encryptionstringWPAnopass、WEP、WPA 或 WPA/WPA2。
location_latitudenumber当 type 为 location 时的纬度。
location_longitudenumber当 type 为 location 时的经度。
eventstring当 type 为 event 时的活动标题。
event_start_datetimestring活动开始的 ISO 日期时间。
vcard first_name / last_name / emailstringvCard 字段: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
列出 二维码
名称类型必填描述
pageintegerPage number (default 1)
results_per_pageintegerItems per page (default 25, max 100)
searchstringSearch term
search_bystringColumn to search
order_bystringSort column
order_typestringasc or desc
datetime_startstringISO datetime filter start
datetime_endstringISO datetime filter end
project_idinteger
typestring
curl -X GET 'https://forqrcode.com/api/v1/qr-codes' \
  -H 'Authorization: Bearer YOUR_API_KEY'
GET/api/v1/qr-codes/{id}
读取一个 二维码
名称类型必填描述
idinteger
curl -X GET 'https://forqrcode.com/api/v1/qr-codes/{id}' \
  -H 'Authorization: Bearer YOUR_API_KEY'
PATCH/api/v1/qr-codes/{id}
更新 二维码
名称类型必填默认描述
idinteger
namestring保存在资源上的标签。
typestringurl内容类型。受支持的 QR 键之一,不包括 file。
urlstring目标 URL。当 type 为 url 时必填。
textstring纯文本。当 type 为 text 时必填。批量文本请在此字段中分行。
url_dynamicbooleanfalse若为 true,会创建短链接,二维码编码该链接,以便日后更改目标。
project_idinteger要将资源附加到的项目。
is_bulkbooleanfalse若为 true 且 type 为 text,则 text 中每行创建一个二维码。
stylestringsquare模块形状。例如:square、dot、rounded、heart、hexagon。
inner_eye_stylestringsquare内定位图案形状。例如:square、dot、circle、rounded。
outer_eye_stylestringsquare外定位图案形状。例如:square、circle、rounded、flower。
sizeinteger500图像尺寸(像素),50–2000。
margininteger0静区模块数,0–25。
eccstringM纠错级别:L、M、Q 或 H。添加徽标时使用 H。
foreground_typestringcolorcolor 或 gradient。
foreground_colorstring#000000模块颜色,HEX。
foreground_gradient_stylestringhorizontalvertical、horizontal、diagonal、inverse_diagonal 或 radial。
foreground_gradient_onestring渐变第一种 HEX 颜色。
foreground_gradient_twostring渐变第二种 HEX 颜色。
background_colorstring#ffffff背景 HEX 颜色。请保持比模块更浅。
background_color_transparencyinteger0背景透明度,0–100。
custom_eyes_colorbooleanfalse若为 true,码眼使用 eyes_inner_color 和 eyes_outer_color。
eyes_inner_colorstring#000000内码眼 HEX 颜色。
eyes_outer_colorstring#000000外码眼 HEX 颜色。
qr_code_logostring徽标图片 URL 或已上传文件键。
qr_code_logo_sizenumber25徽标占二维码的百分比,5–40。
framestring工作室中的可选边框键。
frame_textstring绘制在边框上的说明文字。

请求示例

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}
删除 二维码
名称类型必填描述
idinteger
curl -X DELETE 'https://forqrcode.com/api/v1/qr-codes/{id}' \
  -H 'Authorization: Bearer YOUR_API_KEY'

参数名与 JSON 示例为英文。请将 YOUR_API_KEY 替换为您的密钥。