The ChartQuery Barcode API generates barcode images in 25+ formats — EAN-13, EAN-8, UPC-A, Code 128, ITF-14, GS1-128, postal codes and more — as SVG (default) or PNG.
- Barcode API — Generate a barcode image via GET.
Use it for retail packaging, shipping, inventory, invoices and labels.
| Endpoint | Request | Credits |
|---|---|---|
| Barcode API | GET /v1/barcode |
3 |
- How it works
- Barcode API
- Code examples in other languages
- Use cases
- Why ChartQuery?
- FAQ
- Official SDKs
- Related repositories
- Support
- Create a ChartQuery account and copy your API key from the dashboard.
- Call
https://api.chartquery.comwith the headerx-api-key: YOUR_API_KEY. - Use the result in your app — no infrastructure to run.
export CHARTQUERY_API_KEY="your-api-key"
pip install requests # Python
# TypeScript: Node.js 18+ (native fetch), run with `npx tsx file.ts`Generate a barcode image via GET. Output: SVG (default) or PNG. Supports 25+ formats: EAN-13, Code 128, ITF-14, GS1-128, postal codes and more. Example: ?data=4006381333931&type=ean13
GET https://api.chartquery.com/v1/barcode · 3 credits per request · API reference
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
data |
query | string | ✅ | Value to encode. Always send a string, including an all-digit GTIN. |
type |
query | string (code128, ean13, ean8, upca, upce, code39) |
— | Barcode symbology. Default: code128. |
height |
query | number | — | Bar height in the selected unit. Default: 80. |
color |
query | string | — | Bar color as a CSS color. Default: #000. Paste the raw value, including #. |
show_text |
query | boolean | — | Draw the human-readable text with the bars. |
text_position |
query | string (bottom, top) |
— | Position of the human-readable text. Default: bottom. |
text_align |
query | string (center, left, right) |
— | Horizontal alignment of the text. Default: center. |
font_size |
query | number | — | Text size in the selected unit. Default: 14. |
font_family |
query | string | — | Font family of the text. Default: monospace. |
bar_width |
query | number | — | Width multiplier of one module. Default: 2. A higher value makes the code wider and easier to scan. |
bar_gap |
query | number | — | Extra space between bars, in the selected unit. Default: 0. |
background |
query | string | — | Background color. Default: #fff. |
margin |
query | number | — | Margin on every side. Default: 10. A per-side margin overrides this value. |
margin_top |
query | number | — | Top margin. It overrides margin on that side. |
margin_bottom |
query | number | — | Bottom margin. It overrides margin on that side. |
margin_left |
query | number | — | Left margin. It overrides margin on that side. |
margin_right |
query | number | — | Right margin. It overrides margin on that side. |
rotation |
query | number (0, 90, 180, 270) |
— | Rotation in degrees. Default: 0. |
bearer_bars |
query | boolean | — | Draw horizontal bearer bars above and below the code. |
unit |
query | string (px, mm, in, cm) |
— | Unit used by the dimension fields. Default: px. |
aria_label |
query | string | — | Accessible name on the SVG. |
title |
query | string | — | SVG title, used as a tooltip. |
desc |
query | string | — | Longer SVG description for assistive tech. |
format |
query | string (svg, png) |
— | Output format. Default: svg. |
share |
query | boolean | — | Persist the result and return share URLs instead of the image. |
import os
import requests
API_KEY = os.environ["CHARTQUERY_API_KEY"]
HEADERS = {"x-api-key": API_KEY}
response = requests.get(
"https://api.chartquery.com/v1/barcode",
headers=HEADERS,
params={
"data": "HELLO-WORLD-2026",
},
timeout=120,
)
response.raise_for_status()
with open("barcode.svg", "wb") as f:
f.write(response.content)
print("Saved barcode.svg", len(response.content), "bytes")import { writeFile } from "node:fs/promises";
const headers = { "x-api-key": process.env.CHARTQUERY_API_KEY!, "Content-Type": "application/json" };
const params = new URLSearchParams({
"data": "HELLO-WORLD-2026",
});
const response = await fetch(`https://api.chartquery.com/v1/barcode?${params}`, { headers });
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
await writeFile("barcode.svg", Buffer.from(await response.arrayBuffer()));
console.log("Saved barcode.svg");The response body is the generated file (saved as barcode.svg in every example). Error responses are JSON with an explanatory message.
Ready-to-run examples live in examples/; each reads your key from CHARTQUERY_API_KEY.
| Language | barcode |
|---|---|
| cURL (Bash) | barcode.sh |
| PHP | barcode.php |
| C# | Barcode.cs |
| Go | barcode.go |
| Java | BarcodeExample.java |
| Ruby | barcode.rb |
| Node.js | barcode.mjs |
- Retail & packaging — EAN/UPC barcodes for products.
- Logistics — Code 128 / GS1-128 for shipping and inventory.
- Documents — Barcodes on invoices and delivery notes.
- Images in one request — the response body is the PNG/SVG/PDF, ready for emails, PDFs, dashboards, Slack or
<img>tags. - Charts, diagrams, QR codes, barcodes, labels — Chart.js configs, 28 diagram languages (Mermaid, Graphviz, PlantUML, D2…), 25+ barcode formats.
- AI generation — describe a chart or diagram in plain English and get the rendered image.
- No rendering infrastructure — no headless browser, fonts or libraries to maintain.
- Copy-paste examples — Python and TypeScript in each README, 7 more languages in
examples/.
Create an account on ChartQuery, copy your API key and send it in the x-api-key header of every request to https://api.chartquery.com.
Credits per call: /v1/barcode 3. See ChartQuery pricing.
The response body is the file itself (image or document). Save it directly to disk or stream it to your storage — every example in this repository writes the file locally.
Any language that can make an HTTP request. This README shows Python and TypeScript; the examples/ folder contains cURL, PHP, C#, Go, Java, Ruby and Node.js.
Use ChartQuery from your own language with a typed client:
| SDK | Package | Install |
|---|---|---|
| Node.js | @chartquery/sdk |
npm install @chartquery/sdk |
| Python | chartquery |
pip install chartquery |
| Go | chartquery-go |
go get github.com/chartquery/chartquery-go |
| .NET | ChartQuery |
dotnet add package ChartQuery |
| Ruby | chartquery |
gem install chartquery |
| PHP | chartquery/sdk |
composer require chartquery/sdk |
| Java | chartquery-java |
build from source, see its README |
| CLI | @chartquery/cli |
npm install -g @chartquery/cli |
| MCP server | @chartquery/mcp |
npx -y @chartquery/mcp |
- 💬 Join the Discord to ask questions and share what you build.
- 📚 Read the API reference.
- 🔑 Get your API key.
Built by ChartQuery. Examples are released under the MIT license.
