API
Generate QR codes programmatically using our REST API. Send a POST request and receive a JPG image. Use it in your own projects and applications.
Base URL
http://localhost:3000/api/qr
Send a POST request with JSON body to generate a QR code. Returns a PNG image.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| type | string | Required | QR code type |
| data | object | Required | Type-specific data fields |
| design | object | Optional | Design customization options |
QR Types and Data Fields
website
Encodes a website URL
data fields
{
"url": "https://example.com"
}business-card
Creates a vCard 3.0 QR code
data fields
{
"firstName": "John",
"lastName": "Doe",
"phone": "+15551234567",
"email": "john@example.com",
"company": "Acme Corp",
"title": "Software Engineer",
"website": "https://example.com"
}text
Encodes any text content
data fields
{
"text": "Hello World"
}wifi
WiFi network credentials
data fields
{
"ssid": "MyNetwork",
"password": "MyPassword",
"encryption": "WPA"
}Links to a PDF document
data fields
{
"url": "https://example.com/document.pdf"
}Design Options
| Field | Type | Default | Description |
|---|---|---|---|
| foregroundColor | string | #000000 | QR code color (hex) |
| backgroundColor | string | #ffffff | Background color (hex) |
| size | number | 512 | Image size in pixels (128-1024) |
| errorCorrection | string | M | L (7%), M (15%), Q (25%), H (30%) |
Code Examples
cURL
curl -X POST http://localhost:3000/api/qr \
-H "Content-Type: application/json" \
-d '{
"type": "website",
"data": {
"url": "https://example.com"
},
"design": {
"foregroundColor": "#000000",
"backgroundColor": "#ffffff",
"size": 512,
"errorCorrection": "M"
}
}' \
--output qr-code.pngResponse
200 OK - Image/png
Returns the QR code as a PNG image file
400 Bad Request - JSON
Returns error message when request is invalid
500 Internal Server Error - JSON
Returns error message when generation fails