QR Code API Documentation
Welcome to the QR Code API documentation. This API allows you to generate QR codes with various data types and customization options.
The API supports multiple data formats including text, URLs, bank transfers, email addresses, SMS messages, vCards, WiFi network information, and custom data structures.
You can also customize the appearance of the QR codes with options for colors, size, error correction level, and more.
Getting Started
To use the QR Code API, you need to make HTTP requests to the API endpoints. The API supports both GET and POST methods.
Basic Usage
The simplest way to generate a QR code is to make a GET request to the /encode endpoint with the required parameters:
Authentication
The API does not require authentication for basic usage.
API Endpoints
Generate QR Code
Endpoint: /encode/{dataType}
Methods: GET, POST
This endpoint generates a QR code based on the provided data and options.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
| dataType | string | The type of data to encode. Valid values: text, url, bank, email, sms, vcard, wifi, custom |
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| data | object | Yes | The data to encode. The structure depends on the dataType. |
| options | object | No | Options for customizing the QR code. |
Response
The response will be the generated QR code in the requested format. If the Accept header is set to application/json, the response will be a JSON object containing the QR code as a base64-encoded string.
Data Types
The QR Code API supports various data types that can be encoded in QR codes. Each data type has its own structure and requirements.
Text
The text data type allows you to encode plain text in a QR code.
Data Structure
| Field | Type | Required | Description |
|---|---|---|---|
| text | string | Yes | The text to encode in the QR code. |
Example
URL
The URL data type allows you to encode a web address in a QR code.
Data Structure
| Field | Type | Required | Description |
|---|---|---|---|
| url | string | Yes | The URL to encode in the QR code. |
Example
Bank Transfer
The bank data type allows you to encode bank transfer information in a QR code.
Data Structure
| Field | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Recipient's name |
| iban | string | Yes | IBAN (International Bank Account Number) |
| currency | string | Yes | Currency code (e.g., EUR, USD) |
| amount | string | Yes | Transfer amount |
| description | string | Yes | Payment description/reference |
Example
The email data type allows you to encode an email address in a QR code.
Data Structure
| Field | Type | Required | Description |
|---|---|---|---|
| string | Yes | Email address | |
| subject | string | No | Email subject |
| body | string | No | Email body |
Example
SMS
The SMS data type allows you to encode a text message in a QR code.
Data Structure
| Field | Type | Required | Description |
|---|---|---|---|
| phone | string | Yes | Phone number |
| message | string | No | SMS message |
Example
vCard
The vCard data type allows you to encode contact information in a QR code.
Data Structure
| Field | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Full name |
| company | string | No | Company name |
| title | string | No | Job title |
| phone | string | No | Phone number |
| string | No | Email address | |
| address | string | No | Physical address |
| website | string | No | Website URL |
Example
WiFi
The WiFi data type allows you to encode WiFi network information in a QR code.
Data Structure
| Field | Type | Required | Description |
|---|---|---|---|
| ssid | string | Yes | Network name (SSID) |
| password | string | No | Network password |
| encryption | string | No | Encryption type (WEP, WPA, WPA2, none) |
| hidden | boolean | No | Whether the network is hidden |
Example
Custom
The custom data type allows you to encode any custom data in a QR code.
Data Structure
The structure is flexible and depends on your specific needs.
Example
Output Formats
The QR Code API supports various output formats for the generated QR codes.
Available Formats
| Format | Description |
|---|---|
| png | PNG image format (default) |
| jpg, jpeg | JPEG image format |
| gif | GIF image format |
| bmp | BMP image format |
| webp | WebP image format |
| svg | SVG vector format |
| eps | EPS vector format |
| PDF document format | |
| txt | Text representation |
| html | HTML representation |
| json | JSON representation |
Specifying the Output Format
You can specify the output format using the output parameter in the request:
Alternatively, you can use the Accept header in the request:
Accept: image/svg+xml
QR Code Options
The QR Code API provides various options for customizing the appearance and behavior of the generated QR codes.
Output Options
| Option | Type | Default | Description |
|---|---|---|---|
| output | string | png | Output format (png, jpg, gif, bmp, webp, svg, eps, pdf, txt, html, json) |
| outputBase64 | boolean | false | Whether to return the QR code as a base64-encoded string |
| quality | integer | -1 | Image quality for JPEG format (0-100) |
| gdImageUseUpscale | boolean | true | Whether to use upscaling for GD image output |
| imagickFormat | string | png32 | ImageMagick format for image output |
Error Correction Options
| Option | Type | Default | Description |
|---|---|---|---|
| eccLevel | string | M | Error correction level (L: 7%, M: 15%, Q: 25%, H: 30%) |
| version | integer | -1 | QR code version (1-40, -1 for auto) |
| versionMin | integer | 1 | Minimum QR code version |
| versionMax | integer | 40 | Maximum QR code version |
| maskPattern | integer | -1 | Mask pattern (0-7, -1 for auto) |
Geometry Options
| Option | Type | Default | Description |
|---|---|---|---|
| scale | integer | 4 | Scale factor for the QR code |
| quietZone | integer | 4 | Size of the quiet zone around the QR code |
| circleRadius | float | 0 | Radius for circular modules (0 for square modules) |
| keepAsSquare | array | [] | Module types to keep as squares when using circular modules |
Color Options
| Option | Type | Default | Description |
|---|---|---|---|
| colors.color | string | #000 | Default color for dark modules |
| colors.background | string | #fff | Background color |
| invertMatrix | boolean | false | Whether to invert the QR code colors |
| transparencyColor | string | Color to make transparent in the output image |
You can also specify colors for specific module types:
colors.finder: Finder pattern (the three large squares in the corners)colors.finderDot: Finder pattern dotscolors.alignment: Alignment patterncolors.timing: Timing patterncolors.format: Format informationcolors.version: Version informationcolors.data: Data modulescolors.darkModule: Dark modulecolors.quietZone: Quiet zonecolors.logoSpace: Logo space
Vector Options
| Option | Type | Default | Description |
|---|---|---|---|
| connectPaths | boolean | false | Whether to connect paths in vector output |
| excludeFromConnect | array | [] | Module types to exclude from path connection |
| cssClass | string | qrcode | CSS class for SVG output |
| svgAddXmlHeader | boolean | true | Whether to add XML header to SVG output |
| svgDefs | string | SVG definitions to include in the output | |
| svgPreserveAspectRatio | string | xMidYMid | SVG preserveAspectRatio attribute |
| svgUseFillAttributes | boolean | true | Whether to use fill attributes in SVG output |
Logo Options
| Option | Type | Default | Description |
|---|---|---|---|
| logoData | string | Base64-encoded logo image data | |
| addLogoSpace | boolean | false | Whether to add space for a logo |
| logoSpaceWidth | integer | Width of the logo space | |
| logoSpaceHeight | integer | Height of the logo space | |
| logoSpaceStartX | integer | X coordinate of the logo space | |
| logoSpaceStartY | integer | Y coordinate of the logo space |