เอกสารอ้างอิง 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 จากข้อมูลที่มีโครงสร้าง
ส่งฟิลด์ Application Identifier ของ 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)
);