← All posts

2026-08-21

Automate Barcode Label Printing with LPSNG API

Automate Barcode Label Printing with LPSNG API
pdf labels barcodes label merge browser based graphical layout editor google sheets addin microsoft excel addon electronic shelf labels esl

Automate Barcode Label Printing with LPSNG API

If your team is still exporting order data, opening a label template, pasting SKUs, and clicking Print once per package, the bottleneck is not the printer. It is the manual middle step between your data and the label. The LPSNG Web Service API removes that step: you submit print jobs programmatically, render single labels as PDF or PNG for preview, and send jobs directly to thermal or standard printers.

This guide covers the practical pieces: one-time OAuth2 setup, a basic automated pipeline, failure handling, and the practices that keep a label automation system reliable as volume grows.

One-Time Setup: Connecting Your Application to LPSNG

Before you can send a single label, you need to connect your application to LPSNG. LPSNG uses a simplified OAuth2 registration protocol for external systems. Instead of a long manual developer-app dance, the connection is set up with a single registration URL.

The flow works like this:

  1. Initiate the OAuth2 registration between your application and LPSNG.
  2. Approve the connection.
  3. Store the returned credentials in your integration environment.
  4. Use those credentials to request bearer tokens for API calls.

The same single-URL registration model is used for external systems such as ESL base stations, so once your team has wired it once, the pattern is repeatable across other integrations.

Where you point the API depends on your deployment. The hosted multi-user cloud edition and the embedded edition both expose the web service interface. If you need an offline or high-volume command-line path, the LPSNG Player is a standalone print engine that takes package and data input and produces PDF, PNG, JSON, print, or ESL output.

For non-developers or spreadsheet-heavy processes, the Google Sheets Add-on and the Excel Interface are useful no-code routes. If you are automating from a spreadsheet rather than from code, see How to Print Labels from Google Sheets with LPSNG before building a custom API client.

Keep your integration credentials out of source control:

# .env — store in your secret manager or CI/CD secret store
LPSNG_BASE_URL=https://<your-lpsng-instance>
LPSNG_CLIENT_ID=<from-oauth2-registration>
LPSNG_CLIENT_SECRET=<from-oauth2-registration>

Building the Automated Pipeline: From Data to Printed Label

The core loop is simple: your order, inventory, or shipping system has records. You package those records into a job payload and submit it to the LPSNG Web Service API. LPSNG renders the labels using the templates you have designed, and the result is either a print job on a configured printer or a rendered file.

That gives you three useful patterns:

  • Print directly: submit the job and let LPSNG send it to the target printer.
  • Render for approval: generate a single label as PDF or PNG for preview, email attachment, or archival.
  • Print and archive: combine both paths so the physical label is printed and a PNG/PDF proof is stored in your system.

A minimal Python integration can look like this. The endpoint paths and payload fields are intentionally conceptual here — use the Web Service API guide for the exact request shapes.

import os
import requests

LPSNG_BASE_URL = os.environ["LPSNG_BASE_URL"]

def get_token():
    # Exchange OAuth2 registration credentials for a bearer token.
    # See the OAuth2 guide for the exact request and response fields.
    ...

def render_label_preview(template_id: str, record: dict, output_format: str = "png"):
    token = get_token()
    response = requests.post(
        f"{LPSNG_BASE_URL}/<render-endpoint>",  # exact path in Web Service API guide
        headers={"Authorization": f"Bearer {token}"},
        json={
            "template_id": template_id,
            "data": record,
            "format": output_format,
        },
        timeout=30,
    )
    response.raise_for_status()
    return response.content

def submit_print_job(template_id: str, records: list[dict]):
    token = get_token()
    response = requests.post(
        f"{LPSNG_BASE_URL}/<jobs-endpoint>",
        headers={"Authorization": f"Bearer {token}"},
        json={
            "template_id": template_id,
            "records": records,
        },
        timeout=30,
    )
    response.raise_for_status()
    return response.json()

Your job payload should carry only the variable data your label template needs. Keep the template responsible for layout, barcode formatting, and static content.

