# Barcode Generator (`automation-lab/barcode-generator`) Actor

Generate EAN-13, Code128, UPC-A, QR codes, and 10+ barcode formats as PNG or SVG images. Batch generation with customizable colors and dimensions.

- **URL**: https://apify.com/automation-lab/barcode-generator.md
- **Developed by:** [Stas Persiianenko](https://apify.com/automation-lab) (community)
- **Categories:** Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## Barcode Generator

Generate **EAN-13, Code128, UPC-A, QR codes**, and 10+ barcode formats as PNG and SVG images — in bulk. Define a list of barcodes, hit run, and download your images from the key-value store. No external APIs, no proxy costs, instant results.

### 🏷️ What does it do?

Barcode Generator takes a list of barcode specifications (data, format, size, color) and produces:

- **PNG images** — raster images ready for print or embedding in documents
- **SVG images** — vector graphics that scale to any resolution without quality loss
- **Both formats** — generate PNG + SVG in a single run

Every generated image is saved to the actor's **key-value store** with a named key (e.g., `my-product-ean13.png`). The **dataset** contains a record for each barcode with metadata, KV store key references, and any error messages for failed items.

#### Supported barcode formats

| Format | Description | Example data |
|--------|-------------|--------------|
| **EAN-13** | European Article Number, retail standard | `012345678901` (12 digits) |
| **EAN-8** | Compact version of EAN | `0123456` (7 digits) |
| **UPC-A** | Universal Product Code, North American retail | `012345678905` (12 digits) |
| **UPC-E** | Compact UPC for small packages | `01234565` (8 digits) |
| **Code128** | Alphanumeric, variable length | `Hello World`, `ORDER-1234` |
| **Code39** | Uppercase alphanumeric + symbols | `HELLO WORLD`, `ABC-123` |
| **ITF-14** | Shipping carton barcodes | `0000012345678` (13 digits) |
| **MSI** | Inventory and warehouse | `1234567` |
| **Codabar** | Library books, blood banks | `A1234567B` |
| **Pharmacode** | Pharmaceutical packaging | `1234` |
| **QR Code** | 2D matrix code for URLs, text, data | Any text or URL |

### 👤 Who is it for?

#### E-commerce store owners
Bulk-generate EAN-13 or UPC-A barcodes for product catalogs. Generate 500+ product barcodes in one run and download them all as print-ready PNGs.

#### Logistics and warehouse teams
Create Code128 or ITF-14 shipping labels programmatically. Integrate with your inventory system via the Apify API to auto-generate barcodes whenever new items are added.

#### Developers and QA engineers
Generate barcode images for testing receipt parsers, mobile scanning apps, or POS system integrations — without setting up a barcode library in your own project.

#### Print-on-demand and label design
Generate SVG barcodes for vector workflows. SVG barcodes can be imported into Adobe Illustrator, Affinity Publisher, or Figma and scaled to any size without pixelation.

#### No-code automation builders
Use with Zapier, Make (Integromat), or n8n to auto-generate QR codes for customer URLs, loyalty cards, or event tickets.

### ✅ Why use Barcode Generator?

- **Batch processing** — generate hundreds of barcodes in a single run
- **Zero proxy cost** — pure computation, runs in seconds at negligible cost
- **PNG + SVG** — use raster for print, vector for design workflows
- **Full customization** — colors, dimensions, margins, font size per barcode
- **Named output keys** — images saved with predictable KV store keys for easy retrieval
- **Error isolation** — one invalid barcode doesn't stop the whole batch; errors are reported per item
- **11 formats** — covers retail (EAN/UPC), logistics (Code128/ITF), pharma, and QR

### 📦 What data does it extract?

Each dataset record contains:

| Field | Type | Description |
|-------|------|-------------|
| `label` | string | The identifier used as the KV store file key prefix |
| `data` | string | The data encoded in the barcode |
| `format` | string | Barcode format (EAN13, CODE128, QR, etc.) |
| `outputFormat` | string | PNG, SVG, or BOTH |
| `width` | number | Image width in pixels |
| `height` | number | Image height in pixels |
| `kvKey` | string | KV store key for single-format output |
| `kvKeyPng` | string | KV store key for PNG when outputFormat is BOTH |
| `kvKeySvg` | string | KV store key for SVG when outputFormat is BOTH |
| `success` | boolean | Whether generation succeeded |
| `error` | string | Error message if generation failed |

### 💰 How much does it cost to generate barcodes?

Barcode generation is **pure computation** — no web requests, no proxy, no external APIs. Costs are minimal:

| Event | FREE | BRONZE | SILVER | GOLD | PLATINUM | DIAMOND |
|-------|------|--------|--------|------|----------|---------|
| Actor start (one-time per run) | $0.005 | $0.00475 | $0.00425 | $0.00375 | $0.003 | $0.0025 |
| Per barcode generated | $0.0003 | $0.00027 | $0.00024 | $0.000195 | $0.00015 | $0.00012 |

**Example costs (FREE tier):**
- 100 barcodes → ~$0.035
- 500 barcodes → ~$0.155
- 1,000 barcodes → ~$0.305

**Example costs (DIAMOND tier):**
- 100 barcodes → ~$0.0145
- 1,000 barcodes → ~$0.1225

**Free plan estimate:** Apify's free tier ($5/month credit) covers approximately **14,000 barcodes/month**.

Pricing is Pay-Per-Event — you only pay for what you generate. Higher Apify subscription tiers get automatic volume discounts (up to 50% off at DIAMOND tier).

### 🚀 How to generate barcodes

#### Quick start (3 steps)

1. **Open the actor** on Apify Console
2. **Fill in the `barcodes` list** with your data, format, and optional label
3. **Click Start** — download your images from the key-value store when done

#### Step-by-step with the visual editor

1. In the **Barcodes to generate** field (JSON editor), add one object per barcode:
   ```json
   [
     { "data": "012345678901", "format": "EAN13", "outputFormat": "PNG", "label": "my-product" },
     { "data": "https://mystore.com", "format": "QR", "outputFormat": "BOTH", "label": "store-qr" }
   ]
````

2. Set **Default output format** (PNG, SVG, or Both) — applies when individual barcodes don't specify one
3. Adjust **width, height, colors, and margin** in the Advanced Options section
4. Click **Start** and wait for the run to complete (seconds to minutes depending on batch size)
5. Go to **Key-value store** tab in the run detail — download your images by key name

#### Downloading all images via API

After the run completes, fetch all generated images:

```bash
## List all keys in the KV store
curl "https://api.apify.com/v2/key-value-stores/{STORE_ID}/keys" \
  -H "Authorization: Bearer YOUR_API_TOKEN"

## Download a specific image
curl "https://api.apify.com/v2/key-value-stores/{STORE_ID}/records/my-product.png" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -o my-product.png
```

### ⚙️ Input parameters

#### Barcodes list (required)

The `barcodes` array is the core input. Each item supports:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `data` | string | ✅ Yes | The value to encode (number, text, URL) |
| `format` | string | No | Barcode format — defaults to CODE128. Options: EAN13, EAN8, UPC, UPC\_E, CODE128, CODE39, ITF14, MSI, PHARMACODE, CODABAR, QR |
| `outputFormat` | string | No | PNG, SVG, or BOTH — overrides global setting |
| `label` | string | No | File key prefix. Auto-generated if omitted (e.g., `barcode-1-EAN13-012345678901`) |
| `width` | number | No | Override default width for this barcode |
| `height` | number | No | Override default height for this barcode |
| `lineColor` | string | No | Override bar/module color for this barcode |
| `background` | string | No | Override background color for this barcode |
| `includeText` | boolean | No | Override text display for this barcode |

#### Default settings

| Parameter | Default | Description |
|-----------|---------|-------------|
| `outputFormat` | PNG | Default output format for all barcodes |
| `width` | 300 | Default image width in pixels |
| `height` | 150 | Default image height in pixels |
| `lineColor` | #000000 | Default bar/module color |
| `background` | #ffffff | Default background color |
| `includeText` | true | Show human-readable text below barcode |
| `fontSize` | 20 | Font size for text label (px) |
| `margin` | 10 | White space margin around barcode (px) |
| `qrErrorCorrection` | M | QR error correction: L/M/Q/H |

#### Color values

All color fields accept any CSS color string:

- Hex: `#000000`, `#ff5500`
- Named: `black`, `white`, `red`
- RGB: `rgb(0, 0, 0)`
- Transparent background: `transparent`

### 📊 Output examples

#### Dataset record (EAN-13 → PNG)

```json
{
  "label": "my-product",
  "data": "012345678901",
  "format": "EAN13",
  "outputFormat": "PNG",
  "width": 300,
  "height": 150,
  "kvKey": "my-product.png",
  "kvKeyPng": null,
  "kvKeySvg": null,
  "success": true,
  "error": null
}
```

#### Dataset record (QR → BOTH)

```json
{
  "label": "store-qr",
  "data": "https://mystore.com",
  "format": "QR",
  "outputFormat": "BOTH",
  "width": 300,
  "height": 300,
  "kvKey": null,
  "kvKeyPng": "store-qr.png",
  "kvKeySvg": "store-qr.svg",
  "success": true,
  "error": null
}
```

#### Dataset record (error case)

```json
{
  "label": "bad-barcode",
  "data": "INVALID@#$",
  "format": "EAN13",
  "outputFormat": "PNG",
  "success": false,
  "error": "Invalid data \"INVALID@#$\" for format EAN13: is not a valid input for EAN13"
}
```

### 💡 Tips and best practices

#### Format selection guide

- Use **EAN-13** for retail products sold in Europe, Australia, and most of the world
- Use **UPC-A** for retail products sold in North America
- Use **Code128** for shipping labels, inventory, internal tracking — most flexible format
- Use **Code39** for legacy systems (older industrial scanners) — uppercase only
- Use **QR** for URLs, contact info, WiFi credentials, app links
- Use **ITF-14** for outer carton/shipping container barcodes

#### Data format requirements

| Format | Data requirements |
|--------|------------------|
| EAN-13 | Exactly 12 digits (checksum auto-calculated) |
| EAN-8 | Exactly 7 digits (checksum auto-calculated) |
| UPC-A | Exactly 12 digits |
| Code128 | Any ASCII characters, any length |
| Code39 | Uppercase A-Z, 0-9, space, - . $ / + % |
| ITF-14 | Exactly 13 digits (even total) |
| QR | Any text, URL, JSON, or binary data |

#### SVG for print, PNG for web

SVG files are resolution-independent — perfect for printing at any DPI or importing into design tools. PNG files are better for web embedding, email, or systems that don't support SVG.

#### Custom colors for branding

Override `lineColor` and `background` per barcode to match brand colors. For example, a dark blue barcode on a light blue background:

```json
{
  "data": "https://mystore.com",
  "format": "QR",
  "lineColor": "#1a237e",
  "background": "#e3f2fd",
  "label": "branded-qr"
}
```

> Note: Ensure sufficient contrast between `lineColor` and `background` — scanners need at least 3:1 contrast ratio.

#### Batch labeling strategy

Use descriptive `label` values that map to your data source:

```json
[
  { "data": "9780451524935", "format": "EAN13", "label": "isbn-catch-22" },
  { "data": "9780345391803", "format": "EAN13", "label": "isbn-hitchhiker" }
]
```

This makes it easy to download specific files by name from the KV store.

### 🔌 Integrations

#### Zapier — auto-generate QR codes for new orders

1. Trigger: New order in WooCommerce / Shopify
2. Action: Run Barcode Generator via Apify HTTP API with the order URL
3. Action: Get the generated PNG from KV store
4. Action: Attach to order confirmation email

#### Make (Integromat) — product catalog barcodes

1. Schedule: Daily at midnight
2. Get new products from your database or Google Sheet
3. HTTP: POST to Apify API with product EAN list
4. Wait for run completion (webhook or poll)
5. Download all PNGs from KV store to Google Drive

#### n8n — warehouse label generation

1. Webhook: receives SKU + quantity from WMS
2. Code node: build barcode list JSON (CODE128 per SKU)
3. HTTP Request: POST to Apify run endpoint
4. HTTP Request: GET run status until SUCCEEDED
5. HTTP Request: download each barcode image
6. Send to label printer via network API

#### API integration — embed in your backend

Generate barcodes on demand from any backend:

```python
import apify_client
import requests

client = apify_client.ApifyClient("YOUR_API_TOKEN")

## Start a run
run = client.actor("automation-lab/barcode-generator").call(run_input={
    "barcodes": [
        {"data": "SHIPMENT-2024-001", "format": "CODE128", "outputFormat": "PNG", "label": "ship-001"}
    ],
    "width": 400,
    "height": 120
})

## Get the KV store and download the image
kv_store = client.key_value_store(run["defaultKeyValueStoreId"])
record = kv_store.get_record("ship-001.png")
with open("ship-001.png", "wb") as f:
    f.write(record["value"])
```

### 🧑‍💻 API usage

#### Node.js

```javascript
import { ApifyClient } from 'apify-client';
import { writeFileSync } from 'fs';

const client = new ApifyClient({ token: 'YOUR_API_TOKEN' });

const run = await client.actor('automation-lab/barcode-generator').call({
    barcodes: [
        { data: '012345678901', format: 'EAN13', outputFormat: 'PNG', label: 'product-ean13' },
        { data: 'https://example.com', format: 'QR', outputFormat: 'BOTH', label: 'site-qr' }
    ],
    width: 300,
    height: 150,
    lineColor: '#000000',
    background: '#ffffff'
});

// Download the generated images
const kvStore = client.keyValueStore(run.defaultKeyValueStoreId);
const pngRecord = await kvStore.getRecord('product-ean13.png');
writeFileSync('product-ean13.png', pngRecord.value);

const svgRecord = await kvStore.getRecord('site-qr.svg');
writeFileSync('site-qr.svg', svgRecord.value);

console.log('Barcodes downloaded!');
```

#### Python

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_API_TOKEN")

run = client.actor("automation-lab/barcode-generator").call(run_input={
    "barcodes": [
        {"data": "012345678901", "format": "EAN13", "outputFormat": "PNG", "label": "product-ean13"},
        {"data": "https://example.com", "format": "QR", "outputFormat": "BOTH", "label": "site-qr"}
    ],
    "width": 300,
    "height": 150,
    "lineColor": "#000000",
    "background": "#ffffff"
})

## Download generated images
kv_store = client.key_value_store(run["defaultKeyValueStoreId"])

record = kv_store.get_record("product-ean13.png")
with open("product-ean13.png", "wb") as f:
    f.write(record["value"])

record_svg = kv_store.get_record("site-qr.svg")
with open("site-qr.svg", "w") as f:
    f.write(record_svg["value"])

print("Barcodes downloaded!")
```

#### cURL

```bash
## Start a run
curl -X POST "https://api.apify.com/v2/acts/automation-lab~barcode-generator/runs" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "barcodes": [
      {"data": "012345678901", "format": "EAN13", "outputFormat": "PNG", "label": "product-ean13"},
      {"data": "https://example.com", "format": "QR", "outputFormat": "PNG", "label": "site-qr"}
    ],
    "width": 300,
    "height": 150
  }'

