Home API Tools Posts Hire Me About
Sign In Create Account
Live Free tier included

Generate QR Codes via API

Create custom QR codes in SVG or PNG format with full control over colors, size, error correction levels, and margin. Embed the result directly in your app.

SVG & PNG Custom Colors Up to 1000px No API Key Error Correction

Try it Free

Configure your QR code and generate it instantly. No signup required.

Try Free
Result

Configure options and click Generate

API Documentation

Everything you need to integrate the QR Code Generator API into your application. Generate customizable QR codes in SVG or PNG format with full control over colors, size, and error correction.

Endpoint

POST https://www.mahmoudalhabash.com/api/v1/qr-code

Send a JSON body with your content and configuration options. The API returns a base64-encoded image you can embed directly in HTML or save to disk.

Request Parameters

ParameterTypeRequiredDefaultDescription
content string required The text, URL, or data to encode into the QR code
size integer optional 300 Output image size in pixels (50–1000)
format string optional svg Image format: svg or png
color string optional #000000 Foreground color as hex code
bg_color string optional #ffffff Background color as hex code
error_correction string optional M Error correction level: L (7%), M (15%), Q (25%), H (30%)
margin integer optional 1 Quiet zone margin around the code (0–10)

Response Fields

status Either "success" or "error"
format The output format used (svg or png)
size The output size in pixels
image Base64-encoded data URI — embed directly in <img src="...">
error Error message (only present when status is "error")

Code Examples

cURL
curl -X POST https://www.mahmoudalhabash.com/api/v1/qr-code \ -H "Content-Type: application/json" \ -d '{ "content": "https://example.com", "size": 300, "format": "svg", "color": "#000000", "bg_color": "#ffffff" }'
Response 200 JSON
{ "status": "success", "format": "svg", "size": 300, "image": "data:image/svg+xml;base64,PHN2Zy..." }
JavaScript (fetch)
const res = await fetch('https://www.mahmoudalhabash.com/api/v1/qr-code', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ content: 'https://example.com', size: 400, format: 'png', color: '#6366f1' }) }); const data = await res.json(); document.getElementById('qr').src = data.image;
Python (requests)
import requests, base64 resp = requests.post( 'https://www.mahmoudalhabash.com/api/v1/qr-code', json={ 'content': 'https://example.com', 'size': 400, 'format': 'png' } ) data = resp.json() # Save to file img_data = data['image'].split(',')[1] with open('qr.png', 'wb') as f: f.write(base64.b64decode(img_data))

Error Codes

422 Validation failed — missing or invalid parameters
400 Bad request — malformed JSON body
429 Rate limit exceeded — too many requests
500 Internal server error — QR generation failed

Rate Limits

Unlimited — Free during beta

No API key required. Rate limits may be introduced in the future to ensure fair usage.