# GTIN / Barcode API (`caulleonard/gtin-api`) Actor

Validate, generate, and convert EAN, UPC, GTIN and ISBN barcodes via a simple HTTP API.

- **URL**: https://apify.com/caulleonard/gtin-api.md
- **Developed by:** [Fatih Şahinbaş](https://apify.com/caulleonard) (community)
- **Categories:** E-commerce, Developer tools
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 api calls

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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

## GTIN / Barcode API — Validate, Generate & Convert EAN, UPC and ISBN

A fast HTTP API for **barcode validation** and **check digit calculation**. Verify EAN-13, EAN-8, UPC-A, UPC-E, GTIN-14, ISBN-13 and ISBN-10 codes, generate valid barcodes, and convert between formats — all through simple GET requests.

Catch bad product codes before they hit your catalog, your ERP, or your marketplace feed.

### What it does

- ✅ **Validate any barcode** — automatic format detection plus check-digit verification, with clear error messages.
- 🔢 **Calculate check digits** — give it a code without the last digit and get the complete, valid barcode back.
- 🎲 **Generate valid barcodes** — for testing, seeding databases, or reserving internal codes. Pin a GS1 country/company prefix if you need one.
- 🔄 **Convert between formats** — UPC-A ↔ EAN-13, UPC-E ↔ UPC-A, ISBN-10 ↔ ISBN-13, and EAN-13/UPC-A → GTIN-14.

### Supported formats

| Format | Length | Used for |
|--------|--------|----------|
| **EAN-13** | 13 | Global retail standard |
| **EAN-8** | 8 | Small packaging |
| **UPC-A** | 12 | North American retail |
| **UPC-E** | 8 | Zero-suppressed UPC-A |
| **GTIN-14** | 14 | Cases, cartons, ITF-14 |
| **ISBN-13** | 13 | Books (978/979 prefix) |
| **ISBN-10** | 10 | Legacy books (mod-11, `X` check digit) |

### Who it's for

E-commerce teams validating supplier catalogs, ERP and PIM integrators cleaning product master data, marketplace sellers preparing feeds for Amazon/eBay/Trendyol, and developers building product-entry forms that shouldn't accept broken codes. Also useful for publishers and libraries handling ISBN migrations.

### Endpoints

All endpoints are **GET** and return JSON.

| Endpoint | Purpose | Key params |
|----------|---------|------------|
| `/validate` | Validate and detect format | `code`, `format` (optional hint) |
| `/checkdigit` | Compute the missing check digit | `partial`, `format` (optional) |
| `/generate` | Create a valid barcode | `format`, `prefix` (optional) |
| `/convert` | Convert between formats | `code`, `to`, `src` (optional hint) |

Spaces and hyphens in input are ignored, so `978-0-306-40615-7` works exactly like `9780306406157`.

### Examples

**Validate**

```
GET /validate?code=978-0-306-40615-7
```

```json
{
  "valid": true,
  "format": "isbn13",
  "normalized": "9780306406157",
  "checkDigit": "7",
  "errors": []
}
```

**Catch a bad code**

```
GET /validate?code=4006381333930
```

```json
{
  "valid": false,
  "format": "ean13",
  "normalized": "4006381333930",
  "checkDigit": "1",
  "errors": ["check digit mismatch (expected 1)"]
}
```

**Check digit**

```
GET /checkdigit?partial=400638133393
```

```json
{ "format": "ean13", "partial": "400638133393", "checkDigit": "1", "full": "4006381333931" }
```

**Generate with a GS1 prefix**

```
GET /generate?format=ean13&prefix=869
```

```json
{ "format": "ean13", "code": "8698780044561", "checkDigit": "1" }
```

**Convert ISBN-10 to ISBN-13**

```
GET /convert?code=0306406152&to=isbn13
```

```json
{ "from": "isbn10", "to": "isbn13", "code": "9780306406157" }
```

### How it works

The API runs in **Standby mode** — send HTTP requests directly, no run to start. Validation uses the GS1 modulo-10 algorithm for the whole GTIN family and modulo-11 for ISBN-10 (including the `X` check character). UPC-E conversion implements the standard GS1 zero-suppression rules in both directions, so expand-then-compress round-trips cleanly.

### Tips

- Eight-digit codes are ambiguous between EAN-8 and UPC-E. Pass `format=upce` (on `/validate`) or `src=upce` (on `/convert`) to disambiguate.
- Only `978`-prefixed ISBN-13 codes can be converted back to ISBN-10; `979` codes have no ISBN-10 equivalent.
- Only UPC-A codes with number system `0` or `1` can be compressed to UPC-E, and not all of them qualify.
- Use `/generate` with a prefix to create realistic test data that still matches your GS1 range.

### Pricing

Pay-per-event: **$0.001 per successful API call**. Readiness/health checks are never charged. No subscription, no minimums.

# Actor input Schema

## Actor input object example

```json
{}
```

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("caulleonard/gtin-api").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("caulleonard/gtin-api").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 '{}' |
apify call caulleonard/gtin-api --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/5zyeFi1rKBoP5g7yi/builds/r2oLvFyLMiMWRh65C/openapi.json
