开发者 QR 码 API 指南

QR 码 API 允许用户以编程方式生成高质量的 QR 码,或集成高效的批量 QR 码生成。它提供了一种简单高效的方式来创建适用于各种场景的 QR 码,例如自动支付、应用集成、产品标签生成等。该 API 支持不同的自定义选项,包括大小、颜色、形状、边框、类型等。开发者可以通过 HTTP 请求并提供 API 密钥进行身份验证,或者使用我们的库将其集成到应用程序中。

API 密钥

您账户的 API 密钥可以在 账户页面 创建。API 密钥可以作为 URL 参数包含在请求中,例如:

速率限制

速率限制的实施是为了确保 API 的公平使用。免费套餐每小时包含 180 个令牌。普通 QR 码每个消耗 1 个令牌,每小时最多 180 个令牌,相当于每 20 秒 1 个 QR 码。此外,快速调用端点将消耗 1/50 个令牌,相当于每秒 2.5 个 QR 码。当 QR 码不需要自定义时,推荐使用这些快速端点。如果超出令牌限制,将返回状态码 429,表示请求已被速率限制。

禁止使用多个账户规避这些限制。如需更高的限额,请联系我们了解定价信息。

Java Library

静态 QR 码 API

QR 码类型

QR 码类型是所有 QR 码的基础。它决定了数据的编码方式以及扫描 QR 码后的行为。选择合适的类型至关重要,因为它会影响 QR 码的功能。以下是所有可用类型的列表。

Text

参数 类型 可选 描述
type Int false Use 0 For a Text QR Code
text String false QR 码中的文本。

WiFi

参数 类型 可选 描述
type Int false Use 1 For a WiFi QR Code
network String false Wi-Fi 网络名称。
password String true Wi-Fi 密码。
hidden String true 是否隐藏 Wi-Fi 网络。
encryption String true Wi-Fi 网络的加密方式。

可选值

wep 若 Wi-Fi 网络仍使用旧版 WEP 加密,则选择此项。
nopass 若 Wi-Fi 网络无密码,则选择此项。
wpa 默认值。用于 WPA 加密。如果不确定使用哪种,请选择此项。

SMS

参数 类型 可选 描述
type Int false Use 2 For a SMS QR Code
text String false 短信内容。
number String false 电话号码。

Email

参数 类型 可选 描述
type Int false Use 3 For a Email QR Code
email String true “收件人”字段中的电子邮件地址。
subject String true 电子邮件的主题。
message String true 电子邮件的内容。

Phone

参数 类型 可选 描述
type Int false Use 4 For a Phone QR Code
number String false 电话号码。

Crypto

参数 类型 可选 描述
type Int false Use 5 For a Crypto QR Code
cryptotype String false 要发送的加密货币类型。
address String false 接收方的加密货币地址。
amount String true 发送的加密货币金额。

vCard

参数 类型 可选 描述
type Int false Use 6 For a vCard QR Code
vc_first_name String false vCard 的名字。
vc_last_name String false vCard 的姓氏。
vc_company String true 公司名称。
vc_job String true 职位。
vc_street String true 街道地址。
vc_city String true 城市。
vc_state String true 省份/州。
vc_zip String true 邮政编码。
vc_country String true 国家。
vc_phone String true 电话号码。
vc_mobile String true 手机号码。
vc_fax String true 传真号码。
vc_website String true 网站 URL。
vc_email String true 电子邮件地址。

Whatsapp

参数 类型 可选 描述
type Int false Use 7 For a Whatsapp QR Code
number String false 电话号码。
text String true WhatsApp 消息内容。

vEvent

