Overview
Simple server-side API for generating QR codes. Returns PNG images with built-in caching for fast responses.
Endpoint
Base URL:
api.php
Method:
GET
Parameters:
url(required) - The URL or text to encode in the QR codesize(optional) - Image size in pixels, 100-2000 (default:300)fg(optional) - Foreground color in hex format, e.g.#000000(default:#000000)
Usage Examples
Basic Request:
GET api.php?url=https://example.com
With Custom Size:
GET api.php?url=https://example.com&size=500
With Foreground Color:
GET api.php?url=https://example.com&fg=%23FF0000
Full Example (All Options):
GET api.php?url=https://example.com&size=500&fg=%23FF0000
cURL Example:
curl "https://qr.kyd.net/api.php?url=https://example.com&size=500&fg=%23FF0000" -o qrcode.png
HTML Image Tag:
<img src="api.php?url=https://example.com&size=500&fg=%23FF0000" alt="QR Code">
Response
Success (200 OK):
- Content-Type:
image/png - Body: PNG image binary data
- Cache-Control:
public, max-age=31536000
Error (400 Bad Request):
{
"error": "Missing URL parameter"
}
Caching
QR codes are automatically cached in qr-cache.json using MD5 hash of the URL as the cache key.
Subsequent requests for the same URL are served instantly from cache.
Cache Structure:
{ "md5_hash": { "data": "base64_image", "mime": "image/png", "timestamp": unix_time, "url": "original_url" } }
Test API
Examples
Default
api.php?url=https://qr.kyd.net
Custom Color
api.php?url=...&fg=%2358a6ff
Large Size
api.php?url=...&size=200
Size + Color
api.php?url=...&size=200&fg=%23FF0000
Notes
- Maximum URL/text length: 2000 characters
- Images are returned in PNG format
- Size range: 100-2000 pixels (default: 300)
- Foreground color must be in hex format:
#RRGGBB(e.g.,#FF0000for red) - Background is always white
- Cache is stored server-side in JSON format
- First request generates and caches, subsequent requests use cache
- Works with any text or URL (not just HTTP URLs)