Skip to main content

Endpoint

POST https://api.bunny.build/api/v1/qr-code

Authentication

HeaderRequiredValue
X-API-KeyYesYour API key (bun_...)
Content-TypeYesapplication/json

Overview

Generate QR codes from any text or URL in PNG or SVG format. Control the output size, error correction level, and foreground/background colors. PNG responses include a base64-encoded image ready to embed directly in your application; SVG responses include the raw SVG string.

Use cases

  • Display QR codes during mobile app onboarding to link devices
  • Generate payment links or promo URLs for print and digital campaigns
  • Embed product catalog entries with scannable links
  • Issue event tickets with encoded check-in data

Request body

FieldTypeRequiredDescription
datastringYesThe text or URL to encode (max 4296 characters)
formatstringNoOutput format: "png" or "svg". Default: "png"
sizeintegerNoImage width in pixels for PNG output (100–1000). Default: 300
error_correctionstringNoError correction level: "L", "M", "Q", or "H". Default: "M"
darkstringNoHex color for dark modules. Default: "#000000"
lightstringNoHex color for light modules. Default: "#ffffff"

Example

{
  "data": "https://bunny.build",
  "format": "png",
  "size": 300
}

Response

200 OK — PNG format

FieldTypeDescription
formatstring"png"
datastringOriginal input data (echoed)
qr_base64stringBase64-encoded PNG image
mime_typestring"image/png"
sizeintegerActual image width in pixels
error_correctionstringError correction level used
Example
{
  "format": "png",
  "data": "https://bunny.build",
  "qr_base64": "iVBORw0KGgoAAAANSUhEUgAA...",
  "mime_type": "image/png",
  "size": 300,
  "error_correction": "M"
}

200 OK — SVG format

FieldTypeDescription
formatstring"svg"
datastringOriginal input data (echoed)
qrstringRaw SVG string
error_correctionstringError correction level used
Example
{
  "format": "svg",
  "data": "https://bunny.build",
  "qr": "<svg xmlns=\"http://www.w3.org/2000/svg\" ...>...</svg>",
  "error_correction": "M"
}

401 Unauthorized

{
  "detail": "Missing API key. Include X-API-Key header."
}

402 Payment Required

{
  "detail": "Monthly quota exceeded. Upgrade your plan."
}

422 Unprocessable Entity

{
  "detail": "Field 'data' is required."
}

429 Too Many Requests

{
  "detail": "Rate limit exceeded. Try again in 60 seconds."
}

cURL example

curl -X POST https://api.bunny.build/api/v1/qr-code \
  -H "X-API-Key: bun_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"data": "https://bunny.build", "format": "png", "size": 300}'