Skip to main content

QR Code API - 以编程方式生成二维码

使用 QR-Build 的 REST API,将二维码生成能力接入你的应用、SaaS 仪表盘、移动后端、电商流程或营销自动化系统。发送 JSON 参数,接收 PNG、SVG 或 base64 JSON 输出,并管理动态二维码目标地址,无需自行重建二维码生成逻辑。

网站

通过二维码将用户直接带到你的主页、落地页或活动页面。非常适合用于海报、传单或名片,免去输入网址的麻烦。

1 / 21
QR Code API 是一个 REST 端点,接收目标 URL、输出格式、图片尺寸和二维码类型等参数,然后返回二维码图片或数据对象。开发者使用它在应用中以编程方式生成二维码,而不是手动创建每个二维码。

什么是 QR Code API?

QR Code API 是一个 REST 端点,接收目标 URL、输出格式和图片尺寸等参数,并以 PNG、SVG 或 base64 编码 JSON 对象返回二维码。开发者可以在应用中以编程方式生成二维码,而无需自行构建或维护二维码库。

REST API 是基于 HTTP 的接口,遵循标准请求和响应约定。在 QR Code API 中,端点是应用调用的具体 URL,例如 POST /v1/qr;请求体包含 type、data、format、size、color 以及二维码是静态还是动态等参数。

当二维码创建需要发生在产品流程中时,开发者会选择 API:SaaS 用户点击创建、电商目录导入 5,000 个 SKU、移动应用请求可分享代码,或 CRM 活动在事件触发后生成可追踪的二维码资产。

QR-Build 同时支持静态二维码和动态二维码。静态二维码把最终目标直接存入图片;动态二维码存入 QR-Build 重定向层,让二维码在打印或分发后仍可编辑目标并查看扫码分析。

如何用 QR-Build API 生成二维码?

要通过 API 生成二维码,请向生成端点发送经过身份验证的 POST 请求,并提供 URL、格式、尺寸和二维码类型等参数。API 会返回二维码图片或包含图片数据的 JSON 对象,大多数基础实现不到 10 行代码即可完成。

QR-Build API 面向服务端集成设计。如果你想先使用手动流程,请查看如何在 Web UI 中创建二维码,当生成需要从代码运行时再使用 API。

  1. 1 APIキーで認証します。 APIキーはQR-Buildアカウントを識別し、各リクエストを認可する一意の認証文字列です。
  2. 2 POSTリクエストを送信します。 QRタイプ、遷移先データ、画像形式、サイズを含むJSONパラメータを生成エンドポイントへ送信します。
  3. 3 QRコードを受け取ります。 レスポンスは、要求した出力形式に応じてPNG URL、SVGマークアップ、base64 JSONペイロードを返せます。
  4. 4 必要に応じて動的な遷移先を更新します。 動的QRでは、印刷済みQR画像を再生成せずにPATCHリクエストでリダイレクト先を変更できます。
  5. 5 QRが動的な場合は分析を取得します。 分析GETエンドポイントを使い、スキャン数、時刻、場所、デバイス内訳を自社ダッシュボードへ取り込めます。

POST 请求示例

curl -X POST https://api.qr-build.com/v1/qr \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"type":"url","data":"https://example.com","format":"png","size":300}'

JSON 响应示例

{
  "id": "qr_8x4m2p",
  "type": "url",
  "format": "png",
  "static": true,
  "imageUrl": "https://cdn.qr-build.com/qr/qr_8x4m2p.png",
  "createdAt": "2026-07-01T12:00:00Z"
}

支持哪些 API 请求和响应格式?

QR Code API 通常支持用于打印和邮件的 PNG、用于可缩放网页渲染的 SVG,以及用于内联嵌入的 base64 JSON。PNG 是固定分辨率,SVG 在任何尺寸下都保持清晰,base64 避免单独请求图片文件。

根据二维码的显示位置、存储方式以及下游系统是否需要元数据来选择响应格式。我们按 DPI 行为、文件大小、浏览器支持和 HTTP 往返次数评估格式。

支持的输出格式

格式最适合说明
PNG 印刷、メール、すばやい埋め込み 固定解像度のラスター画像。印刷やパッケージには大きめのサイズを指定します。
SVG Webアプリ、拡大可能なUI、高DPIディスプレイ どのサイズでも鮮明なベクター形式で、レスポンシブなダッシュボードに適しています。
Base64 インラインHTML、PDF、ファイル不要のワークフロー 公開画像URLを別に持たず、JSONまたはHTML内に画像データを埋め込みます。
JSON プログラム処理とメタデータ保存 識別子、画像データ、遷移先、形式、作成メタデータを1つのレスポンスで返します。

API 支持的二维码类型

截至 2026 年,QR-Build API 支持 12 种二维码类型。更完整的概念指南见二维码类型

