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"--outputbarcode.png
端點
GET
/api/barcode/render
下載條碼圖片
| 參數 | 類型 | 預設值 | 說明 |
|---|---|---|---|
| value | string | — | 必填。 要編碼的條碼內容。 |
| symbology | string | Code128Auto | Code128Auto, Code128A, Code128B, Code128C, GS1_128, GS1_DataMatrix, GS1_QR |
| format | string | PNG | PNG, SVG, PDF, EPS |
| resolution | int | 300 | DPI: 150, 300, 600, 1200 |
| xDimension | decimal | 0.33 | 條碼模組寬度(mm) |
| barHeight | decimal | 25.4 | 條碼高度(mm) |
| showText | bool | true | 在條碼下方顯示供人閱讀的文字 |
| foregroundColor | string | #000000 | 條碼線條顏色(hex) |
| backgroundColor | string | #FFFFFF | 背景顏色(hex) |
| barWidthReduction | decimal | 0 | 列印補償(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——無需註冊。
progress_activity
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)
);