## Wait for run to finish, then download
STORE_ID="YOUR_KV_STORE_ID"
curl "https://api.apify.com/v2/key-value-stores/${STORE_ID}/records/product-ean13.png" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -o product-ean13.png
```

### 🤖 MCP — Use with Claude AI

Use Barcode Generator directly in Claude conversations via the Model Context Protocol (MCP).

#### Claude Code (terminal)

```bash
claude mcp add --transport http apify "https://mcp.apify.com?tools=automation-lab/barcode-generator"
```

#### Claude Desktop / Cursor / VS Code

Add to your MCP configuration file (`claude_desktop_config.json` or `.cursor/mcp.json`):

```json
{
  "mcpServers": {
    "apify": {
      "type": "http",
      "url": "https://mcp.apify.com?tools=automation-lab/barcode-generator",
      "headers": {
        "Authorization": "Bearer YOUR_APIFY_TOKEN"
      }
    }
  }
}
```

#### Example Claude prompts

Once connected, you can ask Claude:

- *"Generate an EAN-13 barcode for the number 012345678901 as a PNG"*
- *"Create a QR code for https://mystore.com with blue bars on a light blue background"*
- *"Generate Code128 barcodes for these 20 SKUs and save them as SVG files"*
- *"Make a batch of barcodes for my product catalog: \[paste CSV]"*

### ⚖️ Legality and usage

Barcode generation is fully legal. The barcode formats (EAN, UPC, Code128, QR, etc.) are open standards. You own any barcodes you generate.

**Note on EAN/UPC retail use:** If you plan to sell products in retail stores, EAN-13 and UPC-A codes should be registered with GS1 (gs1.org) to ensure global uniqueness. Self-generated barcodes are fine for internal inventory, warehouse, or testing use. For production retail listings on Amazon, Walmart, etc., obtain a licensed GS1 prefix.

QR codes have no registration requirement — generate freely for any use.

### ❓ FAQ

**Q: What is the maximum number of barcodes per run?**
A: There is no hard limit — the actor processes barcodes sequentially. 500 barcodes typically complete in under 30 seconds. For very large batches (10,000+), consider splitting into multiple runs or using the API with parallel calls.

**Q: Can I use transparent backgrounds?**
A: Yes — set `background` to `"transparent"` for transparent PNG backgrounds. This is useful when overlaying barcodes on colored labels or product images.

**Q: Why did my EAN-13 barcode fail?**
A: EAN-13 requires exactly 12 numeric digits. The checksum digit (13th) is calculated automatically. Common mistakes: providing 13 digits (include the check digit), letters, or special characters. Use `012345678901` (12 digits), not `0123456789012`.

**Q: My Code39 barcode shows an error — why?**
A: Code39 only supports uppercase A-Z, digits 0-9, and the symbols `- . $ / + %` and space. Convert your data to uppercase and remove unsupported characters before encoding.

**Q: Can I retrieve multiple images at once?**
A: Yes — use the Apify API to list all KV store keys and download them programmatically. See the API usage section above for examples. You can also use the Apify CLI: `apify kv get --store-id STORE_ID --key my-barcode.png`.

**Q: The generated PNG looks blurry when printed — what's wrong?**
A: For print use, either use SVG (vector, infinitely scalable) or increase the `width` and `height` values significantly. For 300 DPI printing at 2 inches wide, set width to 600 pixels. For labels, SVG is almost always the better choice.

**Q: How do I download all generated barcodes as a ZIP?**
A: The actor doesn't produce ZIP files directly. Use the Apify API to iterate over KV store keys and download each file. Or use the Apify CLI's batch download feature.

### 🔗 Related actors

- [automation-lab/fake-test-data-generator](https://apify.com/automation-lab/fake-test-data-generator) — Generate fake product data (names, SKUs, prices) to pair with barcode generation
- [automation-lab/unicode-text-inspector](https://apify.com/automation-lab/unicode-text-inspector) — Inspect and clean text before encoding to avoid invalid character errors

# Actor input Schema

## `barcodes` (type: `array`):

List of barcodes to generate. Each item specifies the data, format, and optional settings. Supports EAN-13, Code128, QR codes, and 10+ other formats.

## `outputFormat` (type: `string`):

Default image format for barcodes that don't specify one. Can be overridden per barcode.

## `width` (type: `integer`):

Default image width in pixels for PNG output. SVG scales automatically. Range: 50–2000.

## `height` (type: `integer`):

Default image height in pixels for PNG output. Used for barcode images (not QR codes — those are always square). Range: 50–2000.

## `lineColor` (type: `string`):

Default color for barcode bars / QR modules. Use any CSS color: '#000000', 'black', 'rgb(0,0,0)'.

## `background` (type: `string`):

Default background color. Use 'transparent' for transparent PNG backgrounds (useful for overlays).

## `includeText` (type: `boolean`):

Display the encoded value as text below the barcode (linear barcodes only — QR codes don't have text labels).

## `fontSize` (type: `integer`):

Font size in pixels for the human-readable text below the barcode. Range: 8–72.

## `margin` (type: `integer`):

White space margin around the barcode in pixels. Range: 0–100.

## `qrErrorCorrection` (type: `string`):

QR code error correction: L=7%, M=15%, Q=25%, H=30% data recovery. Higher = more robust but denser.

## Actor input object example

```json
{
  "barcodes": [
    {
      "data": "012345678901",
      "format": "EAN13",
      "outputFormat": "PNG",
      "label": "example-ean13"
    },
    {
      "data": "Hello, World!",
      "format": "CODE128",
      "outputFormat": "PNG",
      "label": "example-code128"
    },
    {
      "data": "https://apify.com",
      "format": "QR",
      "outputFormat": "PNG",
      "label": "example-qr"
    }
  ],
  "outputFormat": "PNG",
  "width": 300,
  "height": 150,
  "lineColor": "#000000",
  "background": "#ffffff",
  "includeText": true,
  "fontSize": 20,
  "margin": 10,
  "qrErrorCorrection": "M"
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "barcodes": [
        {
            "data": "012345678901",
            "format": "EAN13",
            "outputFormat": "PNG",
            "label": "example-ean13"
        },
        {
            "data": "Hello, World!",
            "format": "CODE128",
            "outputFormat": "PNG",
            "label": "example-code128"
        },
        {
            "data": "https://apify.com",
            "format": "QR",
            "outputFormat": "PNG",
            "label": "example-qr"
        }
    ],
    "outputFormat": "PNG",
    "width": 300,
    "height": 150,
    "lineColor": "#000000",
    "background": "#ffffff",
    "includeText": true,
    "fontSize": 20,
    "margin": 10,
    "qrErrorCorrection": "M"
};

