GS1 2D Code GeneratorAPI & integration

Integrating e-label services

Atomic Systems services send product data as JSON. The generator validates it against GS1 rules, the user sees the finished codes and the files (SVG, PNG, JPG, JSON-LD) can be returned to the source service.

API base URL: https://www.gs1.atomicsystems.pl/api/v1 · Currently enabled fields: name, gtin, production_date (set by the administrator)

Data model (product object)

Field names as in the desktop program and CSV files. Dates always YYYY-MM-DD. Fields disabled by the administrator are dropped (warning fields_disabled). Order in the code is fixed.

FieldAIDescriptionAliases
name—Product name, max 100 chars (not encoded – JSON-LD only)product_name, productName, title
gtin01GTIN-8/12/13/14 with valid check digitgtin14, ean, 01
variant (disabled)22Variant, max 20 CSET 82 chars22, cpv
batch (disabled)10Batch/lot, max 20 CSET 82 charslot, batch_lot, 10
serial (disabled)21Serial, max 20 CSET 82 charsserial_number, sn, 21
order (disabled)400Order number, max 30 charsorder_number, 400
country (disabled)422Country of origin, ISO 3166 numeric (e.g. 616)country_of_origin, origin, 422
production_date11Production date YYYY-MM-DDproductionDate, prod_date, 11
packaging_date (disabled)13Packaging datepackagingDate, pack_date, 13
best_before (disabled)15Best beforebestBefore, bbd, 15
sell_by (disabled)16Sell bysellBy, 16
expiry (disabled)17Expiration dateexpiry_date, expiration_date, expirationDate, use_by
weight (disabled)310nNet weight in kg, up to 5 decimals (e.g. "2.5")net_weight, netWeight, weight_kg
domainDLGS1 Digital Link domain (https://…); default https://id.gs1.org

Full request object

{
  "lang": "pl",                       // kod jednego z 24 języków UE (bg…sv) – język strony generatora
  "reference": "WINE-2025-0042",      // własny identyfikator (wraca w wynikach)
  "return_url": "https://winelabel.atomicsystems.pl/label/42",  // powrót po zapisaniu kodów
  "domain": "https://id.example.com", // opcjonalnie
  "product": {
    "name": "Rioja Reserva 2019",
    "gtin": "5901234123457",
    "production_date": "2025-11-30",
    "batch": "L2025-11"
  },
  "options": {                        // opcjonalnie – nadpisuje ustawienia domyślne
    "kinds": ["gs1_datamatrix", "gs1_qr", "dl_datamatrix", "dl_qr"],
    "formats": ["svg", "png", "jpg"], "write_json": true,
    "ecc": "Q", "module_px": 10,
    "print": false, "module_mm": 0.5, "dpi": 300,
    "hri": true, "hri_position": "below", "hri_scope": "all", "hri_px": 40, "hri_mm": 2.0
  },
  "strict": false                     // true = odrzuć (422), gdy dane są błędne
}

1. Simplest integration – browser form

No server code and no API key. The service must be on the trusted list. The browser posts JSON in the payload field and lands in the generator with the data filled in.

<form method="post" action="https://www.gs1.atomicsystems.pl/api/v1/jobs" target="_blank">
  <input type="hidden" name="payload" id="gs1payload">
  <button>Generuj kody GS1</button>
</form>
<script>
document.getElementById("gs1payload").value = JSON.stringify({
  lang: "pl",
  reference: "WINE-42",
  return_url: location.href,
  product: { name: "Rioja Reserva", gtin: "5901234123457", production_date: "2025-11-30" }
});
</script>

2. API: POST /api/v1/jobs

Server call with an API key, or browser fetch (CORS) from a trusted origin. The response contains the user link and the GS1 validation result.

curl -X POST https://www.gs1.atomicsystems.pl/api/v1/jobs \
  -H "Content-Type: application/json" \
  -H "X-API-Key: gs1k_…" \
  -d '{"reference":"WINE-42","return_url":"https://winelabel.atomicsystems.pl/label/42",
       "product":{"name":"Rioja Reserva","gtin":"5901234123457","production_date":"2025-11-30"}}'