参数 类型 可选 描述
type Int false Use 8 For a vEvent QR Code
ve_summary String true vEvent 的摘要。
ve_description String true vEvent 的描述。
ve_location String true vEvent 的地点。
ve_timezone String true vEvent 的起止时间所使用的时区。例如,使用 "Europe/Amsterdam" 表示阿姆斯特丹时区。
ve_url String true vEvent 的 URL。
ve_start String true vEvent 的开始时间。例如,"20250101T083000" 表示 2025 年 1 月 1 日 08:30。
ve_end String true vEvent 的结束时间。例如,"20250101T093000" 表示 2025 年 1 月 1 日 09:30。

Geo

参数 类型 可选 描述
type Int false Use 9 For a Geo QR Code
ge_latitude String false 要编码的纬度。
ge_longitude String false 要编码的经度。

文字 QR 码示例

URL https://api.genqrcode.com/public/generate
请求方法 POST
头部 GenQRCode-apikey: API_KEY
请求体
{
  "type": 0,
  "text": "https://genqrcode.com"
}
响应 Text QR Code example

Wi-Fi QR 码示例

URL https://api.genqrcode.com/public/generate
请求方法 POST
头部 GenQRCode-apikey: API_KEY
请求体
{
  "type": 1,
  "network": "GenQRCode",
  "password": false,
  "hidden": false,
  "encryption": "wpa"
}
响应 WiFi QR Code example

通用参数

这里列出了所有可自定义的通用参数及其使用方法。

参数 类型 默认值 描述
imageformat String png QR 码的图像格式。

可选值

tiff TIFF 图像格式。
svg SVG 图像格式。
gif GIF 图像格式。
obj OBJ 图像格式。支持全彩。
png PNG 图像格式。
jpeg JPEG 图像格式。不支持透明度。
eps EPS 图像格式。
stl STL 图像格式。不支持颜色。
webp WEBP 图像格式。
3mf 3MF 图像格式。
bordersize Int 4 QR 码周围的边框大小。
width Int 500 QR 码的宽度。最大尺寸为 2000。
height Int 500 QR 码的高度。最大尺寸为 2000。

颜色参数

这里列出了所有可自定义的颜色参数及其使用方法。

参数 类型 默认值 描述
color String #000000 QR 码的颜色。格式应为 #RRGGBB 或 #RRGGBBAA。RGBA 值以十六进制表示,范围从 00 到 FF。
custom_color_pattern String 1 要使用的颜色模式。例如,如果颜色为 #ff0000、#00ff00 和 #0000ff,且模式为 1,2,3,3,2,1,则颜色将按照该模式交替出现。示例将在后续指南中提供。
background_color String #FFFFFF QR 码的背景颜色。若要使背景透明,请将 alpha 通道设置为 00,例如 #00000000。
inner_eye_color String #000000 QR 码内眼的颜色。
outer_eye_color String #000000 QR 码外眼的颜色。
frame_color String #000000 QR 码边框的颜色。需要启用边框,此设置才会生效。

颜色 QR 码示例

URL https://api.genqrcode.com/public/generate
请求方法 POST
头部 GenQRCode-apikey: API_KEY
请求体
{
  "type": 0,
  "text": "https://genqrcode.com",
  "color": "#ff0000",
  "background_color": "#aaffaa",
  "inner_eye_color": "#ffaaaa",
  "outer_eye_color": "#ffaaff"
}
响应 Color QR Code example

颜色模式 QR 码示例

URL https://api.genqrcode.com/public/generate
请求方法 POST
头部 GenQRCode-apikey: API_KEY
请求体
{
  "type": 0,
  "text": "https://genqrcode.com",
  "color": "#e81416,#faeb36,#79c314,#487de7,#4b369d,#70369d",
  "custom_color_pattern": "1,1,2,2,3,3,4,4,5,5,6,6"
}
响应 Color pattern QR Code example

边框、形状和 Logo 参数

这里列出了所有可自定义的边框、形状和 Logo 参数及其使用方法。

