Skip to content

Python Quickstart

The one-line version, for reference:

Terminal window
curl -X POST "https://api.labelzoom.com/api/v2/convert/zpl/to/pdf" -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: text/plain" -d '^XA^FO50,50^ADN,36,20^FDLabelZoom^FS^XZ' --output label.pdf

The same conversion with requests:

import os
import requests
zpl = "^XA^FO50,50^ADN,36,20^FDLabelZoom^FS^XZ"
# The API key is optional — omit the Authorization header if it isn't set.
headers = {"Content-Type": "text/plain"}
api_key = os.environ.get("LABELZOOM_API_KEY")
if api_key:
headers["Authorization"] = f"Bearer {api_key}"
response = requests.post(
"https://api.labelzoom.com/api/v2/convert/zpl/to/pdf",
params={"label.width": 4, "label.height": 6, "dpi": 203},
headers=headers,
data=zpl,
)
response.raise_for_status()
with open("label.pdf", "wb") as f:
f.write(response.content)
print("Wrote label.pdf")
with open("shipping-label.pdf", "rb") as f:
pdf_bytes = f.read()
headers = {"Content-Type": "application/pdf"}
api_key = os.environ.get("LABELZOOM_API_KEY")
if api_key:
headers["Authorization"] = f"Bearer {api_key}"
response = requests.post(
"https://api.labelzoom.com/api/v2/convert/pdf/to/zpl",
headers=headers,
data=pdf_bytes,
)
response.raise_for_status()
zpl = response.text

Reuse a requests.Session() for connection pooling when converting many labels, and see rate limits for per-plan throughput. All endpoint patterns and parameters: quickstart · Swagger reference.