HTTP/1.1 201 Created
{
  "id": "kPfi8ulN66eA-oaeyvWuDw",
  "url": "https://www.gs1.atomicsystems.pl/?job=kPfi8ulN66eA-oaeyvWuDw&lang=pl",
  "expires_at": "…",
  "validation": {
    "ok": true, "errors": {},
    "gtin14": "05901234123457",
    "ai_string": "(01)05901234123457(11)251130",
    "element_string": "010590123412345711251130",
    "hri": ["(01) 05901234123457", "(11) 251130"],
    "digital_link": "https://id.gs1.org/01/05901234123457?11=251130",
    "jsonld": { … }, "base_name": "05901234123457_1c6f90ed"
  },
  "warnings": [],
  "result_url": "https://www.gs1.atomicsystems.pl/api/v1/jobs/kPfi8ulN66eA-oaeyvWuDw/result"
}

PHP

$ch = curl_init("https://www.gs1.atomicsystems.pl/api/v1/jobs");
curl_setopt_array($ch, [
  CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => ["Content-Type: application/json", "X-API-Key: " . GS1_API_KEY],
  CURLOPT_POSTFIELDS => json_encode(["reference" => $labelId, "return_url" => $backUrl, "product" => $product]),
]);
$job = json_decode(curl_exec($ch), true);
header("Location: " . $job["url"]);   // użytkownik przechodzi do generatora

3. Getting the generated files

With return_url the user gets a “Save codes and return” button. Files are stored and the browser returns to return_url with a gs1_job parameter. Fetch the results with the API key:

GET https://www.gs1.atomicsystems.pl/api/v1/jobs/{id}/result            → JSON: job, summary, files[] (name, mime, kind, size, sha256, data base64, url)
GET https://www.gs1.atomicsystems.pl/api/v1/jobs/{id}/result?include=meta → bez danych plików
GET https://www.gs1.atomicsystems.pl/api/v1/jobs/{id}/files/{name}        → pojedynczy plik (np. …_gs1_datamatrix.svg)
DELETE https://www.gs1.atomicsystems.pl/api/v1/jobs/{id}                  → usunięcie zlecenia

File names as in the program: {GTIN-14}_{serial or batch}_{hash}_{kind}.{ext}. Jobs expire after 7 days.

Open the job url with window.open or in an iframe with &embed=1. On click, the generator posts the files back to the opener/parent – only to the origin that created the job:

const w = window.open(job.url + "&embed=1", "gs1", "width=1200,height=900");
window.addEventListener("message", (e) => {
  if (e.origin !== "https://www.gs1.atomicsystems.pl" || e.data?.type !== "gs1-2d-codes") return;
  // e.data.summary: ai_string, hri, digital_link, gtin14, product
  // e.data.files: [{ name, kind, encoding: "base64", data }]
});

POST /api/v1/validate

Validation only – 200 when valid, 422 with field errors.

POST /api/v1/validate
{"lang":"pl","product":{"name":"Rioja","gtin":"5901234123458","production_date":"2025-02-30"}}

422 → {"validation":{"ok":false,"errors":{
  "gtin":"Błędna cyfra kontrolna GTIN (powinna być 7)",
  "production_date":"Taka data nie istnieje w kalendarzu"}, …}}

Data link (?data=)

For small payloads without server storage: Base64URL-encoded UTF-8 JSON in the data parameter.

const data = btoa(String.fromCharCode(...new TextEncoder().encode(JSON.stringify({product:{name:"Rioja",gtin:"5901234123457"}}))))
  .replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");
location.href = "https://www.gs1.atomicsystems.pl/?data=" + data;

Endpoint reference

EndpointAccess
GET/api/v1/healthpublic
GET/api/v1/config – fields, domain, defaultspublic
POST/api/v1/validatepublic (rate limited)
POST/api/v1/jobsAPI key or trusted origin
GET/api/v1/jobs/{id}knowledge of id
GET/api/v1/jobs/{id}/result, /files/{name}API key
DELETE/api/v1/jobs/{id}API key

Key: X-API-Key or Authorization: Bearer header (created in the admin panel). Errors: JSON {"error","message"}.