API Documentation
Integrate professional QR code generation into your applications
Quick Start
Get started with the SmarterQRCodes.com API in under 5 minutes.
Generate your first QR code in 3 steps:
- Get your API key from your API Settings page
- Make a POST request to
https://smarterqrcodes.com/api/v1/generate - Receive your QR code as a PNG image or base64 data
Example Request
curl -X POST https://smarterqrcodes.com/api/v1/generate \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"content": "https://example.com", "format": "base64"}'
Authentication
All API requests require authentication using an API key. Include your API key in the request header:
X-API-Key: YOUR_API_KEY
Getting Your API Key
- Upgrade to a Pro or Business plan (API is included on Pro, Business, and Lifetime)
- Navigate to API Settings
- Click "Generate API Key"
- Store your key securely - it won't be shown again
Rate Limits
API access is included on the Pro, Business, and Lifetime plans. Requests are rate-limited per minute (no monthly cap).
| Plan | API Access | Rate Limit |
|---|---|---|
| Free / Personal | Not included | — |
| Pro | Included | 30 requests / minute |
| Business | Included | 30 requests / minute |
| Lifetime | Included | 30 requests / minute |
Rate Limit Headers
Each API response includes headers showing your current usage:
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 847
X-RateLimit-Reset: 1704067200
Endpoints
The SmarterQRCodes.com API provides three main endpoints for QR code generation.
/api/v1/generate
RECOMMENDED
Main API endpoint with full authentication, tracking, and all features including gradient support.
Use this endpoint for: Production applications, authenticated access, usage tracking
/api/v1/generate-qr
Simplified QR generation endpoint (no authentication required for testing).
Use this endpoint for: Quick testing, internal tools, simple QR generation
/api/v1/generate-qr-stl
UNIQUE
Generate 3D printable QR codes in STL format. Perfect for physical applications, signage, and products.
Use this endpoint for: 3D printing, physical products, innovative applications
Request Format
All requests must be sent as JSON with the Content-Type: application/json header.
Basic Request Structure
{
"content": "https://example.com",
"name": "My QR Code",
"format": "base64",
"design": {
"foreground": "#000000",
"background": "#FFFFFF",
"body_style": "rounded",
"eye_frame_style": "circle",
"error_correction": "M"
}
}
Top-Level Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
content |
string | Required | The data to encode in the QR code (URL, text, vCard, etc.) |
name |
string | Optional | Display name for the QR code (for tracking purposes) |
format |
string | Optional | base64 for JSON response with base64 data, omit for binary PNG |
design |
object | Optional | Design customization options (see Design Parameters section) |
Response Format
Success Response (format: "base64")
{
"success": true,
"qr_id": 12345,
"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
}
| Field | Type | Description |
|---|---|---|
success |
boolean | Always true for successful responses |
qr_id |
integer | Unique ID for the generated QR code |
image |
string | Base64-encoded PNG image with data URI prefix |
Success Response (binary format)
When format is omitted or not "base64", the response is a binary PNG image:
Content-Type: image/png
Content-Length: 12345
[PNG binary data]
Error Response
{
"error": "Invalid API key"
}
Design Parameters
Customize your QR code appearance with these design parameters.
Basic Colors
| Parameter | Type | Default | Description |
|---|---|---|---|
foreground |
string | #000000 | QR code color (hex format) |
background |
string | #FFFFFF | Background color (hex format) |
size |
integer | 300 | Image size in pixels (width and height) |
Shape Customization
| Parameter | Options | Description |
|---|---|---|
body_style |
square, circle, rounded, diamond, dots, plus, hexagon, triangle | Shape of the QR code data modules |
eye_frame_style |
square, rounded, circle, diamond, rotated, hexagon | Shape of the outer eye frames (corners) |
eye_ball_style |
square, rounded, circle, diamond, star, heart, triangle | Shape of the inner eye balls (corners) |
Error Correction
| Level | Recovery | Use Case |
|---|---|---|
L |
~7% | Clean environments, digital displays |
M |
~15% | Recommended default |
Q |
~25% | Outdoor use, potential damage |
H |
~30% | Maximum durability, logos embedded |
Gradient Support UNIQUE FEATURE
Create stunning gradient QR codes - a feature unique to SmarterQRCodes.com!
Why Gradients?
Stand out with beautiful gradient QR codes that are still 100% scannable. Perfect for branding, marketing materials, and creative applications.
Gradient Request Example
{
"content": "https://example.com",
"design": {
"color_mode": "gradient",
"gradient_color1": "#667eea",
"gradient_color2": "#764ba2",
"gradient_direction": "diagonal",
"background": "#FFFFFF"
}
}
Gradient Parameters
| Parameter | Type | Options/Default | Description |
|---|---|---|---|
color_mode |
string | "gradient" | Set to "gradient" to enable gradient mode |
gradient_color1 |
string | #667eea | Start color (hex format) |
gradient_color2 |
string | #764ba2 | End color (hex format) |
gradient_direction |
string | diagonal, horizontal, vertical, radial | Direction of the gradient |
3D STL Generation UNIQUE FEATURE
Generate 3D printable QR codes in STL format - perfect for physical products, signage, and innovative applications.
STL Request Example
curl -X POST https://smarterqrcodes.com/api/v1/generate-qr-stl \
-H "Content-Type: application/json" \
-d '{
"data": "https://example.com",
"stl_height": 3.0,
"stl_base_height": 1.0,
"stl_max_dimension": 100.0
}' \
--output qrcode.stl
STL-Specific Parameters
| Parameter | Type | Default | Range | Description |
|---|---|---|---|---|
stl_height |
float | 3.0 | 1.0 - 20.0 mm | Height of raised modules |
stl_base_height |
float | 1.0 | 0.1 - stl_height | Height of base/recessed modules |
stl_max_dimension |
float | 100.0 | 10.0 - 300.0 mm | Maximum width/depth dimension |
- Use higher error correction (Q or H) for physical QR codes
- Minimum recommended size: 50mm for good scannability
- Test scan printed QR codes from various distances
- Consider contrasting filament colors for better scanning
STL Response
The endpoint returns an STL file for download:
Content-Type: application/sla
Content-Disposition: attachment; filename="qrcode_example.stl"
[STL binary data]
Error Codes
The API uses standard HTTP status codes to indicate success or failure.
| Status Code | Error Type | Description | Solution |
|---|---|---|---|
| 200 | Success | Request completed successfully | - |
| 400 | Bad Request | Missing or invalid parameters | Check required fields and data types |
| 401 | Unauthorized | Missing or invalid API key | Verify your API key in X-API-Key header |
| 403 | Forbidden | API access not available for your tier | Upgrade to a paid subscription |
| 429 | Too Many Requests | Monthly rate limit exceeded | Wait for reset or upgrade your plan |
| 500 | Internal Server Error | Server error during processing | Contact support if persists |
Error Response Format
{
"error": "Descriptive error message"
}
Code Examples
Complete examples in multiple programming languages.
cURL
Command line tool for making HTTP requests
Basic QR Code
curl -X POST https://smarterqrcodes.com/api/v1/generate \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"content": "https://example.com", "format": "base64"}' \
-o qrcode.json
Gradient QR Code
curl -X POST https://smarterqrcodes.com/api/v1/generate \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "https://example.com",
"format": "base64",
"design": {
"color_mode": "gradient",
"gradient_color1": "#667eea",
"gradient_color2": "#764ba2",
"gradient_direction": "diagonal"
}
}'
Python
Using the requests library
Basic Example with Error Handling
import requests
import json
import base64
from pathlib import Path
class SmarterQRClient:
def __init__(self, api_key):
self.api_key = api_key
self.base_url = "https://smarterqrcodes.com/api/v1"
self.headers = {
"X-API-Key": api_key,
"Content-Type": "application/json"
}
def generate_qr(self, content, design=None, name=None):
"""Generate a QR code"""
data = {
"content": content,
"format": "base64"
}
if name:
data["name"] = name
if design:
data["design"] = design
try:
response = requests.post(
f"{self.base_url}/generate",
headers=self.headers,
json=data
)
response.raise_for_status()
result = response.json()
if result.get("success"):
return result
else:
raise Exception(result.get("error", "Unknown error"))
except requests.exceptions.RequestException as e:
raise Exception(f"API request failed: {str(e)}")
def save_qr_image(self, image_data, filename):
"""Save base64 image data to file"""
# Remove data URI prefix
image_data = image_data.split(',')[1]
image_bytes = base64.b64decode(image_data)
Path(filename).write_bytes(image_bytes)
# Usage
client = SmarterQRClient("YOUR_API_KEY")
# Generate basic QR code
result = client.generate_qr(
content="https://example.com",
name="My Website QR"
)
print(f"Generated QR Code ID: {result['qr_id']}")
client.save_qr_image(result['image'], "qrcode.png")
# Generate gradient QR code
gradient_design = {
"color_mode": "gradient",
"gradient_color1": "#667eea",
"gradient_color2": "#764ba2",
"gradient_direction": "diagonal",
"body_style": "rounded",
"error_correction": "H"
}
result = client.generate_qr(
content="https://example.com",
design=gradient_design,
name="Gradient QR"
)
client.save_qr_image(result['image'], "gradient_qr.png")
JavaScript / Node.js
Using fetch API
Modern Async/Await Example
class SmarterQRClient {
constructor(apiKey) {
this.apiKey = apiKey;
this.baseUrl = 'https://smarterqrcodes.com/api/v1';
}
async generateQR(content, design = null, name = null) {
const data = {
content,
format: 'base64'
};
if (name) data.name = name;
if (design) data.design = design;
try {
const response = await fetch(`${this.baseUrl}/generate`, {
method: 'POST',
headers: {
'X-API-Key': this.apiKey,
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.error || `HTTP ${response.status}`);
}
const result = await response.json();
if (result.success) {
return result;
} else {
throw new Error(result.error || 'Unknown error');
}
} catch (error) {
console.error('QR generation failed:', error);
throw error;
}
}
async generateSTL(content, stlOptions = {}) {
const data = {
data: content,
...stlOptions
};
const response = await fetch(`${this.baseUrl}/generate-qr-stl`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
});
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
return response.blob();
}
}
// Usage Examples
const client = new SmarterQRClient('YOUR_API_KEY');
// Generate basic QR code
async function createBasicQR() {
try {
const result = await client.generateQR('https://example.com', null, 'Website QR');
console.log('QR Code ID:', result.qr_id);
// Display in img tag
document.getElementById('qrImage').src = result.image;
} catch (error) {
console.error('Failed to generate QR:', error);
}
}
// Generate gradient QR code
async function createGradientQR() {
const design = {
color_mode: 'gradient',
gradient_color1: '#667eea',
gradient_color2: '#764ba2',
gradient_direction: 'diagonal',
body_style: 'circle',
error_correction: 'H'
};
try {
const result = await client.generateQR('https://example.com', design, 'Gradient QR');
document.getElementById('gradientQR').src = result.image;
} catch (error) {
console.error('Failed to generate gradient QR:', error);
}
}
// Generate 3D STL file
async function create3DQR() {
try {
const stlBlob = await client.generateSTL('https://example.com', {
stl_height: 3.0,
stl_base_height: 1.0,
stl_max_dimension: 100.0
});
// Create download link
const url = URL.createObjectURL(stlBlob);
const a = document.createElement('a');
a.href = url;
a.download = 'qrcode.stl';
a.click();
} catch (error) {
console.error('Failed to generate STL:', error);
}
}
// Run examples
createBasicQR();
createGradientQR();
PHP
Using cURL
Complete PHP Class
apiKey = $apiKey;
}
public function generateQR($content, $design = null, $name = null) {
$data = [
'content' => $content,
'format' => 'base64'
];
if ($name !== null) {
$data['name'] = $name;
}
if ($design !== null) {
$data['design'] = $design;
}
$ch = curl_init($this->baseUrl . '/generate');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-API-Key: ' . $this->apiKey,
'Content-Type: application/json'
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode !== 200) {
$error = json_decode($response, true);
throw new Exception($error['error'] ?? 'API request failed');
}
$result = json_decode($response, true);
if (!$result['success']) {
throw new Exception($result['error'] ?? 'Unknown error');
}
return $result;
}
public function saveQRImage($imageData, $filename) {
// Remove data URI prefix
$parts = explode(',', $imageData);
$imageData = $parts[1];
$imageBytes = base64_decode($imageData);
return file_put_contents($filename, $imageBytes);
}
}
// Usage
try {
$client = new SmarterQRClient('YOUR_API_KEY');
// Generate basic QR code
$result = $client->generateQR(
'https://example.com',
null,
'Website QR'
);
echo "Generated QR Code ID: " . $result['qr_id'] . "\n";
$client->saveQRImage($result['image'], 'qrcode.png');
// Generate gradient QR code
$gradientDesign = [
'color_mode' => 'gradient',
'gradient_color1' => '#667eea',
'gradient_color2' => '#764ba2',
'gradient_direction' => 'diagonal',
'body_style' => 'rounded',
'error_correction' => 'H'
];
$result = $client->generateQR(
'https://example.com',
$gradientDesign,
'Gradient QR'
);
$client->saveQRImage($result['image'], 'gradient_qr.png');
echo "QR codes generated successfully!\n";
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
?>
Ruby
Using net/http
Ruby Class Implementation
require 'net/http'
require 'json'
require 'base64'
class SmarterQRClient
def initialize(api_key)
@api_key = api_key
@base_url = 'https://smarterqrcodes.com/api/v1'
end
def generate_qr(content, design: nil, name: nil)
uri = URI("#{@base_url}/generate")
data = {
content: content,
format: 'base64'
}
data[:name] = name if name
data[:design] = design if design
request = Net::HTTP::Post.new(uri)
request['X-API-Key'] = @api_key
request['Content-Type'] = 'application/json'
request.body = data.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
result = JSON.parse(response.body)
unless response.code == '200' && result['success']
raise "API Error: #{result['error'] || 'Unknown error'}"
end
result
end
def save_qr_image(image_data, filename)
# Remove data URI prefix
image_data = image_data.split(',')[1]
image_bytes = Base64.decode64(image_data)
File.open(filename, 'wb') do |file|
file.write(image_bytes)
end
end
end
# Usage
begin
client = SmarterQRClient.new('YOUR_API_KEY')
# Generate basic QR code
result = client.generate_qr(
'https://example.com',
name: 'Website QR'
)
puts "Generated QR Code ID: #{result['qr_id']}"
client.save_qr_image(result['image'], 'qrcode.png')
# Generate gradient QR code
gradient_design = {
color_mode: 'gradient',
gradient_color1: '#667eea',
gradient_color2: '#764ba2',
gradient_direction: 'diagonal',
body_style: 'circle',
error_correction: 'H'
}
result = client.generate_qr(
'https://example.com',
design: gradient_design,
name: 'Gradient QR'
)
client.save_qr_image(result['image'], 'gradient_qr.png')
puts 'QR codes generated successfully!'
rescue => e
puts "Error: #{e.message}"
end
Best Practices
Security
- Store API keys as environment variables
- Never commit API keys to version control
- Use HTTPS for all API requests
- Rotate API keys periodically
- Implement server-side API calls only
Performance
- Cache generated QR codes when possible
- Use appropriate error correction levels
- Batch requests when generating multiple QR codes
- Monitor rate limit headers
- Implement exponential backoff on errors
Scannability
- Use high contrast between foreground/background
- Minimum size: 2cm x 2cm for printed QR codes
- Test with multiple QR scanners
- Use higher error correction for outdoor use
- Avoid very light colors on light backgrounds
Error Handling
- Always check response status codes
- Implement retry logic for 5xx errors
- Log API errors for debugging
- Handle rate limit errors gracefully
- Validate input data before API calls
Optimization Tips
- Caching: Cache QR codes with unique content identifiers to avoid regeneration
- Compression: Use appropriate image formats - PNG for web, STL for 3D printing
- Lazy Loading: Generate QR codes on-demand rather than pre-generating
- Monitoring: Track usage patterns to optimize rate limits
SDKs & Libraries
Official SDKs Coming Soon
We're developing official SDKs for popular languages. In the meantime, use the code examples above or the REST API directly.
Planned SDKs
Python SDK
Coming Q2 2026
Node.js SDK
Coming Q2 2026
PHP SDK
Coming Q3 2026
Community Contributions
Built a wrapper library? Let us know and we'll feature it here!
Need Help?
Our team is here to help you integrate the API successfully.