QR Code Generator API

Comprehensive API documentation for generating and customizing QR codes programmatically

Fast GenerationAPI Key AuthFull Customization

Base URL

All API requests should be made to the following base URL:

https://generate.niceqrcodes.com

Authentication

All API requests require authentication using an API key. Include your API key in the request headers.

API Key Required

You must have an active subscription with API access enabled. Generate your API key from your account dashboard.

Header Format

Authorization: Bearer YOUR_API_KEY

Replace YOUR_API_KEY with your actual API key.

Rate Limiting

API requests are rate-limited to ensure fair usage and system stability.

Rate Limit: 1 request per second per API key

If you exceed the rate limit, you will receive a 429 Too Many Requests response. Please implement exponential backoff in your application.

POST

Generate QR Code

Generate a customizable QR code with advanced styling options. The QR code can encode URLs, text, or other data.

Endpoint

POST /api/qr/generate

Request Headers

Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Request Body

{
  "content": "https://example.com",
  "type": "url",
  "title": "My QR Code",
  "description": "QR code for example.com",
  "style": {
    "width": 500,
    "height": 500,
    "dotsColor": "#000000",
    "backgroundColor": "#ffffff",
    "dotsType": "rounded",
    "cornersType": "extra-rounded",
    "errorCorrectionLevel": "H"
  }
}

Request Parameters

ParameterTypeRequiredDescription
contentstringYesThe content to encode (URL, text, etc.)
typestringYesType of content: "url", "text", "email", "phone", "sms", "wifi"
titlestringNoTitle for the QR code
descriptionstringNoDescription of the QR code
styleobjectNoStyling options (see Style Options section)

Response (Success)

{
  "jobId": "job_abc123xyz",
  "status": "queued",
  "message": "QR generation job started"
}

The API uses asynchronous job processing. Use the jobId to check the status.

Check Job Status

GET /api/qr/generate?jobId=job_abc123xyz

Response (Completed)

{
  "jobId": "job_abc123xyz",
  "status": "completed",
  "qrCode": {
    "id": "qr_123456",
    "shortId": "AbCdEf",
    "title": "My QR Code",
    "description": "QR code for example.com",
    "content": "https://example.com",
    "type": "url",
    "imageUrl": "https://generate.niceqrcodes.com/qr/AbCdEf/image",
    "trackingUrl": "https://link.niceqrcodes.com/AbCdEf",
    "createdAt": "2024-01-15T10:30:00.000Z",
    "status": "active"
  }
}

Style Options

Customize the appearance of your QR codes with these style options. All dimensions are in pixels.

PropertyTypeDefaultDescription
widthnumber300Width of QR code (must equal height, square only)
heightnumber300Height of QR code (must equal width, square only)
dotsColorstring"#000000"Color of QR code dots (hex format)
backgroundColorstring"#ffffff"Background color (hex format)
dotsTypestring"square"Shape of dots: "square", "rounded", "dots", "classy", "classy-rounded", "extra-rounded"
cornersTypestring"square"Shape of corner squares: "square", "rounded", "extra-rounded"
cornersDotTypestring"square"Shape of corner dots: "square", "dot"
errorCorrectionLevelstring"M"Error correction level: "L", "M", "Q", "H" (H = highest)
marginnumber16Margin around QR code in pixels
dotsGradientobjectnullGradient for dots (see Gradient Options)
backgroundGradientobjectnullGradient for background (see Gradient Options)
cornersGradientobjectnullGradient for corners (see Gradient Options)
logoImagestringnullBase64 encoded image or data URL for logo
logoSizenumber0.2Logo size as fraction of QR code (0.1 - 0.8)
logoMarginnumber0Margin around logo in pixels
hideBackgroundDotsbooleanfalseHide dots behind logo

Gradient Options

Gradients can be applied to dots, background, or corners. Use either linear or radial gradients.

{
  "type": "linear",  // or "radial"
  "rotation": 45,    // degrees for linear gradients
  "colorStops": [
    { "offset": 0, "color": "#ff6b6b" },
    { "offset": 1, "color": "#4ecdc4" }
  ]
}
GET

Get QR Code Statistics

Retrieve analytics and statistics for a specific QR code.

Endpoint

GET /api/user-analytics/:userId

Response

{
  "success": true,
  "analytics": [
    {
      "shortId": "AbCdEf",
      "title": "My QR Code",
      "scanCount": 42,
      "lastScanned": "2024-01-15T10:30:00.000Z",
      "createdAt": "2024-01-01T09:00:00.000Z"
    }
  ]
}
GET