URL / link

Generate a QR code that opens a web page, landing page, support article, or app deep link.

WiFi

Encode network name, password, and security type so users can join a network after scanning.

vCard

Create contact QR codes with name, phone, email, company, job title, and website fields.

PDF

Point users to manuals, menus, brochures, compliance documents, or downloadable files.

Email

Open a prefilled email with recipient, subject, and body fields.

Phone

Create scan-to-call QR codes for service desks, sales teams, and support labels.

Menu

Generate QR codes for restaurant menus, seasonal menu pages, and table placements.

Coupon

Create promotional QR codes for discounts, redemption pages, and campaign offers.

Crypto

Encode wallet addresses and payment metadata for supported cryptocurrency flows.

PayPal

Create payment QR codes that route to PayPal payment or donation destinations.

Calendar

Generate QR codes for event details, appointment reminders, and calendar invites.

Bulk

Create many QR codes from one batch request for catalogs, tickets, labels, and print runs.

通过 API 使用静态与动态二维码

通过 API 生成的静态二维码会把目标 URL 直接编码进图片,因此生成后无法更改。动态二维码编码的是服务端管理的重定向 URL,因此之后可通过 PATCH 请求更新最终目标,而无需重新打印二维码。

静的か動的かの選択はアーキテクチャ判断です。固定の遷移先には静的QRを、キャンペーン、製品、ラベル、印刷物に編集や分析が必要な可能性がある場合は動的QRを使います。API以外での違いは静的QRコードと動的QRコードをご覧ください。

功能API 静态二维码API 动态二维码
遷移先を編集可能 いいえ はい
スキャン分析 いいえ はい
QRペイロード内のURL 直接の最終URL QR-Buildリダイレクト層
最適な用途 固定アセットと恒久リンク キャンペーン、製品、パッケージ、印刷物
遷移先更新方法 再生成して再印刷 管理エンドポイントへPATCH
プラン適合 無料枠でのテストと固定用途 分析と高ボリューム管理向け有料プラン

方法論メモ: この比較はQR-Build APIの動作に基づきます。本番導入前に、機能提供状況、レート制限、プラン要件をQRプロバイダーで必ず確認してください。

QRコードAPI連携のユースケース

QRコードAPI連携は、QR作成が別システムの一部である場合に最適です。製品カタログ、SaaSダッシュボード、モバイルアプリ、マーケティング自動化、イベントワークフロー、ドキュメント生成などです。APIは反復ワークフローから手動QR作成を取り除きます。

QR-BuildのAPIが手動ジェネレーターより有用な連携パターンです。

1

E-commerce - Per-product QR codes at scale

Generate QR codes for product pages, packaging inserts, warranty cards, receipts, and shelf labels as SKUs are created or updated. Bulk generation keeps QR output aligned with catalog data.

2

SaaS products - Embedded QR generation

Add QR creation to a dashboard without building a QR rendering engine, redirect layer, or analytics storage from scratch. Your product sends the request; QR-Build handles the QR output.

3

Marketing automation - Campaign QR codes

Trigger QR generation from CRM, CDP, email, or campaign events. Dynamic QR codes let marketers update destinations mid-campaign while keeping printed assets live.

4

Mobile apps - Lightweight API calls

iOS and Android apps can request QR images through a server-side backend, then render an image URL or base64 payload in the app without exposing the API key.

5

Document and label printing

Create QR codes for logistics labels, inventory sheets, compliance packets, and operational documents. This pattern is especially useful when labels are generated from database records.

See QR codes for inventory management

APIと手動QRジェネレーター - どちらを使うべきか

大量生成、コードからの生成トリガー、製品内へのQR機能埋め込みが必要な場合はQRコードAPIを使います。自動化や連携が不要な単発QRには手動ジェネレーターが適しています。

QR-BuildのQRコードジェネレーターは手動作成に適しています。APIは製品ワークフロー、バックエンドジョブ、自動化パイプラインからQR生成を実行する場合に適しています。

シナリオAPIを使う手動ジェネレーターを使う
One-off QR code for a flyer 最適
Generate 500+ QR codes for products 最適
QR codes embedded in a SaaS dashboard 最適
Campaign QR with an updatable destination 最適
Quick WiFi QR code for an office 最適
Real-time QR generation after user action 最適

API Key Authentication and Security

The QR-Build API uses API key authentication through the Authorization header, not API keys in URLs. Keep keys server-side, store them in environment variables, rotate compromised keys, and confirm current rate limits on the pricing page before production deployment.

An API key is account-scoped and should be sent as a Bearer token in the Authorization header. Do not place API keys in query strings, browser JavaScript, mobile app binaries, public repositories, or analytics logs.

Run QR generation calls from your backend, serverless function, or trusted integration service. Client-side apps should call your server, and your server should call QR-Build. This prevents users from extracting the key and consuming your quota.

