API Documentation
Generate QR codes programmatically with our free REST API.
Overview
The CodePrints API lets you generate QR codes
programmatically from any language that can make HTTP requests.
Send a POST request with JSON, receive a base64-encoded image back — no API key required.
No API Key
Free & open access
JSON API
REST + JSON responses
PNG & SVG
Base64 or raw binary
Base URL
https://www.codeprints.site/api/v1
All endpoints are relative to this base URL. Always use HTTPS in production.
Rate Limits
60 requests / minute per IP address
When the limit is exceeded the API returns HTTP 429. Check these response headers:
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 42
Retry-After: 30
Error Handling
All error responses share the same JSON shape:
{
"success": false,
"message": "Human-readable error description",
"errors": {
"field_name": ["Validation error detail"]
}
}
| Code | Meaning |
|---|---|
200 | Success |
422 | Validation error — check the errors field |
429 | Rate limit exceeded |
500 | Server error |
GET
/qr/types
Returns all supported QR code types and their required / optional fields.
Request
GET https://www.codeprints.site/api/v1/qr/types
Accept: application/json
Response
{
"success": true,
"data": [
{
"type": "url",
"label": "URL / Website",
"description": "Encodes a website URL.",
"fields": [
{ "name": "url", "type": "string", "required": true, "description": "The full URL" }
]
},
// ... more types
]
}
POST
/qr/generate
Generate a QR code image. Returns it as a base64-encoded data URI.
Headers
Content-Type: application/json
Accept: application/json
X-API-Key: your_api_key_here
Don't have a key yet?
Get your free API key →
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
type | string | required | QR type: url text wifi email phone sms whatsapp vcard |
url | string | if url | Website URL |
text | string | if text | Plain text (max 2000 chars) |
ssid | string | if wifi | WiFi network name |
password | string | optional | WiFi password |
encryption | string | optional | WPA WEP none (default: WPA) |
email | string | if email | Recipient email address |
email_subject | string | optional | Email subject line |
email_body | string | optional | Email body text |
phone | string | if phone | Phone number |
sms_number | string | if sms | SMS recipient number |
sms_message | string | optional | Pre-filled SMS text |
whatsapp_number | string | if whatsapp | WhatsApp number (digits only) |
whatsapp_message | string | optional | Pre-filled message |
vcard_first_name | string | if vcard | Contact first name |
vcard_last_name | string | optional | Contact last name |
vcard_organization | string | optional | Company name |
vcard_phone | string | optional | Contact phone |
vcard_email | string | optional | Contact email |
format | string | optional | png (default) or svg |
size | integer | optional | 200 300 (default) 500 |
margin | integer | optional | 0–10 (default: 1) |
foreground_color | string | optional | Hex color e.g. #000000 |
background_color | string | optional | Hex color e.g. #ffffff |
Success Response
{
"success": true,
"data": {
"image": "data:image/png;base64,iVBORw0KGgo...", // ready for <img src="...">
"base64": "iVBORw0KGgo...", // raw base64 string
"mime_type": "image/png",
"format": "png",
"size": 300,
"payload": "https://example.com", // encoded content
"type": "url"
},
"meta": {
"generated_at": "2024-01-15T12:00:00+00:00",
"version": "v1"
}
}
Example: URL QR Code
JavaScript (fetch)
const res = await fetch('https://www.codeprints.site/api/v1/qr/generate', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', 'X-API-Key': 'your_key' },
body: JSON.stringify({
type: 'url',
url: 'https://example.com',
format: 'png',
size: 300
})
});
const data = await res.json();
document.querySelector('img').src = data.data.image;
cURL
curl -X POST https://www.codeprints.site/api/v1/qr/generate \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"type":"url","url":"https://example.com","size":300}'
Python
import requests, base64
res = requests.post('https://www.codeprints.site/api/v1/qr/generate', json={
'type': 'url',
'url': 'https://example.com',
'size': 300
})
data = res.json()['data']
with open('qrcode.png', 'wb') as f:
f.write(base64.b64decode(data['base64']))
PHP
$response = file_get_contents('https://www.codeprints.site/api/v1/qr/generate', false,
stream_context_create(['http' => [
'method' => 'POST',
'header' => "Content-Type: application/json\r\nAccept: application/json",
'content' => json_encode(['type'=>'url', 'url'=>'https://example.com'])
]])
);
$data = json_decode($response, true)['data'];
file_put_contents('qrcode.png', base64_decode($data['base64']));
Example: WiFi QR Code
{
"type": "wifi",
"ssid": "MyHomeNetwork",
"password": "secretpassword",
"encryption": "WPA",
"hidden": false,
"size": 300,
"format": "png"
}
Example: vCard QR Code
{
"type": "vcard",
"vcard_first_name": "John",
"vcard_last_name": "Doe",
"vcard_organization": "Acme Inc.",
"vcard_title": "Software Engineer",
"vcard_phone": "+1234567890",
"vcard_email": "john@acme.com",
"vcard_website": "https://acme.com",
"size": 300,
"foreground_color": "#1e293b"
}