無限制。無浮水印。無需註冊。 立即試用

API 參考

透過程式碼產生 Code 128 與 GS1 條碼。簡單易用的 REST API,提供 JSON 回應與圖片下載。

Free:100 次請求/天 Business:50,000 次請求/月

快速入門

curl "https://www.barcode-code128.com/api/barcode/render?value=HELLO-WORLD&format=PNG&resolution=300" --output barcode.png

端點

GET /api/barcode/render 下載條碼圖片
參數類型預設值說明
valuestring—必填。 要編碼的條碼內容。
symbologystringCode128AutoCode128Auto, Code128A, Code128B, Code128C, GS1_128, GS1_DataMatrix, GS1_QR
formatstringPNGPNG, SVG, PDF, EPS
resolutionint300DPI: 150, 300, 600, 1200
xDimensiondecimal0.33條碼模組寬度(mm)
barHeightdecimal25.4條碼高度(mm)
showTextbooltrue在條碼下方顯示供人閱讀的文字
foregroundColorstring#000000條碼線條顏色(hex)
backgroundColorstring#FFFFFF背景顏色(hex)
barWidthReductiondecimal0列印補償(mm)
POST /api/barcode/batch 產生多個條碼並封裝為 ZIP

傳送包含值陣列的 JSON 內容。傳回的 ZIP 檔案中,每個值各有一個條碼。

{
  "values": ["SKU-001", "SKU-002", "SKU-003"],
  "symbology": "Code128Auto",
  "format": "PNG",
  "resolution": 300
}
POST /api/gs1/render 從結構化資料產生 GS1 條碼

傳送 GS1 應用識別碼欄位。API 會自動處理編碼、FNC1 分隔符號及檢查碼。

{
  "fields": [
    { "ai": "01", "value": "05412345000013" },
    { "ai": "10", "value": "LOT-A23" },
    { "ai": "17", "value": "260731" }
  ],
  "symbology": "GS1_128",
  "format": "PNG",
  "resolution": 300
}
GET /api/barcode/quota 查看您目前的用量
{ "usedToday": 3, "dailyLimit": 5, "remaining": 2, "tier": "Free" }

試驗場

即時體驗 API——無需註冊。


                

程式碼範例

cURL
curl "https://www.barcode-code128.com\
/api/barcode/render\
?value=SKU-4711\
&format=PNG\
&resolution=300" \
  --output barcode.png
Python
import requests

resp = requests.get(
    "https://www.barcode-code128.com"
    "/api/barcode/render",
    params={
        "value": "SKU-4711",
        "format": "PNG",
        "resolution": 300
    }
)

with open("barcode.png", "wb") as f:
    f.write(resp.content)
Node.js
const fs = require('fs');

const url = new URL(
  "https://www.barcode-code128.com"
  + "/api/barcode/render"
);
url.searchParams.set("value", "SKU-4711");
url.searchParams.set("format", "PNG");
url.searchParams.set("resolution", "300");

const resp = await fetch(url);
const buf = await resp.arrayBuffer();
fs.writeFileSync(
  "barcode.png",
  Buffer.from(buf)
);