// Run the Actor and wait for it to finish
const run = await client.actor("automation-lab/barcode-generator").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "barcodes": [
        {
            "data": "012345678901",
            "format": "EAN13",
            "outputFormat": "PNG",
            "label": "example-ean13",
        },
        {
            "data": "Hello, World!",
            "format": "CODE128",
            "outputFormat": "PNG",
            "label": "example-code128",
        },
        {
            "data": "https://apify.com",
            "format": "QR",
            "outputFormat": "PNG",
            "label": "example-qr",
        },
    ],
    "outputFormat": "PNG",
    "width": 300,
    "height": 150,
    "lineColor": "#000000",
    "background": "#ffffff",
    "includeText": True,
    "fontSize": 20,
    "margin": 10,
    "qrErrorCorrection": "M",
}

# Run the Actor and wait for it to finish
run = client.actor("automation-lab/barcode-generator").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "barcodes": [
    {
      "data": "012345678901",
      "format": "EAN13",
      "outputFormat": "PNG",
      "label": "example-ean13"
    },
    {
      "data": "Hello, World!",
      "format": "CODE128",
      "outputFormat": "PNG",
      "label": "example-code128"
    },
    {
      "data": "https://apify.com",
      "format": "QR",
      "outputFormat": "PNG",
      "label": "example-qr"
    }
  ],
  "outputFormat": "PNG",
  "width": 300,
  "height": 150,
  "lineColor": "#000000",
  "background": "#ffffff",
  "includeText": true,
  "fontSize": 20,
  "margin": 10,
  "qrErrorCorrection": "M"
}' |
apify call automation-lab/barcode-generator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=automation-lab/barcode-generator",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Barcode Generator",
        "description": "Generate EAN-13, Code128, UPC-A, QR codes, and 10+ barcode formats as PNG or SVG images. Batch generation with customizable colors and dimensions.",
        "version": "0.1",
        "x-build-id": "gOSBLx8JcbIMEngQM"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/automation-lab~barcode-generator/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-automation-lab-barcode-generator",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/automation-lab~barcode-generator/runs": {
            "post": {
                "operationId": "runs-sync-automation-lab-barcode-generator",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/automation-lab~barcode-generator/run-sync": {
            "post": {
                "operationId": "run-sync-automation-lab-barcode-generator",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "barcodes"
                ],
                "properties": {
                    "barcodes": {
                        "title": "🏷️ Barcodes to generate",
                        "type": "array",
                        "description": "List of barcodes to generate. Each item specifies the data, format, and optional settings. Supports EAN-13, Code128, QR codes, and 10+ other formats."
                    },
                    "outputFormat": {
                        "title": "📁 Default output format",
                        "enum": [
                            "PNG",
                            "SVG",
                            "BOTH"
                        ],
                        "type": "string",
                        "description": "Default image format for barcodes that don't specify one. Can be overridden per barcode.",
                        "default": "PNG"
                    },
                    "width": {
                        "title": "📐 Default width (px)",
                        "minimum": 50,
                        "maximum": 2000,
                        "type": "integer",
                        "description": "Default image width in pixels for PNG output. SVG scales automatically. Range: 50–2000.",
                        "default": 300
                    },
                    "height": {
                        "title": "📏 Default height (px)",
                        "minimum": 50,
                        "maximum": 2000,
                        "type": "integer",
                        "description": "Default image height in pixels for PNG output. Used for barcode images (not QR codes — those are always square). Range: 50–2000.",
                        "default": 150
                    },
                    "lineColor": {
                        "title": "🎨 Default bar color",
                        "type": "string",
                        "description": "Default color for barcode bars / QR modules. Use any CSS color: '#000000', 'black', 'rgb(0,0,0)'.",
                        "default": "#000000"
                    },
                    "background": {
                        "title": "🖼️ Default background color",
                        "type": "string",
                        "description": "Default background color. Use 'transparent' for transparent PNG backgrounds (useful for overlays).",
                        "default": "#ffffff"
                    },
                    "includeText": {
                        "title": "🔤 Show human-readable text",
                        "type": "boolean",
                        "description": "Display the encoded value as text below the barcode (linear barcodes only — QR codes don't have text labels).",
                        "default": true
                    },
                    "fontSize": {
                        "title": "🔡 Font size",
                        "minimum": 8,
                        "maximum": 72,
                        "type": "integer",
                        "description": "Font size in pixels for the human-readable text below the barcode. Range: 8–72.",
                        "default": 20
                    },
                    "margin": {
                        "title": "📦 Margin (px)",
                        "minimum": 0,
                        "maximum": 100,
                        "type": "integer",
                        "description": "White space margin around the barcode in pixels. Range: 0–100.",
                        "default": 10
                    },
                    "qrErrorCorrection": {
                        "title": "🛡️ QR error correction level",
                        "enum": [
                            "L",
                            "M",
                            "Q",
                            "H"
                        ],
                        "type": "string",
                        "description": "QR code error correction: L=7%, M=15%, Q=25%, H=30% data recovery. Higher = more robust but denser.",
                        "default": "M"
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
