QR Code Generator

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 in image.

Notes

  • data can be up to 4000 characters. Text is encoded as UTF-8. If it does not fit at the chosen errorCorrection level the API returns 413; shorten it or use a lower level (L holds the most).
  • size is the image width and height in pixels, 50 to 2000. margin is the blank border in modules (QR squares), 0 to 20. Keep at least 4 for reliable scanning.
  • Colours are hex only (#000 or #000000). Keep strong contrast, dark on light.
  • POST /v1/tools/qr-code-generator/wifi builds 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-generator
Generate a QR code for text or a URL

Request Body

Content-Type: application/json

ParameterTypeRequiredDescription
data
string
Required
The text or URL to encode, 1 to 4000 characters.
size
number
OptionalWidth and height in pixels, 50 to 2000.Default: 256
foregroundColor
string
OptionalColour of the dark squares, as hex.Default: #000000
backgroundColor
string
OptionalBackground colour, as hex.Default: #FFFFFF
format
string
Enum: png, svg, base64
Optionalpng and svg return the image file; base64 returns JSON with a PNG data URL.Default: png
errorCorrection
string
Enum: L, M, Q, H
OptionalError correction level. Higher levels survive more damage but hold less data.Default: H
margin
number
OptionalBlank 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 option
401
Unauthorized - Invalid or missing API key
403
Forbidden - API key inactive, expired, or request from a disallowed IP
413
Payload Too Large - The data does not fit in a QR code at this error correction level
429
Too Many Requests - Rate limit exceeded
500
Internal Server Error
POST
https://opentools.ca/api/v1/tools/qr-code-generator/wifi
Generate a Wi-Fi sign-in QR code

Request Body

Content-Type: application/json

ParameterTypeRequiredDescription
ssid
string
Required
Network name, 1 to 32 characters.
password
string
OptionalNetwork password, up to 63 characters. Leave out for an open network.
encryption
string
Enum: WPA, WEP, nopass
OptionalSecurity type. Use nopass for an open network.Default: WPA
hidden
boolean
OptionalSet to true if the network does not broadcast its name.Default: false
size
number
OptionalWidth and height in pixels, 50 to 2000.Default: 256
foregroundColor
string
OptionalColour of the dark squares, as hex.Default: #000000
backgroundColor
string
OptionalBackground colour, as hex.Default: #FFFFFF
format
string
Enum: png, svg, base64
Optionalpng and svg return the image file; base64 returns JSON with a PNG data URL.Default: png
errorCorrection
string
Enum: L, M, Q, H
OptionalError correction level.Default: H
margin
number
OptionalBlank 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 option
401
Unauthorized - Invalid or missing API key
403
Forbidden - API key inactive, expired, or request from a disallowed IP
429
Too Many Requests - Rate limit exceeded
500
Internal Server Error

Code 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.svg

Ready to get started?

Create an API key to start using the QR Code Generator API.

Rather use it in your browser? Open the QR Code Generator