Skip to content

Batch Generation

Generate multiple QR codes in a single API request. Returns a ZIP archive containing all generated images.

Pro Feature

Batch generation is available on Pro and Enterprise plans.

Endpoint

POST /api/batch

Request Body

json
{
  "items": [
    {
      "data": "https://example.com/product/1",
      "filename": "product-1.png"
    },
    {
      "data": "https://example.com/product/2",
      "filename": "product-2.png",
      "size": 500,
      "color": "4F46E5"
    },
    {
      "data": "https://example.com/product/3",
      "filename": "product-3.png"
    }
  ],
  "defaults": {
    "size": 300,
    "format": "png",
    "color": "000000",
    "background": "ffffff",
    "errorCorrection": "M"
  }
}

Request Fields

FieldTypeRequiredDescription
itemsarrayArray of QR codes to generate (max 100)
defaultsobject-Default settings for all items

Item Fields

FieldTypeRequiredDescription
datastringContent to encode
filenamestring-Output filename (auto-generated if not provided)
sizenumber-Override default size
formatstring-Override default format
colorstring-Override default color
backgroundstring-Override default background
errorCorrectionstring-Override default error correction

Response

Returns a ZIP file containing all generated QR codes.

Content-Type: application/zip
Content-Disposition: attachment; filename="qrcodes.zip"

Examples

Basic Batch Generation

bash
curl -X POST "https://www.qrcodeapi.io/api/batch" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "items": [
      {"data": "https://example.com/1"},
      {"data": "https://example.com/2"},
      {"data": "https://example.com/3"}
    ]
  }' \
  -o qrcodes.zip

With Custom Settings

bash
curl -X POST "https://www.qrcodeapi.io/api/batch" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "items": [
      {"data": "Product A", "filename": "product-a.png"},
      {"data": "Product B", "filename": "product-b.png"},
      {"data": "Product C", "filename": "product-c.png"}
    ],
    "defaults": {
      "size": 500,
      "color": "22c55e",
      "format": "png"
    }
  }' \
  -o products.zip

JavaScript Example

javascript
async function generateBatch(items, defaults = {}) {
  const response = await fetch('https://www.qrcodeapi.io/api/batch', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ items, defaults })
  });

  if (!response.ok) {
    const error = await response.json();
    throw new Error(error.message);
  }

  return response.blob();
}

// Generate QR codes for a product list
const products = [
  { id: 1, name: 'Widget A', url: 'https://shop.com/widget-a' },
  { id: 2, name: 'Widget B', url: 'https://shop.com/widget-b' },
  { id: 3, name: 'Widget C', url: 'https://shop.com/widget-c' }
];

const items = products.map(p => ({
  data: p.url,
  filename: `${p.name.toLowerCase().replace(' ', '-')}.png`
}));

const zipBlob = await generateBatch(items, {
  size: 400,
  color: '000000'
});

// Download the ZIP
const url = URL.createObjectURL(zipBlob);
const a = document.createElement('a');
a.href = url;
a.download = 'product-qrcodes.zip';
a.click();

Python Example

python
import requests
import zipfile
import io

def generate_batch(items, defaults=None):
    payload = {'items': items}
    if defaults:
        payload['defaults'] = defaults
    
    response = requests.post(
        'https://www.qrcodeapi.io/api/batch',
        json=payload,
        headers={'Authorization': f'Bearer {API_KEY}'}
    )
    
    response.raise_for_status()
    return response.content

# Generate QR codes for URLs
urls = [
    'https://example.com/page1',
    'https://example.com/page2',
    'https://example.com/page3'
]

items = [{'data': url, 'filename': f'qr-{i}.png'} for i, url in enumerate(urls)]

zip_content = generate_batch(items, {
    'size': 500,
    'color': '4F46E5'
})

# Extract the ZIP
with zipfile.ZipFile(io.BytesIO(zip_content)) as z:
    z.extractall('qrcodes/')

Node.js Example

javascript
const fs = require('fs');
const https = require('https');

async function generateBatch(items, defaults = {}) {
  return new Promise((resolve, reject) => {
    const payload = JSON.stringify({ items, defaults });
    
    const options = {
      hostname: 'www.qrcodeapi.io',
      path: '/api/batch',
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${API_KEY}`,
        'Content-Type': 'application/json',
        'Content-Length': Buffer.byteLength(payload)
      }
    };

    const req = https.request(options, (res) => {
      const chunks = [];
      res.on('data', chunk => chunks.push(chunk));
      res.on('end', () => resolve(Buffer.concat(chunks)));
    });

    req.on('error', reject);
    req.write(payload);
    req.end();
  });
}

// Usage
const items = [
  { data: 'https://example.com/1', filename: 'qr1.png' },
  { data: 'https://example.com/2', filename: 'qr2.png' },
  { data: 'https://example.com/3', filename: 'qr3.png' }
];

const zipBuffer = await generateBatch(items, { size: 400 });
fs.writeFileSync('qrcodes.zip', zipBuffer);

Limits

PlanMax Items per RequestRequests per Minute
Pro10010
Enterprise1,000100

Error Handling

Partial Failures

If some items fail but others succeed, the ZIP will contain:

  • Successfully generated QR codes
  • An errors.json file listing failures
json
{
  "errors": [
    {
      "index": 2,
      "data": "invalid-data-too-long...",
      "error": "Data exceeds maximum length"
    }
  ]
}

Common Errors

StatusMessageSolution
400items array requiredInclude items array in request
400Maximum 100 items allowedSplit into multiple requests
403Batch generation requires Pro planUpgrade your plan
429Rate limit exceededWait before retrying

Use Cases

Use CaseExample
Product CatalogGenerate QR codes for all SKUs
Event TicketsCreate unique QR codes for each attendee
Asset LabelsLabel equipment with QR codes
MarketingGenerate QR codes for multiple campaigns
InventoryCreate labels for warehouse items