X114
返回 API 总览

qr-code

POST1 积分

Encodes a payload into a QR code and returns it in the requested format. PNG and SVG are suitable for direct rendering; UTF-8 is useful for terminal UIs and quick previews.

端点

POST https://x114.org/api/v1/qr-code

请求体

以 JSON 形式放在 POST 请求体中。

NameTypeRequiredDescription
textstringrequiredThe payload to encode. Up to 4 KB of UTF-8 (less at higher error correction).
format"png" | "svg" | "utf8"optionalOutput format. "png" returns a base64 data URL; "svg" returns SVG markup; "utf8" returns block characters for terminals. Defaults to "png".
errorCorrectionLevel"L" | "M" | "Q" | "H"optionalQR error correction level. Defaults to "M".
widthnumberoptionalPixel size for PNG (64-2048) or logical width for SVG/UTF-8. Defaults to 256.

响应体

成功时返回的 JSON(HTTP 200)。

NameTypeRequiredDescription
okbooleanrequiredTrue on success.
formatstringrequiredThe format returned ("png" | "svg" | "utf8").
errorCorrectionLevelstringrequiredThe error correction level that was used.
widthnumberrequiredThe width that was used (after clamping to the allowed range).
mimeTypestringrequiredMIME type of the output: "image/png" for png, "image/svg+xml" for svg, "text/plain" for utf8.
outputstringrequiredThe encoded QR — base64 data URL when format is "png", SVG markup when "svg", block-character text when "utf8".

示例

curl -X POST https://x114.org/api/v1/qr-code \
  -H "Authorization: Bearer sk_..." \
  -H "Content-Type: application/json" \
  -d '{"text":"https://x114.org","format":"svg","width":256}'
在浏览器里试

这个免费工具无需写代码即可得到相同结果。

打开工具