Rate limiting is a server-enforced cap on requests per time window, and plan details can change as products evolve. Review the current pricing page before production rollout instead of relying on copied limits in a blog post or implementation ticket.

QR-Build enforces HTTPS for API traffic. For dynamic QR codes, the QR image stores the redirect layer, not the final destination URL; destination changes happen through authenticated management requests.

Code Examples for the QR Code API

The fastest QR code API integration is a server-side POST request with an Authorization header and a JSON body. The examples below show curl, JavaScript with fetch, and a PATCH request for updating a dynamic QR destination.

Methodology note: the examples below use the same API surface our own QR-Build web generator uses - no separate API tier. Replace placeholder keys and IDs with values from your account before testing.

Generate a URL QR Code (curl)

curl -X POST https://api.qr-build.com/v1/qr \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"type":"url","data":"https://example.com","format":"png","size":300}'

Generate a URL QR Code (JavaScript / Node.js)

const response = await fetch("https://api.qr-build.com/v1/qr", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.QR_BUILD_API_KEY}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    type: "url",
    data: "https://example.com",
    format: "svg",
    size: 300
  })
});

if (!response.ok) {
  throw new Error(`QR generation failed: ${response.status}`);
}

const qr = await response.json();
console.log(qr.imageUrl);

Update a Dynamic QR Destination

curl -X PATCH https://api.qr-build.com/v1/qr/qr_8x4m2p \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"destination":"https://example.com/new-campaign"}'

How Does Bulk QR Code Generation Work via API?

A bulk generation endpoint accepts an array of QR parameters in one request and returns a batch of QR codes, typically as a ZIP archive or JSON array of image data. This is more efficient than sending hundreds or thousands of sequential individual requests.

Bulk generation is designed for product catalogs, event tickets, packaging labels, inventory tags, print runs, and agency workflows where many QR codes share a common pattern but differ by destination or metadata.

A typical bulk request includes an array of rows, each with type, data, format, size, and optional label metadata. The response can return a job ID for asynchronous processing, a ZIP file URL, or a JSON array of generated QR assets depending on batch size and account settings.

For high-volume jobs, treat rate limits as part of the integration design. Queue batches, retry safely after rate-limit responses, and avoid regenerating static QR images when a cached asset is still valid.

Can You Access Scan Analytics via API?

Via the analytics GET endpoint, you can retrieve scan count, scan timestamps, device type breakdown, and geographic location data for each dynamic QR code. This data can be piped into dashboards, data warehouses, or BI tools for campaign performance analysis.

Scan analytics are collected when a dynamic QR code routes through the QR-Build redirect layer. Static QR codes do not pass through a redirect layer, so they cannot provide the same scan analytics model.

Analytics API access is useful when your product needs to show QR performance inside its own dashboard, combine scan data with CRM records, or export campaign events to a warehouse. For dashboard-based reporting, see the scan analytics dashboard guide.

A webhook is an HTTP callback that can notify your server when a scan event occurs. Webhooks are useful when scan data should trigger real-time downstream actions, such as lead scoring, inventory lookup, or campaign attribution.

Common QR Code API Integration Mistakes

The most common QR code API mistakes are exposing API keys, choosing static QR codes for destinations that will change, skipping error handling, requesting images too small for print, and cropping the quiet zone around the QR code.

Hardcoding API keys in client-side code

We've seen teams expose keys in browser JavaScript and mobile binaries. Always make API calls from a trusted server-side environment.

Using static QR when dynamic QR is needed

If the destination may change after print, use a dynamic QR code with a redirect layer. Static QR codes require regeneration and reprinting.

Not handling API errors or rate limits

Handle non-2xx responses, retry only when safe, and display clear failure states in your product instead of silently dropping QR generation.

Generating QR images at too low a resolution

Small PNG output can look fine on screen but fail on packaging or signage. Use SVG for scalable output or request larger PNG dimensions for print.

Ignoring quiet zone requirements

The quiet zone is the blank margin around the QR code. Cropping it can make an otherwise valid QR code difficult or impossible to scan.

Best Practices for QR Code API Integration

A strong QR code API integration keeps keys server-side, validates destinations before generation, uses dynamic QR codes for changeable campaigns, chooses SVG for scalable web rendering, and monitors scan analytics after launch.

Use dynamic QR for changeable destinations

Campaigns, product pages, support documents, and printed labels often change after distribution. Dynamic QR codes prevent costly reprints.

Cache generated static QR images

If a static QR code's payload is permanent, store the generated asset and reuse it instead of creating the same code repeatedly.

Match format to channel

Use SVG for responsive web interfaces, PNG for simple print and email workflows, and JSON or base64 when downstream systems need embedded image data.

Validate destination URLs

Validate and normalize URLs before generation so broken, unsafe, or malformed destinations do not become printed assets.

