Generate a QR code with custom content, size, colors, and error correction level.
| Parameter | Type | Description | Required |
|---|---|---|---|
| content | string | The content to encode in the QR code. Can be text, URL, or formatted data (vCard, WiFi, etc.) | Yes |
| size | integer | Size of the QR code in pixels (100-1000) | No (default: 300) |
| margin | integer | White space margin around the QR code (0-50) | No (default: 25) |
| foregroundColor | string | Hex color code for QR code foreground (#000000-#FFFFFF) | No (default: #000000) |
| backgroundColor | string | Hex color code for QR code background (#000000-#FFFFFF) | No (default: #FFFFFF) |
| errorCorrection | string | Error correction level (L, M, Q, H) | No (default: M) |
7% Recovery
15% Recovery
25% Recovery
30% Recovery
curl -X POST https://qr.nifty.app/api/generate \
-H "Content-Type: application/json" \
-d '{
"content": "https://example.com",
"size": 300,
"margin": 25,
"foregroundColor": "#000000",
"backgroundColor": "#FFFFFF",
"errorCorrection": "M"
}'
L - Low (7% recovery)M - Medium (15% recovery)Q - Quartile (25% recovery)H - High (30% recovery){
"success": true,
"image": "string" // Base64 encoded PNG image with data URI scheme
}
{
"success": true,
"image": "data:image/png;base64,..." // Base64 encoded image with data URI
}
{
"error": "Error message description"
}
$ch = curl_init('https://qr.nifty.app/api/generate');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'content' => 'https://example.com'
])
]);
$response = curl_exec($ch);
$result = json_decode($response, true);
if ($result['success']) {
$qrCode = $result['image']; // Base64 encoded image
}
$data = [
'content' => 'WIFI:T:WPA;S:NetworkName;P:Password;;'
];
$ch = curl_init('https://qr.nifty.app/api/generate');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode($data)
]);
$response = curl_exec($ch);
$result = json_decode($response, true);
$vcard = implode("\n", [
'BEGIN:VCARD',
'VERSION:3.0',
'FN:John Doe',
'TEL:+1234567890',
'EMAIL:john@example.com',
'END:VCARD'
]);
$data = ['content' => $vcard];
$ch = curl_init('https://qr.nifty.app/api/generate');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode($data)
]);
$response = curl_exec($ch);
$result = json_decode($response, true);
$data = [
'content' => 'https://example.com',
'size' => 400,
'margin' => 25,
'foregroundColor' => '#0984e3',
'backgroundColor' => '#f5f7fa',
'errorCorrection' => 'H'
];
$ch = curl_init('https://qr.nifty.app/api/generate');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode($data)
]);
$response = curl_exec($ch);
$result = json_decode($response, true);
if ($result['success']) {
// Save as file
$imageData = base64_decode(explode(',', $result['image'])[1]);
file_put_contents('qrcode.png', $imageData);
}