List QR Codes

Retrieve all QR codes for your account.

Endpoint

GET /api/user-qr-codes/:userId

Response

{
  "success": true,
  "qrCodes": [
    {
      "id": "qr_123456",
      "shortId": "AbCdEf",
      "title": "My QR Code",
      "description": "QR code for example.com",
      "content": "https://example.com",
      "type": "url",
      "imageUrl": "https://generate.niceqrcodes.com/qr/AbCdEf/image",
      "trackingUrl": "https://link.niceqrcodes.com/AbCdEf",
      "status": "active",
      "createdAt": "2024-01-01T09:00:00.000Z"
    }
  ]
}
PATCH

Update QR Code

Update the title, description, or status of an existing QR code.

Endpoint

PATCH /api/create-qr-record/:id

Request Body

{
  "title": "Updated Title",
  "description": "Updated description",
  "isActive": true
}
DELETE

Delete QR Code

Delete a QR code. This action cannot be undone.

Endpoint

DELETE /api/create-qr-record/:id

Error Handling

The API uses standard HTTP status codes and returns error details in the response body.

401 Unauthorized

{
  "error": "Authentication required",
  "message": "Invalid or missing API key"
}

429 Too Many Requests

{
  "error": "Rate limit exceeded",
  "message": "Maximum 1 request per second allowed",
  "retryAfter": 1
}

400 Bad Request

{
  "error": "Validation error",
  "message": "Content and type are required"
}

403 Forbidden

{
  "error": "Access denied",
  "message": "API access is not available on your current plan"
}

Code Examples

JavaScript/Node.js

const API_KEY = 'your_api_key_here';
const BASE_URL = 'https://generate.niceqrcodes.com';

async function generateQRCode() {
  const response = await fetch(`${BASE_URL}/api/qr/generate`, {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      content: 'https://example.com',
      type: 'url',
      title: 'Example QR Code',
      style: {
        width: 500,
        height: 500,
        dotsColor: '#0066cc',
        backgroundColor: '#ffffff',
        dotsType: 'rounded',
        cornersType: 'extra-rounded'
      }
    })
  });

  const data = await response.json();

  if (data.jobId) {
    // Poll for completion
    const result = await pollJobStatus(data.jobId);
    return result;
  }

  return data;
}

async function pollJobStatus(jobId) {
  while (true) {
    const response = await fetch(`${BASE_URL}/api/qr/generate?jobId=${jobId}`, {
      headers: {
        'Authorization': `Bearer ${API_KEY}`
      }
    });

    const data = await response.json();

    if (data.status === 'completed') {
      return data;
    } else if (data.status === 'failed') {
      throw new Error(data.error);
    }

    // Wait 1 second before checking again
    await new Promise(resolve => setTimeout(resolve, 1000));
  }
}

Python

import requests
import time

API_KEY = 'your_api_key_here'
BASE_URL = 'https://generate.niceqrcodes.com'

def generate_qr_code():
    headers = {
        'Authorization': f'Bearer {API_KEY}',
        'Content-Type': 'application/json'
    }

    payload = {
        'content': 'https://example.com',
        'type': 'url',
        'title': 'Example QR Code',
        'style': {
            'width': 500,
            'height': 500,
            'dotsColor': '#0066cc',
            'backgroundColor': '#ffffff',
            'dotsType': 'rounded',
            'cornersType': 'extra-rounded'
        }
    }

    response = requests.post(
        f'{BASE_URL}/api/qr/generate',
        headers=headers,
        json=payload
    )

    data = response.json()

    if 'jobId' in data:
        return poll_job_status(data['jobId'])

    return data

def poll_job_status(job_id):
    headers = {
        'Authorization': f'Bearer {API_KEY}'
    }

    while True:
        response = requests.get(
            f'{BASE_URL}/api/qr/generate',
            params={'jobId': job_id},
            headers=headers
        )

        data = response.json()

        if data['status'] == 'completed':
            return data
        elif data['status'] == 'failed':
            raise Exception(data['error'])

        time.sleep(1)

cURL

# Generate QR Code
curl -X POST https://generate.niceqrcodes.com/api/qr/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "https://example.com",
    "type": "url",
    "title": "Example QR Code",
    "style": {
      "width": 500,
      "height": 500,
      "dotsColor": "#0066cc",
      "backgroundColor": "#ffffff"
    }
  }'

# Check Job Status
curl -X GET "https://generate.niceqrcodes.com/api/qr/generate?jobId=job_abc123xyz" \
  -H "Authorization: Bearer YOUR_API_KEY"