Monitor analytics after deployment

Use scan analytics to confirm that codes are being scanned, placements are working, and campaigns are routing users to the intended destination.

QR Code API Glossary

In QR-Build terminology, a QR code API combines an authenticated endpoint, a request payload, an output format, and optional dynamic redirect management. These terms define the moving parts developers need before integration.

We define these terms consistently across QR-Build's product, API, and documentation so developers, marketers, and product managers can make the same implementation decisions.

API key

An API key is a unique credential string that authenticates each request to the QR-Build API and connects usage to your account.

Endpoint

An endpoint is a specific URL your client sends requests to, such as POST /v1/qr for generation or GET /v1/qr/{id}/analytics for reporting.

Dynamic QR

A dynamic QR code is a QR code whose encoded URL points to a server-managed redirect layer, allowing the final destination to change after the QR is printed.

Redirect layer

A redirect layer is the QR-Build-managed URL encoded in a dynamic QR code; it forwards scanners to the current destination and enables analytics.

Scan analytics

Scan analytics are data collected when a dynamic QR code is scanned, including count, timestamp, device type, and geographic location.

Base64

Base64 is a binary-to-text encoding that lets QR image data travel inside JSON or HTML without a separate image file request.

Webhook

A webhook is an HTTP callback that notifies your server when a scan event or QR workflow event occurs.

QR Code API FAQ

A QR code API should answer the practical integration questions before a developer signs up: authentication, formats, dynamic updates, bulk generation, analytics, pricing, rate limits, and security.

Answers to developer, product, and integration questions about QR-Build API usage.

What is a QR code API?

A QR code API is a REST endpoint that accepts QR parameters such as type, URL, size, and format, then returns a QR code image or data object. It lets developers generate QR codes from application code instead of using a manual generator.

How do I generate a QR code with an API?

Authenticate with an API key, send a POST request with the QR parameters, and read the returned PNG, SVG, or JSON response. The simplest URL QR integration is a server-side HTTP request with a JSON body.

Is the QR-Build API free?

QR-Build offers free access for getting started with static QR generation. Dynamic QR codes, scan analytics, higher volume, and production features may require a paid plan; verify current details on the pricing page.

What output formats does the QR code API support?

The API supports PNG, SVG, base64, and JSON-style responses. Use PNG for simple print and email, SVG for scalable web or print rendering, and JSON or base64 when your application needs metadata and embedded image data.

What is the difference between static and dynamic QR codes via API?

A static QR code encodes the final destination directly into the image. A dynamic QR code encodes a redirect layer, so the destination can be edited later and scan analytics can be collected.

Can I update a dynamic QR code's destination via API?

Yes. Send a PATCH request to the QR code management endpoint with the new destination URL. The printed QR image does not need to be regenerated because the redirect layer routes future scans to the updated destination.

How do I generate bulk QR codes via API?

Use a batch request with an array of QR parameters. The API can return generated assets as a ZIP archive, a job result, or a JSON array depending on volume and account configuration.

What QR code types can I generate via the API?

As of 2026, QR-Build supports URL, WiFi, vCard, PDF, email, phone, menu, coupon, crypto, PayPal, calendar, and bulk QR workflows through API-oriented generation.

What authentication does the QR code API use?

The API uses API key authentication. Send the key as a Bearer token in the Authorization header and keep it server-side.

How do I keep my API key secure?

Store API keys in environment variables or a secret manager, make QR-Build calls from your server, never expose keys in client-side JavaScript, and rotate keys if they are committed or shared accidentally.

Can I access scan analytics via the API?

Yes. For dynamic QR codes, the analytics endpoint can return scan count, scan timestamps, device type, and location data. For dashboard-based analysis, see our QR code analytics guide.

What programming languages work with the QR code API?

Any language that can make HTTPS requests can use the API, including JavaScript, TypeScript, Python, Ruby, PHP, Go, Swift, Kotlin, Java, and C#.

What image size should I request for print use?

For print, request a large PNG or use SVG when possible. SVG is resolution-independent, while PNG should be sized high enough for the final printed dimensions and scan distance.

When should I use a QR code API instead of a manual generator?

Use the API for scale, automation, product integration, real-time generation, or campaign workflows. Use a manual generator for occasional one-off QR codes that do not need automation.

Can I use the QR code API in a mobile app?

Yes, but route calls through your server and deliver the generated image URL or data to the app. Do not embed your API key in an iOS or Android binary because it can be extracted.

相关 QR-Build 资源

把二维码生成接入你的产品

从免费 API 密钥开始,测试静态生成;当应用需要时,再加入动态二维码管理、批量流程和扫码分析。

速率限制和套餐详情会随时间变化;部署前请确认当前生产限制。

QR Code - QR-Build

需要从代码生成二维码?

获取 API 访问权限