
QR Code Generator API
Marketing
Create custom QR codes instantly from URLs, text, or contact info. Download as PNG with full customization of size and colors.
Authentication
All API requests require a valid API key passed in the Authorization header as a Bearer token.
Rate Limit
20 requests per minute
Endpoints
2 endpoints available
Overview
Turn text or a URL into a QR code. You get the image back directly as PNG or SVG, or as JSON holding a PNG data URL.
Output formats
png(default): the response body is the PNG file (Content-Type: image/png).svg: the response body is the SVG file (Content-Type: image/svg+xml).base64: a JSON response with the PNG as a data URL inimage.
Notes
datacan be up to 4000 characters. Text is encoded as UTF-8. If it does not fit at the chosenerrorCorrectionlevel the API returns 413; shorten it or use a lower level (L holds the most).sizeis the image width and height in pixels, 50 to 2000.marginis the blank border in modules (QR squares), 0 to 20. Keep at least 4 for reliable scanning.- Colours are hex only (
#000or#000000). Keep strong contrast, dark on light. POST /v1/tools/qr-code-generator/wifibuilds a Wi-Fi sign-in code from a network name and password, so phones offer to join the network when they scan it. It takes the same size, colour, format, errorCorrection and margin options.
Endpoints
POST
https://opentools.ca/api/v1/tools/qr-code-generatorGenerate a QR code for text or a URL
Request Body
Content-Type: application/json
| Parameter | Type | Required | Description |
|---|---|---|---|
| data | string | Required | The text or URL to encode, 1 to 4000 characters. |
| size | number | Optional | Width and height in pixels, 50 to 2000.Default: 256 |
| foregroundColor | string | Optional | Colour of the dark squares, as hex.Default: #000000 |
| backgroundColor | string | Optional | Background colour, as hex.Default: #FFFFFF |
| format | string Enum: png, svg, base64 | Optional | png and svg return the image file; base64 returns JSON with a PNG data URL.Default: png |
| errorCorrection | string Enum: L, M, Q, H | Optional | Error correction level. Higher levels survive more damage but hold less data.Default: H |
| margin | number | Optional | Blank border around the code, in modules, 0 to 20.Default: 4 |
Response Example
With format "png" or "svg" the body is the image file itself. With format "base64":
{
"success": true,
"type": "text",
"data": "https://example.com",
"size": 256,
"format": "base64",
"mimeType": "image/png",
"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
}Error Codes
400
Bad Request - Missing data, invalid colour, or out-of-range option401
Unauthorized - Invalid or missing API key403
Forbidden - API key inactive, expired, or request from a disallowed IP413
Payload Too Large - The data does not fit in a QR code at this error correction level429
Too Many Requests - Rate limit exceeded500
Internal Server ErrorPOST
https://opentools.ca/api/v1/tools/qr-code-generator/wifiGenerate a Wi-Fi sign-in QR code
Request Body
Content-Type: application/json
| Parameter | Type | Required | Description |
|---|---|---|---|
| ssid | string | Required | Network name, 1 to 32 characters. |
| password | string | Optional | Network password, up to 63 characters. Leave out for an open network. |
| encryption | string Enum: WPA, WEP, nopass | Optional | Security type. Use nopass for an open network.Default: WPA |
| hidden | boolean | Optional | Set to true if the network does not broadcast its name.Default: false |
| size | number | Optional | Width and height in pixels, 50 to 2000.Default: 256 |
| foregroundColor | string | Optional | Colour of the dark squares, as hex.Default: #000000 |
| backgroundColor | string | Optional | Background colour, as hex.Default: #FFFFFF |
| format | string Enum: png, svg, base64 | Optional | png and svg return the image file; base64 returns JSON with a PNG data URL.Default: png |
| errorCorrection | string Enum: L, M, Q, H | Optional | Error correction level.Default: H |
| margin | number | Optional | Blank border around the code, in modules, 0 to 20.Default: 4 |
Response Example
With format "png" or "svg" the body is the image file itself. With format "base64":
{
"success": true,
"type": "wifi",
"data": "WIFI:T:WPA;S:MyNetwork;P:MyPassword;;",
"size": 256,
"format": "base64",
"mimeType": "image/png",
"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
}Error Codes
400
Bad Request - Missing ssid, invalid colour, or out-of-range option401
Unauthorized - Invalid or missing API key403
Forbidden - API key inactive, expired, or request from a disallowed IP429
Too Many Requests - Rate limit exceeded500
Internal Server ErrorCode Examples
# Save a PNG
curl -X POST https://opentools.ca/api/v1/tools/qr-code-generator \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"data": "https://example.com", "size": 512, "foregroundColor": "#1a1a1a"}' \
-o qrcode.png
# Wi-Fi code as SVG
curl -X POST https://opentools.ca/api/v1/tools/qr-code-generator/wifi \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"ssid": "MyNetwork", "password": "MyPassword", "format": "svg"}' \
-o wifi.svgRather use it in your browser? Open the QR Code Generator