Developer Guide

QR Code Generator API: Complete Developer Documentation Guide

Comprehensive guide to QR code generator APIs. Learn about endpoints, authentication, code examples, rate limits, and best practices for integrating QR code generation into your applications.

QR Mommy Team
November 20, 2025
20 min read

QR code APIs enable developers to programmatically generate, customize, and track QR codes at scale. Whether you're building an e-commerce platform, event management system, or marketing automation tool, understanding QR code APIs is essential. This comprehensive guide covers everything you need to integrate QR code generation into your applications.

1. What is a QR Code API?

A QR code API (Application Programming Interface) is a set of protocols and tools that allows developers to create, customize, and manage QR codes programmatically. Instead of manually generating QR codes through a web interface, APIs enable automated, scalable QR code creation directly from your application code.

Core API Functions

  • Generate static QR codes
  • Create dynamic (trackable) QR codes
  • Customize colors, logos, and styles
  • Retrieve scan analytics
  • Update QR code destinations
  • Bulk generate multiple codes

Response Formats

  • PNG image (base64 or URL)
  • SVG vector format
  • PDF document
  • EPS for print
  • JSON metadata

2. API Use Cases

QR code APIs power a wide range of applications across industries:

E-commerce Platforms

Generate QR codes for product pages, order tracking, warranty registration, and mobile payments. Automatically create codes when new products are added to inventory.

Event Management

Issue unique QR code tickets for attendees, track check-ins in real-time, and enable contactless badge scanning. Integrate with registration systems for automated ticket generation.

Marketing Automation

Create personalized QR codes for direct mail campaigns, track engagement by campaign/segment, and generate unique codes for A/B testing different landing pages.

Inventory and Asset Management

Generate QR codes for asset tagging, track equipment locations and maintenance history, and automate label printing when new items are added.

Document Management

Embed QR codes in invoices, contracts, and reports linking to digital copies. Enable document verification and access to supplementary materials.

3. Authentication Methods

QR code APIs use various authentication methods to secure access:

API Key Authentication

The most common method. Include your API key in request headers or query parameters.

// Header authentication
curl -X POST https://api.example.com/qr \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json"

// Query parameter
GET /qr?api_key=YOUR_API_KEY&data=https://example.com

OAuth 2.0

Used by enterprise APIs for delegated authorization and token refresh.

// Get access token
POST /oauth/token
{
  "grant_type": "client_credentials",
  "client_id": "your_client_id",
  "client_secret": "your_client_secret"
}

// Use token in requests
Authorization: Bearer {access_token}

Basic Authentication

Simple username/password encoding. Less common for modern APIs.

Authorization: Basic base64(username:password)

Security Best Practices

  • - Never expose API keys in client-side code
  • - Use environment variables for key storage
  • - Rotate keys periodically
  • - Use separate keys for development and production
  • - Monitor for unauthorized usage

4. Common API Endpoints

Most QR code APIs follow RESTful conventions with these standard endpoints:

MethodEndpointDescription
POST/qr-codesCreate a new QR code
GET/qr-codesList all QR codes
GET/qr-codes/{id}Get specific QR code details
PUT/qr-codes/{id}Update QR code (dynamic only)
DELETE/qr-codes/{id}Delete a QR code
GET/qr-codes/{id}/analyticsGet scan analytics
GET/qr-codes/{id}/downloadDownload QR code image
POST/qr-codes/bulkCreate multiple QR codes

5. Request Parameters

Common parameters when creating QR codes via API:

Required Parameters

ParameterTypeDescription
datastringThe content to encode (URL, text, etc.)
typestringQR code type (url, vcard, wifi, email, sms)

Customization Parameters

