QR codes are everywhere — from restaurant menus to payment systems, event tickets to WiFi sharing. As a developer, you'll eventually need to generate QR codes programmatically, and using a **QR code API** is the fastest, most reliable way to do it. In this guide, we'll show you how to generate QR codes using the **ToolCenter QR API**, including customization options, real-world use cases, and code examples in multiple languages. ## Why Use a QR Code API? While there are QR code libraries for every programming language, a hosted API offers several advantages: - **No dependencies** — No need to install image processing libraries - **Consistent output** — Same quality across all platforms - **Customization** — Colors, sizes, error correction levels, and more - **CDN delivery** — Generated QR codes served from edge locations - **No server-side rendering** — Offload image generation to the API - **Integration simplicity** — A single HTTP request generates your QR code ## Real-World Use Cases ### 1. Payment Links Mobile payment apps like Venmo, CashApp, and cryptocurrency wallets use QR codes to encode payment addresses: ``` bitcoin:1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa?amount=0.001 ``` ### 2. WiFi Sharing Encode WiFi credentials in a QR code that phones can scan to auto-connect: ``` WIFI:T:WPA;S:MyNetworkName;P:MyPassword123;; ``` ### 3. Product Links and Marketing Link physical products to digital experiences — scan to open product pages, reviews, or manuals. ### 4. Event Tickets Generate unique QR codes for each ticket that can be validated at the door: ``` TICKET:EVT-2026-001:SEAT-A12:VIP ``` ### 5. Contact Cards (vCard) Share contact information instantly: ``` BEGIN:VCARD VERSION:3.0 FN:John Developer TEL:+1234567890 EMAIL:[email protected] END:VCARD ``` ## ToolCenter QR Code API ### API Endpoint ``` POST https://toolcenter.dev/api/v1/qr ``` ### Parameters | Parameter | Type | Required | Description | |---|---|---|---| | `data` | string | Yes | Content to encode in the QR code | | `size` | integer | No | Image size in pixels (default: 300) | | `format` | string | No | Output format: png, svg, jpg (default: png) | | `fg_color` | string | No | Foreground color hex (default: #000000) | | `bg_color` | string | No | Background color hex (default: #FFFFFF) | | `error_correction` | string | No | Error correction level: L, M, Q, H (default: M) | | `margin` | integer | No | Quiet zone margin in modules (default: 4) | ### Error Correction Levels QR codes have built-in error correction, allowing them to be read even if partially damaged: | Level | Recovery | Best For | |---|---|---| | **L** (Low) | ~7% | Clean digital displays | | **M** (Medium) | ~15% | General use (recommended) | | **Q** (Quartile) | ~25% | Printed materials | | **H** (High) | ~30% | QR codes with logos overlay | ## Code Examples ### cURL ```bash # Simple QR code curl -X POST "https://toolcenter.dev/api/v1/qr" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "data": "https://example.com", "size": 400, "format": "png" }' \ --output qrcode.png # Custom colored QR code curl -X POST "https://toolcenter.dev/api/v1/qr" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "data": "https://example.com", "size": 500, "format": "png", "fg_color": "#1a73e8", "bg_color": "#ffffff", "error_correction": "H" }' \ --output qrcode-branded.png ``` ### Node.js ```javascript const ToolCenter = require('devtoolbox-sdk'); const fs = require('fs'); const client = new ToolCenter('YOUR_API_KEY'); // Generate a simple QR code async function generateQR() { const qr = await client.qr({ data: 'https://example.com', size: 400, format: 'png' }); fs.writeFileSync('qrcode.png', qr); console.log('QR code generated!'); } // Generate WiFi QR code async function generateWiFiQR(ssid, password, encryption = 'WPA') { const wifiString = `WIFI:T:${encryption};S:${ssid};P:${password};;`; const qr = await client.qr({ data: wifiString, size: 500, fgColor: '#2d3748', bgColor: '#ffffff', errorCorrection: 'H' }); fs.writeFileSync('wifi-qr.png', qr); console.log(`WiFi QR for "${ssid}" generated!`); } // Generate payment QR code async function generatePaymentQR(address, amount) { const qr = await client.qr({ data: `bitcoin:${address}?amount=${amount}`, size: 300, errorCorrection: 'H' }); fs.writeFileSync('payment-qr.png', qr); } generateQR(); generateWiFiQR('MyNetwork', 'SecurePass123'); ``` ### Python ```python from devtoolbox import ToolCenter client = ToolCenter("YOUR_API_KEY") # Generate a simple QR code qr = client.qr( data="https://example.com", size=400, format="png" ) with open("qrcode.png", "wb") as f: f.write(qr) print("QR code generated!") # Generate vCard QR code vcard = """BEGIN:VCARD VERSION:3.0 FN:Jane Developer ORG:ToolCenter TEL:+1234567890 EMAIL:[email protected] URL:https://devtoolbox.com END:VCARD""" qr = client.qr( data=vcard, size=500, error_correction="Q" ) with open("contact-qr.png", "wb") as f: f.write(qr) print("Contact QR code generated!") ``` ### PHP ```php use ToolCenter\Client; $client = new Client('YOUR_API_KEY'); // Generate a simple QR code $qr = $client->qr([ 'data' => 'https://example.com', 'size' => 400, 'format' => 'png', ]); file_put_contents('qrcode.png', $qr); // Generate event ticket QR code $ticketData = json_encode([ 'event' => 'DevConf 2026', 'ticket_id' => 'TCK-001-VIP', 'seat' => 'A12', 'holder' => 'John Doe', ]); $qr = $client->qr([ 'data' => $ticketData, 'size' => 300, 'error_correction' => 'H', 'fg_color' => '#1a1a2e', 'bg_color' => '#ffffff', ]); file_put_contents('ticket-qr.png', $qr); echo "Ticket QR generated!\n"; ``` ## Customization Tips ### Brand Colors Use your brand colors for the foreground, but ensure sufficient contrast: ```json { "fg_color": "#1a73e8", "bg_color": "#ffffff" } ``` **Important:** Always maintain high contrast between foreground and background. Dark foreground on light background works best. Avoid light foreground colors as many scanners struggle with them. ### Choosing the Right Size | Use Case | Recommended Size | |---|---| | Web display | 200-300px | | Print (flyers, posters) | 400-600px | | Large format (billboards) | 800-1000px | | Favicon/icon | 100-150px | ### SVG for Scalability For print materials or responsive web displays, use SVG format: ```bash curl -X POST "https://toolcenter.dev/api/v1/qr" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"data": "https://example.com", "format": "svg"}' \ --output qrcode.svg ``` SVG QR codes scale infinitely without losing quality — perfect for print. ## Bulk QR Code Generation Need to generate hundreds of QR codes? Use ToolCenter's bulk endpoint: ```javascript const ToolCenter = require('devtoolbox-sdk'); const client = new ToolCenter('YOUR_API_KEY'); const urls = [ 'https://example.com/product/1', 'https://example.com/product/2', 'https://example.com/product/3', // ... hundreds more ]; const results = await client.bulk('qr', urls.map(url => ({ data: url, size: 400, format: 'png' }))); console.log(`Generated ${results.length} QR codes`); ``` ## Best Practices 1. **Always use error correction** — Level M or higher for printed QR codes 2. **Test with multiple scanners** — Not all QR scanners handle custom colors well 3. **Include a quiet zone** — The white margin around the QR code is essential for scanning 4. **Keep data short** — Shorter data produces simpler, more scannable QR codes 5. **Use URL shorteners** for long URLs — Less data means a less dense QR code 6. **Provide fallback** — Always show the URL or data as text near the QR code ## Pricing QR code generation is included in all ToolCenter plans: | Plan | Price | Monthly Requests | |---|---|---| | Free | $0 | 100 | | Starter | $9/mo | 5,000 | | Pro | $29/mo | 25,000 | | Business | $79/mo | 100,000 | All plans include QR codes, screenshots, PDFs, OG images, and metadata extraction. ## Conclusion Generating QR codes with the **ToolCenter QR API** is simple, fast, and reliable. Whether you need a single QR code for your WiFi or thousands for event tickets, the API handles it all with full customization support. Combined with ToolCenter's other tools — screenshots, PDFs, OG images, and metadata extraction — you have a complete developer toolkit at your fingertips. **[Generate Your First QR Code →](https://toolcenter.dev)** --- *Need help? Check the [API documentation](https://toolcenter.dev/docs) for detailed endpoint references and more examples.*