API Documentation

Complete reference for the BarGen API

Introduction

The BarGen API enables generation of SVG format barcodes and QR codes through simple HTTP requests.

Base URL

https://api.bargen.pro/

Authentication

Every API request requires an API key, which can be generated from your dashboard.

The key must be sent in the X-API-Key header:

curl -H "X-API-Key: your-api-key" \
  "https://api.bargen.pro/v1/barcode/qrcode?data=Hello"

Generate Barcode

GET https://api.bargen.pro/v1/barcode/{type}

Parameters

Parameter Type Required Default Description
type string Yes - Barcode type (in URL path)
data string Yes - Data to encode
scale integer No 2 Scale factor (1-10)
height integer No - Height in pixels (1D codes)
width integer No - Width in modules (2D codes)
color string No 000000 Foreground color hex
bgcolor string No ffffff Background color hex
includetext boolean No true Show text below barcode
fontsize integer No 14 Font size for text (8-24)
ecl string No M Error correction level (QR only) (L/M/Q/H)
format string No svg Output format: svg (all plans), png, pdf, eps (Pro/Enterprise)
pngzoom float No 1 PNG zoom factor (0.5-10). Use 2-3 for retina, 5+ for print (Pro/Enterprise)

Supported Types

qrcode
code128
ean13
ean8
upca
upce
code39
codabar
itf14
datamatrix
pdf417
aztec

Example Request

# SVG (default)
curl -H "X-API-Key: your-key" \
  "https://api.bargen.pro/v1/barcode/qrcode?data=https://example.com&scale=4"

# PNG standard resolution (Pro/Enterprise)
curl -H "X-API-Key: your-key" -o barcode.png \
  "https://api.bargen.pro/v1/barcode/qrcode?data=https://example.com&format=png"

# PNG print quality - 5x zoom (Pro/Enterprise)
curl -H "X-API-Key: your-key" -o barcode-hires.png \
  "https://api.bargen.pro/v1/barcode/ean13?data=5901234123457&format=png&pngzoom=5"

Response

SVG - Returns SVG image with Content-Type: image/svg+xml

<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" ...>
  ...
</svg>

PNG/PDF/EPS - Binary image data (Pro/Enterprise)

Content-Type: image/png | application/pdf | application/postscript

Error Codes

Code Meaning
400Bad request (invalid parameters)
401Missing or invalid API key
429Rate limit exceeded
500Server error

Rate Limits

Currently, the API is free with unlimited requests. Rate limits may be introduced in the future.