QR Code and Barcode API Reference
Two endpoints for QR and barcode batches. Each call returns a ZIP and a CSV manifest.
Overview
Batch QR generation for posters, product labels and mail merges.
One request turns a list of strings into a ZIP of QR images plus a CSV manifest. The endpoint accepts application/json, a form post, or a query string; any field you omit falls back to the default listed under Request parameters.
data.qrcode_data[n].path.Endpoint
https://api-v2.qrbatch.com/qrbatchv4api/create/createAPI.php
Base host: api-v2.qrbatch.com. HTTPS only. CORS is open (Access-Control-Allow-Origin: *), so browser-side calls work, but never ship a token inside client-side code.
create/create_svg.php with the same payload. Batches of 100 or more return 202 with a job_id; poll create/create_status.php?job_id=… until it answers code: 0.Authentication
Body token, no header plumbing.
Every request may carry a token — the auth code shown in your account. Signed-in calls draw from your plan quota; calls without a token draw from the anonymous per-IP allowance.
{{ token ? token : 'No token attached — anonymous quota applies' }}
Clicking fills your live token into every example on this page. The token is read from your signed-in session in this browser — it is never sent to us by this page.
Where the token lives
- Send it in the request body as
"token": "…". There is noAuthorizationheader handling. - An invalid or expired token answers
302; treat it as "signed out" and re-authenticate rather than retrying. - Rotating your password invalidates previously issued tokens.
Quotas & limits
Quota is counted per generated item, not per request. The allowance resets at 00:00 server time.
| Caller | Daily allowance | Per-request cap | Rejection |
|---|---|---|---|
| Anonymous (no token) | 50 codes per IP address | 50 | 301 |
| Signed in | Your plan’s daily volume | Your plan’s batch size | 303 |
| Add-on packs | Added on top of the plan allowance | — | — |
addon and remaining only ever include credits that are still valid. The 303 response also returns addon_expire, a Unix timestamp of the earliest expiry among your valid credits (0 when the balance has no expiry or is empty).Request parameters
Grouped by object. Only contents is strictly required.
Top level
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
contents |
array | string | required | — | QR payloads, one per image. A plain string is split on newlines; empty lines are dropped. |
data |
array | string | optional | — | Alias of contents, honoured only when contents is empty or missing. |
token |
string | optional | "" | Account auth code. Empty means the anonymous per-IP allowance. |
file_name_type |
int | optional | 1 | 1 = sequential index (1, 2, …), 2 = sanitized content, 3 = the matching entry from names. |
labels |
array | string | optional | [] | Caption printed under each code when label_setting.use_content is 0. Length must equal contents, otherwise 302. |
names |
array | string | optional | [] | File names used when file_name_type is 3. |
color |
object | optional | see below | Module, background and caption colours. |
base |
object | optional | see below | Size, DPI and image format. |
logo |
object | optional | see below | Centre logo overlay. |
label_setting |
object | optional | see below | Caption typography and placement. |
base — geometry & format
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
size |
int | optional | 200 | Image side length in pixels. |
margin |
int | optional | 10 | Quiet-zone padding in pixels. Keep at least 4 modules of white space for reliable scanning. |
dpi |
int | optional | 96 | Written into the PNG metadata; use 300 for print. |
img_type |
int | optional | 1 | 1 = PNG, 2 = JPEG. |
transparent |
bool | optional | false | Transparent background (PNG only). |
fault |
string | optional | Medium-High | Error correction: Low, Medium-Low, Medium-High, High. Raise it when a logo covers the centre. |
color
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
front_color |
string | optional | "0,0,0" | QR module colour, as an R,G,B triplet. |
bg_color |
string | optional | "255,255,255" | Background colour, as an R,G,B triplet. |
font_color |
string | optional | "0,0,0" | Caption text colour, as an R,G,B triplet. |
logo
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
size |
int | optional | 2 | Logo width as a fraction of the code width — 2 means 20%. |
file |
string | optional | "" | Path or URL of the logo image on the server. |
label_setting
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
show_label |
int | optional | 0 | 1 prints a caption band under the code; 0 leaves it bare. |
use_content |
int | optional | 1 | 1 = caption repeats the QR content, 0 = caption comes from labels[]. |
font_size |
int | optional | 15 | Caption font size in pixels. |
margin |
int | optional | 10 | Gap in pixels between the code and the caption. |
location |
string | optional | bottom | bottom or top. |
font_type |
int | optional | 1 | Accepted for compatibility with the web app; the API path always uses the bundled font. |
line_type |
int | optional | 1 | Accepted for compatibility with the web app; it does not alter API output. |
color are RGB triplets such as "0,0,0", not hex. Hex values belong to the web-app payload, which is a different schema.Code examples
The same call in six flavours.
Replace YOUR_TOKEN with your auth code, or press Get my token above to fill every example at once.
Payload
{
"contents": ["https://example.com/p/1001", "https://example.com/p/1002"],
"file_name_type": 1,
"base": {
"size": 600,
"margin": 12,
"dpi": 300,
"img_type": 1,
"fault": "Medium-High"
},
"color": {
"front_color": "0,0,0",
"bg_color": "255,255,255",
"font_color": "0,0,0"
},
"label_setting": {
"show_label": 0,
"use_content": 1,
"font_size": 15,
"margin": 10,
"location": "bottom"
},
"token": "YOUR_TOKEN"
}
Same request, five languages
curl -X POST "https://api-v2.qrbatch.com/qrbatchv4api/create/createAPI.php" \
-H "Content-Type: application/json" \
-d '{
"contents": ["https://example.com/p/1001", "https://example.com/p/1002"],
"file_name_type": 1,
"base": { "size": 600, "margin": 12, "dpi": 300 },
"token": "YOUR_TOKEN"
}'
const res = await fetch('https://api-v2.qrbatch.com/qrbatchv4api/create/createAPI.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
contents: ['https://example.com/p/1001', 'https://example.com/p/1002'],
file_name_type: 1,
base: { size: 600, margin: 12, dpi: 300 },
token: 'YOUR_TOKEN'
})
});
const { code, message, data } = await res.json();
if (code !== 0) throw new Error(message);
console.log(data.num, 'codes', data.zip_path);
import requests
res = requests.post(
"https://api-v2.qrbatch.com/qrbatchv4api/create/createAPI.php",
json={
"contents": ["https://example.com/p/1001", "https://example.com/p/1002"],
"file_name_type": 1,
"base": {"size": 600, "margin": 12, "dpi": 300},
"token": "YOUR_TOKEN",
},
timeout=120,
)
payload = res.json()
if payload.get("code") != 0:
raise RuntimeError(payload.get("message"))
for item in payload["data"]["qrcode_data"].values():
print(item["file_name"], item["path"])
<?php
$payload = [
"contents" => ["https://example.com/p/1001", "https://example.com/p/1002"],
"file_name_type" => 1,
"base" => ["size" => 600, "margin" => 12, "dpi" => 300],
"token" => "YOUR_TOKEN",
];
$ch = curl_init("https://api-v2.qrbatch.com/qrbatchv4api/create/createAPI.php");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 120,
]);
$res = json_decode(curl_exec($ch), true);
curl_close($ch);
echo $res["code"] === 0 ? $res["data"]["zip_path"] : $res["message"];
const axios = require('axios');
axios.post('https://api-v2.qrbatch.com/qrbatchv4api/create/createAPI.php', {
contents: ['https://example.com/p/1001', 'https://example.com/p/1002'],
file_name_type: 1,
base: { size: 600, margin: 12, dpi: 300 },
token: 'YOUR_TOKEN'
}).then(({ data }) => {
if (data.code !== 0) throw new Error(data.message);
console.log(data.data.num, data.data.zip_path);
}).catch(err => console.error(err.message));
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
body, _ := json.Marshal(map[string]any{
"contents": []string{"https://example.com/p/1001", "https://example.com/p/1002"},
"file_name_type": 1,
"base": map[string]any{"size": 600, "margin": 12, "dpi": 300},
"token": "YOUR_TOKEN",
})
resp, err := http.Post("https://api-v2.qrbatch.com/qrbatchv4api/create/createAPI.php", "application/json", bytes.NewBuffer(body))
if err != nil {
panic(err)
}
defer resp.Body.Close()
var out struct {
Code int `json:"code"`
Message string `json:"message"`
Data struct {
ZipPath string `json:"zip_path"`
Num int `json:"num"`
} `json:"data"`
}
json.NewDecoder(resp.Body).Decode(&out)
if out.Code != 0 {
panic(out.Message)
}
fmt.Println(out.Data.ZipPath)
}
application/x-www-form-urlencoded and let arrays serialise as contents[]=…. Nested objects still need to be JSON strings — they are parsed automatically on arrival.Response
Synchronous — the work is done by the time you get 200.
{
"code": 0,
"data": {
"qrcode_data": {
"0": {
"path": "https://api-v2.qrbatch.com//qrbatchv4api/create/img/2026-10-26-101530-482/1.png",
"file_name": "1",
"content": "https://example.com/p/1001"
},
"1": {
"path": "https://api-v2.qrbatch.com//qrbatchv4api/create/img/2026-10-26-101530-482/2.png",
"file_name": "2",
"content": "https://example.com/p/1002"
}
},
"finish": 1,
"domain": "https://api-v2.qrbatch.com/",
"num": 2,
"zip_path": "https://qrbatchzip-1256595918.cos.ap-singapore.myqcloud.com/qrcode/20261026-101530-6512a1b2c3d4e.zip",
"time": "0.42",
"create_time": "2026-10-26 10:15:30"
}
}
Field reference
| Field | Type | Description |
|---|---|---|
code |
int | 0 on success; anything else is an error — see Error codes. |
data.qrcode_data |
object | Generated images keyed by their position in contents. |
…[n].path |
string | Absolute URL of the image. Use this directly. |
…[n].file_name |
string | File name without extension. |
…[n].content |
string | The content that was encoded. |
data.num |
int | Number of images actually produced (empty inputs are skipped). |
data.finish |
int | 1 when the batch completed in this response. |
data.zip_path |
string | Absolute URL of a ZIP containing every image plus a CSV manifest. |
data.time |
string | Server-side duration in seconds, as a string. |
data.create_time |
string | Server timestamp, YYYY-MM-DD HH:MM:SS. |
Error codes
Failures return HTTP 200 with a non-zero code and a human-readable message. Branch on code, never on the message text.
| code | Meaning | What to do |
|---|---|---|
| 0 | Success | — |
| 301 | Missing contents, or the anonymous per-IP allowance is exhausted. |
Add contents; sign in or attach a token for a larger allowance. |
| 302 | Token could not be decrypted, or contents and labels have different lengths. |
Re-issue the token; align the two arrays. |
| 303 | Daily account allowance exhausted. | Reduce the batch or upgrade the plan. |
| 304 | Batch larger than the plan’s per-request cap. | Split the job into smaller batches. |
| 404 | Calling IP is blocklisted. | Contact support with your egress IP. |
| 500 | Server-side file or archive creation failed. | Retry once; if it persists, contact support. |
Notes
- Fields that look like JSON —
color,base,logo,labels,label_setting— are parsed automatically when sent as strings, so form posts and query strings behave like JSON. - Omitted fields use the defaults in Request parameters; you never have to send the full object.
- Empty or whitespace-only entries are dropped, so the number of images can be smaller than the number of inputs. Check
data.num. - Quota is consumed per produced image, not per request.
- Payloads are plain text — URLs with tracking parameters are encoded verbatim.
- Requests are rate-limited per IP in addition to the daily quota.
Support
Stuck on a response code? Send us the request you made (with the token removed) and the full response body — that is usually enough to pinpoint it.
Overview
Retail GTINs, GS1 logistics labels, asset tags and serial plates.
The Barcodes API renders 1D symbologies in batches. Send a list of values plus one code_type and you get back a ZIP of PNG, JPEG or SVG files, each named the way you asked for.
base.size is the width of the narrowest bar, base.height is how tall the bars are. Everything else derives from those, so a label that is 40 mm wide at 300 DPI is size: 3, height: 300, dpi: 300.Endpoint
https://api-v2.qrbatch.com/qrbatchv4api/barcode/createAPI.php
One endpoint serves every output format. Set base.img_type in the JSON body — the request shape and the response envelope stay identical, so moving a job from a preview PNG to a print-ready SVG is a single field.
base.img_type |
Output | File | Encoder | Use it for |
|---|---|---|---|---|
| 1 | PNG |
.png |
raster | Default. Screens, PDF embeds, on-demand label printers. |
| 2 | JPEG |
.jpg |
raster | Smaller files where transparency is not needed. |
| 3 | SVG |
.svg |
vector | Offset and flexo printing. Bars stay sharp at any size, a few KB per file. |
application/json.Supported symbologies
Ten code_type values, mapped to the encoders below.
code_type applies to the whole batch. To mix symbologies, send several requests — or use the QR API above if your payload is free-form text.
| code_type | Symbology | Input | Typical use |
|---|---|---|---|
code128 |
Code 128 (auto subset) | Any ASCII character; the encoder picks subset A/B/C per value. | Shipping, asset tags — the densest general-purpose 1D code |
code128A |
Code 128 subset A | Uppercase, digits and control characters. | Older systems locked to uppercase |
code128B |
Code 128 subset B | Full ASCII including lowercase. | Mixed-case text |
code128C |
Code 128 subset C | Digits only, in pairs. | Numeric serials, GS1 data |
code39 |
Code 39 | A–Z, 0–9, and - . $ / + % and space. |
Industrial, automotive, defence |
code39ext |
Code 39 Extended | Full ASCII via shift pairs. | Legacy systems that need symbols |
ean13 |
EAN-13 | 13 digits including the check digit. | Retail GTIN-13 |
ean8 |
EAN-8 | 8 digits including the check digit. | Small retail packages |
ean128 |
GS1-128 | GS1 application identifiers, e.g. (01)…(10)…. |
Shipping and food traceability |
upc |
UPC-A | 12 digits including the check digit. | North American retail |
Request parameters
Top level
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
contents |
array | required | — | One barcode value per item. Empty entries are skipped. |
base |
object | required | — | Geometry and output format. The key must be present even if you only override one field. |
code_type |
string | optional | code128 | Symbology for the whole batch — see Supported symbologies. Unknown values fall back to Code 128. |
token |
string | optional | "" | Account auth code. Empty means the anonymous per-IP allowance. |
file_name_type |
int | optional | 1 | 1 = sequential index, 2 = sanitized content, 3 = the matching entry from names. |
names |
array | optional | [] | File names used when file_name_type is 3. |
show_label |
bool | optional | true | Prints the value as human-readable text under the bars. SVG output adds a caption band on top of base.height. |
font_size |
int | optional | 12 | Caption font size in pixels. Applies to every format. |
color |
object | optional | see below | Bar and background colours. |
base — geometry & format
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
size |
int | optional | 2 | Width of the narrowest bar, in pixels. This is the scan-density dial. |
height |
int | optional | 60 | Bar height in pixels, excluding the caption band. |
margin |
int | optional | 10 | Quiet-zone padding in pixels added on all four sides. |
dpi |
int | optional | 96 | Written into the PNG metadata; use 300 for print. |
img_type |
int | optional | 1 | 1 = PNG, 2 = JPEG, 3 = SVG. All three are served by the same endpoint. |
transparent |
bool | optional | false | Omit the background plate. Applies to PNG and SVG; JPEG has no alpha channel. |
color
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
front_color |
string | optional | "#000000" | Bars, as a hex colour such as #0f766e. |
bg_color |
string | optional | "#FFFFFF" | Background, as a hex colour. |
R,G,B triplets. Sending "0,0,0" here produces black but "255,255,255" is not a valid background — use "#FFFFFF".Code examples
Replace YOUR_TOKEN with your auth code, or press Get my token in Authentication to fill every example on this page.
Payload
{
"contents": ["QRB-2026-0001", "QRB-2026-0002"],
"code_type": "code128",
"file_name_type": 1,
"show_label": true,
"font_size": 12,
"base": {
"size": 2,
"height": 60,
"margin": 10,
"dpi": 300,
"img_type": 1
},
"color": {
"front_color": "#000000",
"bg_color": "#FFFFFF"
},
"token": "YOUR_TOKEN"
}
A retail GTIN batch
{
"contents": ["4006381333931", "4006381333948"],
"code_type": "ean13",
"show_label": false,
"base": { "size": 2, "height": 80, "margin": 12, "dpi": 300 },
"token": "YOUR_TOKEN"
}
Same request, four languages
curl -X POST "https://api-v2.qrbatch.com/qrbatchv4api/barcode/createAPI.php" \
-H "Content-Type: application/json" \
-d '{
"contents": ["QRB-2026-0001", "QRB-2026-0002"],
"code_type": "code128",
"show_label": true,
"base": { "size": 2, "height": 60, "margin": 10, "dpi": 300 },
"token": "YOUR_TOKEN"
}'
const res = await fetch('https://api-v2.qrbatch.com/qrbatchv4api/barcode/createAPI.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
contents: ['QRB-2026-0001', 'QRB-2026-0002'],
code_type: 'code128',
show_label: true,
base: { size: 2, height: 60, margin: 10, dpi: 300 },
token: 'YOUR_TOKEN'
})
});
const { code, message, data } = await res.json();
if (code !== 0) throw new Error(message);
// path is relative; domain is the absolute prefix
data.qrcode_data && Object.values(data.qrcode_data).forEach(item => {
console.log(item.domain + item.path);
});
import requests
res = requests.post(
"https://api-v2.qrbatch.com/qrbatchv4api/barcode/createAPI.php",
json={
"contents": ["QRB-2026-0001", "QRB-2026-0002"],
"code_type": "code128",
"show_label": True,
"base": {"size": 2, "height": 60, "margin": 10, "dpi": 300},
"token": "YOUR_TOKEN",
},
timeout=120,
)
payload = res.json()
if payload.get("code") != 0:
raise RuntimeError(payload.get("message"))
zip_url = payload["data"]["zip_path"]
print(zip_url)
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
body, _ := json.Marshal(map[string]any{
"contents": []string{"QRB-2026-0001", "QRB-2026-0002"},
"code_type": "code128",
"show_label": true,
"base": map[string]any{"size": 2, "height": 60, "margin": 10, "dpi": 300},
"token": "YOUR_TOKEN",
})
resp, err := http.Post("https://api-v2.qrbatch.com/qrbatchv4api/barcode/createAPI.php", "application/json", bytes.NewBuffer(body))
if err != nil {
panic(err)
}
defer resp.Body.Close()
var out struct {
Code int `json:"code"`
Data struct {
Domain string `json:"domain"`
ZipPath string `json:"zip_path"`
} `json:"data"`
}
json.NewDecoder(resp.Body).Decode(&out)
fmt.Println(out.Data.Domain + out.Data.ZipPath)
}
Response
{
"code": 0,
"data": {
"barcode_data": [
{
"path": "https://api-v2.qrbatch.com/qrbatchv4api/barcode/img/2026-10-26-101530-482/1.png",
"file_name": "1",
"content": "QRB-2026-0001",
"format": "png"
},
{
"path": "https://api-v2.qrbatch.com/qrbatchv4api/barcode/img/2026-10-26-101530-482/2.png",
"file_name": "2",
"content": "QRB-2026-0002",
"format": "png"
}
],
"finish": 1,
"domain": "https://api-v2.qrbatch.com/",
"num": 2,
"skipped": {},
"time": "0.08",
"create_time": "2026-10-26 10:15:30",
"zip_path": "https://qrbatchzip-1256595918.cos.ap-singapore.myqcloud.com/barcode/20261026-101530-6512a1b2c3d4e.zip"
}
}
path and zip_path are ready to use — no concatenation needed. domain stays in the payload for clients written against the earlier contract.Field reference
| Field | Type | Description |
|---|---|---|
code |
int | 0 on success — see Error codes. |
data.barcode_data |
object | Generated files, in the order they were submitted. qrcode_data is kept as a compatibility alias. |
…[n].path |
string | Absolute URL of the generated file. Use it as-is. |
…[n].domain |
string | Retained for compatibility; path is already absolute. |
…[n].file_name |
string | File name without extension. |
…[n].content |
string | The value that was encoded. |
…[n].format |
string | File extension of this entry: png, jpg or svg. |
data.skipped |
object | Values that could not be encoded, keyed by their index in contents. Only present when part of the batch failed. |
data.num |
int | Number of files produced. |
data.finish |
int | 1 when the batch completed. |
data.zip_path |
string | Absolute URL of the ZIP bundle. |
data.time |
string | Server-side duration in seconds, as a string. |
data.create_time |
string | Server timestamp. |
Vector (SVG) output
Same payload, smaller feature set.
Send "base": { "img_type": 3 } and the same endpoint switches to the vector encoder. Output is a true vector — bars stay crisp at any print size and the files are a few KB each.
| Behaviour | PNG / JPEG (img_type 1–2) |
SVG (img_type 3) |
|---|---|---|
Supported code_type |
All ten values | Nine of ten — every value except ean128, which returns code: 306 |
base.size |
Narrow-bar width in pixels | Width multiplier applied to the computed bar pattern |
base.height |
Bar height in pixels | Bar height in pixels; the caption band adds 2 × font_size on top |
font_size |
Applies | Applies — sets the caption size |
margin, dpi |
Applies | Ignored — handle margins in your layout |
transparent |
Applies (PNG) | Applies — omits the background plate |
| EAN-13 check digit | Must be supplied | Computed automatically from a 12-digit value |
{
"contents": ["4006381333931"],
"code_type": "ean13",
"show_label": true,
"base": { "size": 2, "height": 60, "img_type": 3 },
"color": { "front_color": "#000000" },
"token": "YOUR_TOKEN"
}
format: every entry reports png, jpg or svg. Compare it with what you asked for — that is the fastest way to catch a mistyped img_type.Error codes
Same envelope as the QR API: HTTP 200 with a numeric code on failure. Branch on the number, not the message.
| code | Meaning | What to do |
|---|---|---|
| 0 | Success | — |
| 301 | contents missing or not an array, base missing, or the anonymous per-IP allowance is exhausted. |
Send both keys; sign in or attach a token for more volume. |
| 302 | Token could not be decrypted. | Re-issue the token; check for truncation. |
| 303 | Daily allowance exhausted, or the batch exceeds the per-request cap. | Split the batch or upgrade the plan — the response carries limit, used and remaining. |
| 305 | base.img_type is not 1, 2 or 3. |
Send one of the three documented values. |
| 306 | Unknown code_type, or one the requested format cannot encode (for example ean128 with img_type: 3). |
Pick a supported symbology, or switch to img_type: 1. |
| 307 | Every value in the batch failed to encode. | Read data.skipped for the per-item reason. |
| 404 | Calling IP is blocklisted. | Contact support with your egress IP. |
| 500 | Output directory could not be created or written. | Retry once; if it persists, contact support with the create_time. |
Notes
- Quiet zone is not optional. Keep
base.marginat 10 px or more. A barcode pasted flush against artwork frequently fails to scan even though it looks fine. - Bar width beats height. If a scanner struggles, raise
base.sizebefore raisingheight— height buys tolerance to being scanned at an angle, width buys resolution. - One symbology per request.
code_typeis batch-wide; split mixed jobs into separate calls and merge the ZIPs yourself. - File names are sanitised. With
file_name_type: 2anything outside[A-Za-z0-9-]becomes an underscore, and collisions get a numeric suffix. - Caption fonts. PNG/JPEG captions render with the bundled font at
font_size; there is no custom-font option on the API path. - Quota is consumed per produced file, and empty
contentsentries are skipped before counting.
Support
For symbology-specific problems (a code that scans on one device but not another), send us the image, the encoded value and the scanner model. That combination resolves most cases in one reply.