API Documentation
Generate barcodes programmatically. Plug it into Claude Code, ChatGPT/Codex, Cursor, openclaw, Aider, Continue, or any AI agent that supports HTTP tool calls — drop the spec into your agent's tool definitions and let it generate, validate, and bulk-create barcodes on demand. Available on any paid plan; quota applies per tier.
Base URL
https://upcgen.comAuthentication
Every request must include an API key in the Authorization header:
Authorization: Bearer upcgen_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxManage API keys in your account dashboard.
Quick start
Render a UPC-A barcode as PNG:
curl -X POST https://upcgen.com/api/barcode \
-H "Authorization: Bearer $UPCGEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"format":"upca","text":"036000291452","output":"png"}' \
--output barcode.pngAI agent integration
The API is a clean fit for any AI coding agent that can call HTTP tools — Claude Code, ChatGPT / Codex, Cursor, openclaw, Aider, Continue, Cline, Roo Code, and anything MCP-compatible. Two endpoints, JSON in / JSON or image out, predictable errors.
Claude tool definition (function calling)
{
"name": "upcgen_generate",
"description": "Generate one or more valid barcodes (UPC-A, EAN-13, Code 128, FNSKU, etc.) with correct check digits. Returns codes as JSON or CSV.",
"input_schema": {
"type": "object",
"properties": {
"format": { "type": "string", "enum": ["upca","upce","ean13","ean8","isbn","itf14","code128","fnsku","datamatrix"] },
"mode": { "type": "string", "enum": ["random","sequential"], "default": "random" },
"prefix": { "type": "string", "description": "Required when mode = sequential" },
"count": { "type": "integer", "minimum": 1, "maximum": 1000, "default": 1 },
"output": { "type": "string", "enum": ["json","csv"], "default": "json" }
},
"required": ["format"]
}
}OpenAI / Codex tool definition
{
"type": "function",
"function": {
"name": "upcgen_generate",
"description": "Generate barcodes via UPCGen REST API. Use POST https://upcgen.com/api/generate with bearer auth.",
"parameters": {
"type": "object",
"properties": {
"format": { "type": "string", "enum": ["upca","upce","ean13","ean8","isbn","itf14","code128","fnsku","datamatrix"] },
"count": { "type": "integer", "minimum": 1, "maximum": 1000 }
},
"required": ["format"]
}
}
}Store your UPCGEN_API_KEYin the agent's env so the bearer header is set automatically. Same OpenAPI shape works in Cursor (/api/tools/openapi.json), Aider (--openai-api-key with custom base), and any MCP server wrapping our REST API.
Endpoints
POST /api/barcode
Render a barcode image from a value you provide.
Request body:
{
"format": "upca" | "upce" | "ean13" | "ean8" | "isbn" | "itf14" | "code128" | "fnsku" | "datamatrix",
"text": "036000291452",
"output": "png" | "svg" // optional, default "png"
}Response:
Binary image body with the appropriate Content-Type.
POST /api/generate
Generate one or more valid codes with correct check digits. Optionally return a CSV.
Request body:
{
"format": "upca",
"mode": "random" | "sequential", // default "random"
"prefix": "036000", // required when mode = "sequential"
"count": 100, // 1..1000, default 1
"output": "json" | "csv" // default "json"
}Response (JSON):
{
"codes": ["036000000016", "036000000023", ...],
"mode": "sequential",
"count": 100,
"format": "upca"
}With output=csv, returns text/csv ready to save.
Code samples
Node.js
const res = await fetch("https://upcgen.com/api/generate", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.UPCGEN_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ format: "upca", mode: "random", count: 50 }),
});
const { codes } = await res.json();Python
import os, requests
r = requests.post(
"https://upcgen.com/api/generate",
headers={"Authorization": f"Bearer {os.environ['UPCGEN_API_KEY']}"},
json={"format": "ean13", "mode": "random", "count": 100, "output": "csv"},
)
open("codes.csv", "wb").write(r.content)Rate limits
Quota is shared between UI and API usage on a rolling 30-day window:
- Starter: 100 codes / month
- Pro: 3,000 codes / month
- Business: 25,000 codes / month
When you exceed your quota, the API returns HTTP 429 with a JSON body explaining the reset.
Errors
| Status | Meaning |
|---|---|
| 400 | Invalid input — check the request body schema |
| 401 | Missing or invalid API key |
| 403 | Feature gated to a higher plan (e.g. SVG output) |
| 422 | Format-specific validation failed (e.g. wrong digit count) |
| 429 | Quota reached for this billing period |
| 500 | Server error — try again or contact support |
Support
Questions, integration help, custom rate limits: [email protected]