Need QR codes for every product in your catalog? Every seat at your event? Every flyer in your marketing campaign? This guide shows you how to efficiently generate QR codes in bulk.
Two Approaches to Bulk Generation
You can generate QR codes in bulk using two methods:
- Sequential API calls: Loop through your data and make individual requests (simpler, works for any plan)
- Batch endpoint: Send multiple items in a single request (faster, Pro plan)
Method 1: Sequential Generation
Perfect for small to medium batches (up to a few hundred QR codes):
const products = [
{ id: 'SKU001', url: 'https://shop.com/product/1' },
{ id: 'SKU002', url: 'https://shop.com/product/2' },
{ id: 'SKU003', url: 'https://shop.com/product/3' },
// ... more products
];
async function generateBulkQRCodes(items) {
const results = [];
for (const item of items) {
const response = await fetch('https://www.qrcodeapi.io/api/generate', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
data: item.url,
size: 300,
format: 'png'
})
});
const blob = await response.blob();
results.push({
id: item.id,
qrCode: blob
});
// Small delay to respect rate limits
await new Promise(r => setTimeout(r, 100));
}
return results;
}
const qrCodes = await generateBulkQRCodes(products);
Method 2: Parallel Generation
For faster processing with higher rate limits:
async function generateParallel(items, concurrency = 5) {
const results = [];
for (let i = 0; i < items.length; i += concurrency) {
const batch = items.slice(i, i + concurrency);
const batchResults = await Promise.all(
batch.map(async (item) => {
const response = await fetch('https://www.qrcodeapi.io/api/generate', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({ data: item.url, size: 300 })
});
return {
id: item.id,
qrCode: await response.blob()
};
})
);
results.push(...batchResults);
console.log(`Processed ${Math.min(i + concurrency, items.length)}/${items.length}`);
}
return results;
}
// Generate 5 QR codes at a time
const qrCodes = await generateParallel(products, 5);
Saving QR Codes to Files
Here's how to save the generated QR codes to files:
const fs = require('fs');
const path = require('path');
async function saveQRCodes(qrCodes, outputDir) {
// Create output directory
if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir, { recursive: true });
}
for (const { id, qrCode } of qrCodes) {
const buffer = Buffer.from(await qrCode.arrayBuffer());
const filePath = path.join(outputDir, `${id}.png`);
fs.writeFileSync(filePath, buffer);
}
console.log(`Saved ${qrCodes.length} QR codes to ${outputDir}`);
}
await saveQRCodes(qrCodes, './qr-codes');
Common Use Cases
Product Inventory
Generate QR codes for each product SKU linking to product details, manuals, or warranty registration.
Event Tickets
Create unique QR codes for each attendee for check-in and ticket validation.
Marketing Materials
Generate different QR codes for different flyer versions to A/B test messaging.
Asset Tracking
Create QR codes for equipment, inventory items, or shipments for tracking and management.
Best Practices
- Respect rate limits: Add delays between requests or use the concurrency control pattern
- Handle errors gracefully: Implement retry logic for failed requests
- Use meaningful file names: Name files with IDs or descriptions for easy reference
- Store mappings: Keep a CSV or database linking QR codes to their destinations
- Test first: Generate a small batch first to verify settings before bulk generation
Ready for Bulk QR Generation?
Get started with an API key and generate QR codes at scale.
Get Your Free API Key