For dynamic label content, LPSNG includes a Python Field Script API. You can attach Python script blocks to label fields so they can access and modify field values before printing. This is useful for formatting, cleaning input data, or applying conditional logic directly inside the label instead of building all of that logic into your application.

# Conceptual field script attached to a barcode or text field.
if record.get("country_code") == "DE":
    value = value.strip().upper()

The same automation mindset extends beyond paper labels. For electronic shelf labels, LPSNG provides a vendor-neutral JSON file interface called ESLSEND and an ESL Binding API. If your project includes digital price tags, see What Are Electronic Shelf Labels and How Do They Work? for the broader context.

Monitoring and Failure Handling

A reliable automation pipeline does not treat a submitted job as a printed job. After you submit a print request, track the job until it reaches a terminal state.

The LPSNG web UI includes a job queue, which gives operators a manual oversight point. That queue is useful for spotting failed jobs, checking why a label did not print, and reprinting without re-submitting the original data.

In your integration code, build a small status poll:

import time

def wait_until_terminal(job_reference: str, timeout: int = 120):
    deadline = time.time() + timeout
    while time.time() < deadline:
        state = get_job_state(job_reference)  # from API or job queue
        if state in ("printed", "completed", "failed"):
            return state
        time.sleep(2)
    raise TimeoutError(
        f"Job {job_reference} did not reach a terminal state in {timeout}s"
    )

For retries, be conservative after network timeouts. A timeout does not tell you whether the job was accepted. Before resubmitting, query the job queue for your previous attempt. If you can attach a client-generated job reference, keep it stable across retries so a duplicate submission is detectable.

In production, log at least these fields:

  • job reference or API-returned ID
  • template ID
  • record identifiers, such as order number or SKU
  • printer or output route
  • HTTP status and error body

Then alert on failed jobs rather than only on service-level errors. A label that fails silently is worse than a service that reports an exception.

Best Practices for Label Automation

  • Design templates around variable data placeholders. The more you keep layout, barcode type, and static branding in the template, the less application code you need to change later.
  • Use the Python Field Script API for label-level transformations. Formatting a barcode, trimming input, or conditionally changing text belongs in the label script when it is label-specific.
  • Use the Excel Interface for lookup tables and data validation. If your application already depends on spreadsheets for product data, mapping, or validation, LPSNG can use Excel files as data files and lookup files.
  • Consider the Embedded Edition for on-premise or low-latency environments. It provides complete LPSNG on a single-board computer such as a Raspberry Pi, which is useful when labels must print even if cloud connectivity is interrupted.
  • Look at the White Label Solution for OEM or reseller builds. If label printing is embedded in a larger product, the white label edition is designed for printer manufacturers, paper manufacturers, and system integrators.

Within the Next Generation Label Printing System label studio, reusable templates are the key to long-term maintainability. A good rule of thumb: if two labels differ only in data, they should be one template.

FAQ

What authentication method does the LPSNG API use?

LPSNG uses OAuth2 with a simplified registration protocol. You register your application via a single URL and receive credentials to authenticate API calls.

Can I render label previews without printing?

Yes, the Web Service API can render single labels as PDF or PNG files. Those files can be used for previews, email attachments, or archival.

Does the API support all barcode formats?

LPSNG supports a wide range of 1D and 2D barcode formats. Refer to the Barcode Formats documentation for the complete list.

Is there an offline or on-premise option for automation?

Yes, the LPSNG Player is a standalone command-line print engine that can run locally, and the Embedded Edition provides a complete LPSNG installation on a single-board computer like a Raspberry Pi.

Conclusion: Start Automating Today

API-driven label printing removes the manual copying, pasting, and clicking that causes slow fulfillment and mislabeled shipments. With the LPSNG Web Service API, the same data that drives your order or inventory system can produce printed labels, PDF previews, and electronic shelf label updates without a person in the middle.

Start small: pick one label type, connect one application, and run it in parallel with your existing process until you trust the output. The managed Next Generation Label Printing System gives you the cloud edition and the standalone player to evaluate the workflow without building an entire print room first.

For implementation details, start with the Web Service API documentation and the OAuth2 guide.

Related posts

EU label: AI-generated content