ParameterTypeDescription
sizeintegerImage size in pixels (e.g., 300)
colorstringForeground color (hex: #000000)
backgroundColorstringBackground color (hex: #FFFFFF)
logostringLogo URL or base64 image
errorCorrectionstringL, M, Q, or H
formatstringOutput format (png, svg, pdf)
marginintegerQuiet zone size in modules

Dynamic QR Code Parameters

ParameterTypeDescription
namestringInternal name for organization
folderIdstringFolder/project ID for organization
tagsarrayTags for filtering and search
expiresAtdatetimeExpiration date for time-limited codes

6. Code Examples

Here are practical code examples for common QR code API operations:

JavaScript (Node.js) - Create QR Code

const axios = require('axios');

async function createQRCode(data, options = {}) {
  try {
    const response = await axios.post(
      'https://api.qrmommy.com/v1/qr-codes',
      {
        data: data,
        type: 'url',
        size: options.size || 300,
        color: options.color || '#000000',
        backgroundColor: options.backgroundColor || '#FFFFFF',
        errorCorrection: options.errorCorrection || 'M',
        format: options.format || 'png'
      },
      {
        headers: {
          'Authorization': `Bearer ${process.env.QR_API_KEY}`,
          'Content-Type': 'application/json'
        }
      }
    );

    return response.data;
  } catch (error) {
    console.error('Error creating QR code:', error.response?.data);
    throw error;
  }
}

// Usage
const qrCode = await createQRCode('https://mywebsite.com', {
  size: 400,
  color: '#1a73e8'
});
console.log('QR Code URL:', qrCode.imageUrl);

Python - Create Dynamic QR Code with Logo

import requests
import os

def create_qr_with_logo(url, logo_url, name):
    api_key = os.environ.get('QR_API_KEY')

    payload = {
        'data': url,
        'type': 'url',
        'name': name,
        'size': 500,
        'color': '#2563eb',
        'backgroundColor': '#ffffff',
        'logo': logo_url,
        'errorCorrection': 'H',  # High for logo support
        'format': 'png'
    }

    headers = {
        'Authorization': f'Bearer {api_key}',
        'Content-Type': 'application/json'
    }

    response = requests.post(
        'https://api.qrmommy.com/v1/qr-codes',
        json=payload,
        headers=headers
    )

    if response.status_code == 201:
        return response.json()
    else:
        raise Exception(f'API Error: {response.text}')

# Usage
qr = create_qr_with_logo(
    url='https://mystore.com/product/123',
    logo_url='https://mystore.com/logo.png',
    name='Product 123 QR'
)
print(f"QR Code ID: {qr['id']}")
print(f"Download URL: {qr['imageUrl']}")

PHP - Bulk QR Code Generation

<?php
function bulkCreateQRCodes($items) {
    $apiKey = getenv('QR_API_KEY');

    $qrCodes = array_map(function($item) {
        return [
            'data' => $item['url'],
            'name' => $item['name'],
            'type' => 'url',
            'size' => 300,
            'tags' => $item['tags'] ?? []
        ];
    }, $items);

    $ch = curl_init('https://api.qrmommy.com/v1/qr-codes/bulk');

    curl_setopt_array($ch, [
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POST => true,
        CURLOPT_POSTFIELDS => json_encode(['qrCodes' => $qrCodes]),
        CURLOPT_HTTPHEADER => [
            'Authorization: Bearer ' . $apiKey,
            'Content-Type: application/json'
        ]
    ]);

    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    if ($httpCode === 201) {
        return json_decode($response, true);
    }

    throw new Exception('Bulk creation failed: ' . $response);
}

// Usage
$items = [
    ['url' => 'https://store.com/product/1', 'name' => 'Product 1', 'tags' => ['electronics']],
    ['url' => 'https://store.com/product/2', 'name' => 'Product 2', 'tags' => ['electronics']],
    ['url' => 'https://store.com/product/3', 'name' => 'Product 3', 'tags' => ['clothing']]
];

$result = bulkCreateQRCodes($items);
echo "Created " . count($result['qrCodes']) . " QR codes\n";

cURL - Get Analytics

# Get scan analytics for a specific QR code
curl -X GET "https://api.qrmommy.com/v1/qr-codes/qr_abc123/analytics" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "startDate": "2025-01-01",
    "endDate": "2025-01-31",
    "groupBy": "day"
  }'

# Response example:
{
  "totalScans": 1523,
  "uniqueScans": 892,
  "scansByDate": [
    {"date": "2025-01-01", "scans": 45},
    {"date": "2025-01-02", "scans": 62}
  ],
  "scansByLocation": [
    {"country": "US", "city": "New York", "scans": 234},
    {"country": "US", "city": "Los Angeles", "scans": 189}
  ],
  "scansByDevice": [
    {"os": "iOS", "scans": 823},
    {"os": "Android", "scans": 700}
  ]
}

7. Rate Limits and Quotas

API providers implement rate limits to ensure fair usage and system stability:

PlanRequests/MinuteQR Codes/MonthBulk Limit
Free10505 per request
Basic6050025 per request
Professional3005,000100 per request
Enterprise1,000+Unlimited500 per request

Handling Rate Limits

APIs return rate limit information in response headers:

X-RateLimit-Limit: 60
X-RateLimit-Remaining: 45
X-RateLimit-Reset: 1640995200

Implement exponential backoff when hitting limits. Check remaining quota before bulk operations.

8. Error Handling

APIs return standard HTTP status codes with detailed error messages:

StatusMeaningCommon Causes
400Bad RequestInvalid parameters, malformed JSON
401UnauthorizedInvalid or missing API key
403ForbiddenInsufficient permissions, plan limits
404Not FoundQR code ID doesn't exist
429Too Many RequestsRate limit exceeded
500Server ErrorInternal API error

Error Response Format

{
  "error": {
    "code": "INVALID_PARAMETER",
    "message": "The 'color' parameter must be a valid hex color",
    "field": "color",
    "documentation": "https://docs.qrmommy.com/errors/INVALID_PARAMETER"
  }
}

9. Webhooks and Callbacks

Webhooks notify your application of events in real-time without polling:

Common Webhook Events

  • qr.scanned - QR code was scanned
  • qr.created - New QR code created
  • qr.updated - QR code destination changed
  • qr.deleted - QR code was deleted
  • limit.approaching - Near usage limit

Webhook Payload Example

{
  "event": "qr.scanned",
  "timestamp": "2025-01-15T10:30:00Z",
  "data": {
    "qrCodeId": "qr_abc123",
    "scanId": "scan_xyz789",
    "location": {
      "country": "US",
      "city": "New York",
      "latitude": 40.7128,
      "longitude": -74.0060
    },
    "device": {
      "os": "iOS",
      "version": "17.2",
      "browser": "Safari"
    }
  },
  "signature": "sha256=abc123..."
}

10. Best Practices

Follow these practices for reliable and efficient API integration:

Security

  • - Store API keys in environment variables
  • - Use HTTPS for all requests
  • - Validate webhook signatures
  • - Implement key rotation
  • - Log access for auditing

Performance

  • - Use bulk endpoints for multiple codes
  • - Cache responses where appropriate
  • - Implement retry logic with backoff
  • - Monitor rate limit headers
  • - Use webhooks instead of polling

Reliability

  • - Handle all error codes gracefully
  • - Implement circuit breakers
  • - Set appropriate timeouts
  • - Log errors for debugging
  • - Test in staging before production

Maintainability

  • - Use SDK/client libraries when available
  • - Abstract API calls into services
  • - Document integration points
  • - Version your integration code
  • - Monitor for API deprecations

11. Choosing a QR Code API Provider

Consider these factors when selecting a QR code API:

Features Checklist

Dynamic QR code support

Custom branding/logos

Multiple QR code types

Bulk generation

Detailed analytics

Webhook support

Multiple export formats

SDKs for your language

Technical Considerations

  • Uptime SLA: Look for 99.9%+ availability guarantees
  • Latency: Sub-200ms response times for generation
  • Documentation: Comprehensive, with examples in multiple languages
  • Support: Response time guarantees, priority support for higher tiers
  • Compliance: GDPR, SOC 2, or industry-specific requirements

Why Choose QR Mommy API

QR Mommy offers a developer-friendly API with comprehensive features, competitive pricing, and excellent documentation. Create dynamic QR codes with full customization, track scans in real-time, and scale from prototype to production.

12. Frequently Asked Questions

Is there a free QR code API?

Yes, most QR code APIs offer free tiers with limited features or monthly quotas. Free tiers are great for testing and small projects. For production use, paid plans provide higher limits, better support, and additional features.

How do I test the API without writing code?

Use tools like Postman or curl to make test requests. Most API providers also offer interactive documentation where you can test endpoints directly in the browser.

Can I generate QR codes without an internet connection?

Static QR codes can be generated offline using libraries like qrcode.js (JavaScript) or qrcode (Python). However, dynamic QR codes with tracking require an API for the redirect service.

What's the best format for QR code images?

Use SVG or PDF for print (vector formats scale without quality loss). Use PNG for digital display. Avoid JPEG as compression can affect scannability.

How do I track which marketing channel drove scans?

Create separate dynamic QR codes for each channel (print ad, billboard, product packaging) and use unique names or tags. Your analytics dashboard will show scans per code.

Can I white-label the QR codes?

Many enterprise API plans offer white-labeling where the short URL domain and branding can be customized. This removes any reference to the QR code provider.

Ready to Integrate QR Codes into Your Application?

Get started with QR Mommy's developer-friendly API. Comprehensive documentation, SDKs, and support to help you build.

Ready to Create Your Own QR Codes?

Start generating professional QR codes with advanced analytics and customization. No credit card required.

Found this article helpful? Share it with your network!