QR Code Generator API
Comprehensive API documentation for generating and customizing QR codes programmatically
Table of Contents
Base URL
All API requests should be made to the following base URL:
https://generate.niceqrcodes.comAuthentication
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_KEYReplace 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.
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/generateRequest Headers
Authorization: Bearer YOUR_API_KEY
Content-Type: application/jsonRequest 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
| Parameter | Type | Required | Description |
|---|---|---|---|
content | string | Yes | The content to encode (URL, text, etc.) |
type | string | Yes | Type of content: "url", "text", "email", "phone", "sms", "wifi" |
title | string | No | Title for the QR code |
description | string | No | Description of the QR code |
style | object | No | Styling 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_abc123xyzResponse (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.
| Property | Type | Default | Description |
|---|---|---|---|
width | number | 300 | Width of QR code (must equal height, square only) |
height | number | 300 | Height of QR code (must equal width, square only) |
dotsColor | string | "#000000" | Color of QR code dots (hex format) |
backgroundColor | string | "#ffffff" | Background color (hex format) |
dotsType | string | "square" | Shape of dots: "square", "rounded", "dots", "classy", "classy-rounded", "extra-rounded" |
cornersType | string | "square" | Shape of corner squares: "square", "rounded", "extra-rounded" |
cornersDotType | string | "square" | Shape of corner dots: "square", "dot" |
errorCorrectionLevel | string | "M" | Error correction level: "L", "M", "Q", "H" (H = highest) |
margin | number | 16 | Margin around QR code in pixels |
dotsGradient | object | null | Gradient for dots (see Gradient Options) |
backgroundGradient | object | null | Gradient for background (see Gradient Options) |
cornersGradient | object | null | Gradient for corners (see Gradient Options) |
logoImage | string | null | Base64 encoded image or data URL for logo |
logoSize | number | 0.2 | Logo size as fraction of QR code (0.1 - 0.8) |
logoMargin | number | 0 | Margin around logo in pixels |
hideBackgroundDots | boolean | false | Hide 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 QR Code Statistics
Retrieve analytics and statistics for a specific QR code.
Endpoint
GET /api/user-analytics/:userIdResponse
{
"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"
}
]
}List QR Codes
Retrieve all QR codes for your account.
Endpoint
GET /api/user-qr-codes/:userIdResponse
{
"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"
}
]
}Update QR Code
Update the title, description, or status of an existing QR code.
Endpoint
PATCH /api/create-qr-record/:idRequest Body
{
"title": "Updated Title",
"description": "Updated description",
"isActive": true
}Delete QR Code
Delete a QR code. This action cannot be undone.
Endpoint
DELETE /api/create-qr-record/:idError 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"