Skip to main content

Endpoint

POST https://api.bunny.build/api/v1/barcode

Authentication

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

Overview

Generate barcodes and QR codes on demand. Bunny’s Barcode API converts any text or URL into a pixel-perfect image: QR codes, Code 128, EAN-13, PDF417, Data Matrix, and more. Returns a base64-encoded PNG ready to embed in web pages, PDFs, or print flows.

Use cases

  • Product labels and inventory management
  • QR code generation for links and contact cards
  • Shipping and logistics barcode printing
  • Event tickets and access passes

Details

Supported types: qrcode, code128, code39, ean13, ean8, upca, upce, pdf417, datamatrix, azteccode, interleaved2of5. All barcodes are rendered as PNG at a fixed scale with human-readable text below the symbol where applicable.

Request body

FieldTypeRequiredDescription
datastringYesThe data to encode in the barcode
typestringNoBarcode type (e.g. qrcode, code128, ean13). Default: "code128"

Example

{
  "type": "qrcode",
  "data": "https://example.com"
}

Response

200 OK

FieldTypeDescription
barcode_base64stringBase64-encoded PNG barcode image
mime_typestringAlways "image/png"
typestringThe barcode type used
datastringThe encoded data
Example
{
  "barcode_base64": "iVBORw0KGgoAAAANSUhEUgAA...",
  "mime_type": "image/png",
  "type": "qrcode",
  "data": "https://example.com"
}

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": "Invalid barcode type or data"
}

429 Too Many Requests

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

cURL example

curl -X POST https://api.bunny.build/api/v1/barcode \
  -H "X-API-Key: bun_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"type": "qrcode", "data": "https://example.com"}'