QR Code Generator API
Generate QR codes in SVG, PNG, or Base64 data URL format. Customize size, colors, margin, and error correction level. Supports encoding up to 4000 characters of text, URLs, or structured data.
/api/v1/qr/generateTry it out
/api/v1/qr/generateParameters
Code
curl -X GET "https://khaleejiapi.dev/api/v1/qr/generate?data=https%3A%2F%2Fkhaleejiapi.dev&format=svg&size=256&margin=4&dark=%23000000&light=%23ffffff&ecLevel=M" \ -H "Authorization: Bearer your_api_key"Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| data | string | Required | Content to encode in the QR code (max 4000 characters) |
| format | string | Optional | Output format: svg, png, or dataurl |
| size | number | Optional | Image size in pixels (64–2048) |
| margin | number | Optional | Quiet zone margin |
| dark | string | Optional | Dark module color (hex) |
| light | string | Optional | Light module color (hex) |
| ecLevel | string | Optional | Error correction level: L, M, Q, H |
Output Formats
svg (default)
Returns SVG XML with Content-Type: image/svg+xml. Scalable, perfect for web. 24-hour cache.
png
Returns PNG binary with Content-Type: image/png. Fixed resolution based on size parameter. 24-hour cache.
dataurl
Returns JSON with Base64-encoded PNG data URL. Ideal for embedding in HTML or apps without additional requests.
Error Correction Levels
| Level | Recovery | Use Case |
|---|---|---|
| L | ~7% | Smallest QR code, clean environments |
| M | ~15% | Default, good balance |
| Q | ~25% | Higher durability |
| H | ~30% | Maximum recovery, logo overlay |
Rate Limits
| Plan | Requests/Month | Rate Limit |
|---|---|---|
| Free | 1,000 | 10 req/min |
| Starter | 10,000 | 60 req/min |
| Professional | 100,000 | 300 req/min |
| Business | 500,000 | 1,000 req/min |
Debugging & Support
Include X-Request-ID when contacting support
Every response from KhaleejiAPI includes an X-Request-ID header — a unique identifier that lets our support team pull the exact log entry for your request within seconds. Always share it when reporting an unexpected error or unexpected result.
How to capture it
JavaScript / fetch
const res = await fetch("https://khaleejiapi.dev/api/v1/...", {
headers: { Authorization: "******" },
});
const requestId = res.headers.get("x-request-id");
console.log("Request ID:", requestId);
// → e.g. "req_01j9xkz4vp8..."cURL
curl -si "https://khaleejiapi.dev/api/v1/..." \ -H "Authorization: ******" | grep -i x-request-id # → x-request-id: req_01j9xkz4vp8...
Browser DevTools
Open DevTools (F12) → Network tab → click the failing request → scroll to the Response Headers section → copy the value next to x-request-id.
For a full list of error codes and guidance on common issues, see the Troubleshooting guide.