@lazymac/qr-code-api
v1.0.0
Published
QR Code generation REST API and MCP server. Supports text, URLs, vCards, WiFi configs, email, phone, custom colors/sizes.
Maintainers
Readme
QR Code API
QR code generation REST API and MCP server. Generate QR codes from text, URLs, vCards, WiFi configs, email, and phone numbers. Returns PNG, SVG, or base64. No external APIs required.
Quick Start
npm install
npm start
# Server runs on http://localhost:3700Endpoints
| Method | Path | Description |
|--------|------|-------------|
| GET | /api/v1/generate?data=... | Generate QR from query params |
| GET | /api/v1/generate/base64?data=... | Return base64 data URL as JSON |
| POST | /api/v1/generate | Generate QR with full options |
| POST | /api/v1/vcard | Generate QR from vCard fields |
| POST | /api/v1/wifi | Generate QR from WiFi credentials |
| GET | /api/v1/health | Health check |
Examples
Simple text/URL QR
# PNG image (default)
curl "http://localhost:3700/api/v1/generate?data=https://example.com" -o qr.png
# SVG
curl "http://localhost:3700/api/v1/generate?data=hello&format=svg" -o qr.svg
# Custom colors and size
curl "http://localhost:3700/api/v1/generate?data=hello&size=500&darkColor=%23ff0000&lightColor=%23ffffff" -o qr.png
# Base64
curl "http://localhost:3700/api/v1/generate/base64?data=hello"vCard
curl -X POST http://localhost:3700/api/v1/vcard \
-H "Content-Type: application/json" \
-d '{"firstName":"John","lastName":"Doe","phone":"+1234567890","email":"[email protected]","org":"Acme"}' \
-o vcard.pngWiFi
curl -X POST http://localhost:3700/api/v1/wifi \
-H "Content-Type: application/json" \
-d '{"ssid":"MyNetwork","password":"secret123","encryption":"WPA"}' \
-o wifi.pngEmail / Phone (via POST /generate)
# Email
curl -X POST http://localhost:3700/api/v1/generate \
-H "Content-Type: application/json" \
-d '{"type":"email","to":"[email protected]","subject":"Hi","data":"_"}' \
-o email.png
# Phone
curl -X POST http://localhost:3700/api/v1/generate \
-H "Content-Type: application/json" \
-d '{"type":"phone","number":"+1234567890","data":"_"}' \
-o phone.pngQuery Parameters / Body Options
| Parameter | Description | Default |
|-----------|-------------|---------|
| data | Text/URL to encode | required |
| format | png, svg, base64 | png |
| size | Image width in px (50-2000) | 300 |
| errorCorrectionLevel | L, M, Q, H | M |
| darkColor | Hex color for dark modules | #000000 |
| lightColor | Hex color for light modules | #ffffff |
| margin | Quiet zone modules | 2 |
MCP Server
Use as a Model Context Protocol tool server:
node src/mcp-server.jsClaude Desktop config
{
"mcpServers": {
"qr-code": {
"command": "node",
"args": ["/path/to/qr-code-api/src/mcp-server.js"]
}
}
}MCP Tools
generate_qr— Text/URL to QRgenerate_vcard_qr— vCard contact QRgenerate_wifi_qr— WiFi credentials QRgenerate_email_qr— Email mailto QRgenerate_phone_qr— Phone number QR
Docker
docker build -t qr-code-api .
docker run -p 3700:3700 qr-code-apiLicense
MIT