参数 类型 默认值 描述
style Int 0 QR 码方块的样式。
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
inner_eye_style Int 0 QR 码内眼的样式。
0
1
2
3
4
5
6
7
outer_eye_style Int 0 QR 码外眼的样式。
0
1
2
3
4
5
6
frame_style Int 0 QR 码边框的样式。
0
1
/> /> /> /> /> />SCAN ME
2
/> /> /> /> /> /> /> />SCAN ME
3
/> /> /> />SCAN ME
4
/> /> />SCAN ME
5
/>SCAN ME
6
/>SCAN ME
7
/> /> />
8
/> /> /> /> />
9
/> /> /> /> /> /> /> /> /> /> /> /> />
10
/> /> /> /> /> /> />SCAN ME
11
/> />SCAN ME
12
SCAN ME
13
SCAN ME
frame_text String SCAN ME 边框内的文本。必须先配置带文本的边框,此项才可见。
logo String QR 码内要使用的标志(Logo)。
youtube
wifi
google-maps
facebook
spotify
threads
zoom
instagram
linkedin
genqrcode
google-drive
airbnb
skype
snapchat
twitter
x-twitter
reddit
logo_remove_background Boolean false 是否去除 Logo 背景。

Logo 和形状 QR 码示例

URL https://api.genqrcode.com/public/generate
请求方法 POST
头部 GenQRCode-apikey: API_KEY
请求体
{
  "type": 0,
  "text": "https://x.com/genqrcode",
  "style": 22,
  "inner_eye_style": 1,
  "outer_eye_style": 4,
  "frame": 10,
  "frame_text": "My X Page",
  "logo": "x-twitter",
  "logo_remove_background":true
}
响应 Style and logo QR Code example

自定义 Logo 示例

使用自定义 Logo 需要通过 multipart form-data 请求上传 Logo。上传后的 Logo 可用于 Logo 字段。

URL https://api.genqrcode.com/public/upload/logo
请求方法 POST
头部 GenQRCode-apikey: API_KEY
Content-Type: multipart/form-data
响应 586d0136af8a06e4a2b50cf9f2af0b72

快速 QR 码 API

快速 QR 码 API 仅消耗普通 API 1/50 的令牌。生成的 QR 码经过优化,下载速度更快,文件体积更小。虽然支持所有 QR 码类型,但仅支持少量自定义参数。

快速 QR 码参数

这里列出了所有快速 QR 码参数及其使用方法。

参数 类型 默认值 描述
imageformat String png QR 码的图像格式。

可选值

svg SVG 图像格式。
png PNG 图像格式。
bordersize Int 4 QR 码周围的边框大小。
width Int 500 QR 码的宽度。将自动调整为最接近的预设尺寸,以避免缩放失真。最大尺寸为 4000。
height Int 500 QR 码的高度。将自动调整为最接近的预设尺寸,以避免缩放失真。最大尺寸为 4000。

快速文本 QR 码示例

URL https://api.genqrcode.com/public/fastgenerate
请求方法 POST
头部 GenQRCode-apikey: API_KEY
请求体
{
  "imageformat": "png",
  "type": 0,
  "text": "https://genqrcode.com"
}
响应 Text QR Code example

快速批量 QR 码 API

快速批量文本 QR 码示例

URL https://api.genqrcode.com/public/fastbatch
请求方法 POST
头部 GenQRCode-apikey: API_KEY
请求体
{
  "QR Code 1": {
    "text": "https://genqrcode.com",
    "type": 0,
    "width": 500,
    "bordersize": 4,
    "imageformat": "png",
    "height": 500
  },
  "QR Code 2": {
    "text": "https://genqrcode.com/dynamicview",
    "type": 0,
    "width": 500,
    "bordersize": 4,
    "imageformat": "png",
    "height": 500
  },
  "QR Code 3": {
    "text": "https://genqrcode.com/pricing",
    "type": 0,
    "width": 500,
    "bordersize": 4,
    "imageformat": "png",
    "height": 500
  }
}
响应 QR Codes in a zip file.