二维码

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

支持的类型

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

  • text
  • url
  • pdf
  • image
  • audio
  • app
  • instagram
  • facebook
  • telegram
  • tiktok
  • twitter
  • linkedin
  • youtube
  • spotify
  • 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是—保存在资源上的标签。
typestring是url内容类型。受支持的 QR 键之一,不包括 file。
urlstring否—目标 URL。当 type 为 url 时必填。
textstring否—纯文本。当 type 为 text 时必填。批量文本请在此字段中分行。
url_dynamicboolean否false若为 true,会创建短链接,二维码编码该链接,以便日后更改目标。
project_idinteger否—要将资源附加到的项目。
is_bulkboolean否false若为 true 且 type 为 text,则 text 中每行创建一个二维码。
stylestring否square模块形状。例如:square、dot、rounded、heart、hexagon。
inner_eye_stylestring否square内定位图案形状。例如:square、dot、circle、rounded。
outer_eye_stylestring否square外定位图案形状。例如:square、circle、rounded、flower。
sizeinteger否500图像尺寸(像素),50–2000。
margininteger否0静区模块数,0–25。
eccstring否M纠错级别:L、M、Q 或 H。添加徽标时使用 H。
foreground_typestring否colorcolor 或 gradient。
foreground_colorstring否#000000模块颜色,HEX。
foreground_gradient_stylestring否horizontalvertical、horizontal、diagonal、inverse_diagonal 或 radial。
foreground_gradient_onestring否—渐变第一种 HEX 颜色。
foreground_gradient_twostring否—渐变第二种 HEX 颜色。
background_colorstring否#ffffff背景 HEX 颜色。请保持比模块更浅。
background_color_transparencyinteger否0背景透明度,0–100。
custom_eyes_colorboolean否false若为 true,码眼使用 eyes_inner_color 和 eyes_outer_color。
eyes_inner_colorstring否#000000内码眼 HEX 颜色。
eyes_outer_colorstring否#000000外码眼 HEX 颜色。
qr_code_logostring否—徽标图片 URL 或已上传文件键。
qr_code_logo_sizenumber否25徽标占二维码的百分比,5–40。
framestring否—工作室中的可选边框键。
frame_textstring否—绘制在边框上的说明文字。

按类型划分的内容字段

名称类型必填默认描述
phonestring否—当 type 为 phone 时的电话号码。
smsstring否—当 type 为 sms 时的电话号码。
sms_bodystring否—SMS 正文。
emailstring否—当 type 为 email 时的收件人。
email_subjectstring否—邮件主题。
email_bodystring否—邮件正文。
whatsappstring否—WhatsApp 号码,仅数字。
whatsapp_bodystring否—WhatsApp 预填文本。
wifi_ssidstring否—当 type 为 wifi 时的网络名称。
wifi_passwordstring否—Wi-Fi 密码。
wifi_encryptionstring否WPAnopass、WEP、WPA 或 WPA/WPA2。
location_latitudenumber否—当 type 为 location 时的纬度。
location_longitudenumber否—当 type 为 location 时的经度。
eventstring否—当 type 为 event 时的活动标题。
event_start_datetimestring否—活动开始的 ISO 日期时间。
vcard first_name / last_name / emailstring否—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
列出 二维码
名称类型必填描述
pageinteger否Page number (default 1)
results_per_pageinteger否Items per page (default 25, max 100)
searchstring否Search term
search_bystring否Column to search
order_bystring否Sort column
order_typestring否asc or desc
datetime_startstring否ISO datetime filter start
datetime_endstring否ISO 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否—保存在资源上的标签。
typestring否url内容类型。受支持的 QR 键之一,不包括 file。
urlstring否—目标 URL。当 type 为 url 时必填。
textstring否—纯文本。当 type 为 text 时必填。批量文本请在此字段中分行。
url_dynamicboolean否false若为 true,会创建短链接,二维码编码该链接,以便日后更改目标。
project_idinteger否—要将资源附加到的项目。
is_bulkboolean否false若为 true 且 type 为 text,则 text 中每行创建一个二维码。
stylestring否square模块形状。例如:square、dot、rounded、heart、hexagon。
inner_eye_stylestring否square内定位图案形状。例如:square、dot、circle、rounded。
outer_eye_stylestring否square外定位图案形状。例如:square、circle、rounded、flower。
sizeinteger否500图像尺寸(像素),50–2000。
margininteger否0静区模块数,0–25。
eccstring否M纠错级别:L、M、Q 或 H。添加徽标时使用 H。
foreground_typestring否colorcolor 或 gradient。
foreground_colorstring否#000000模块颜色,HEX。
foreground_gradient_stylestring否horizontalvertical、horizontal、diagonal、inverse_diagonal 或 radial。
foreground_gradient_onestring否—渐变第一种 HEX 颜色。
foreground_gradient_twostring否—渐变第二种 HEX 颜色。
background_colorstring否#ffffff背景 HEX 颜色。请保持比模块更浅。
background_color_transparencyinteger否0背景透明度,0–100。
custom_eyes_colorboolean否false若为 true,码眼使用 eyes_inner_color 和 eyes_outer_color。
eyes_inner_colorstring否#000000内码眼 HEX 颜色。
eyes_outer_colorstring否#000000外码眼 HEX 颜色。
qr_code_logostring否—徽标图片 URL 或已上传文件键。
qr_code_logo_sizenumber否25徽标占二维码的百分比,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 替换为您的密钥。