API-reference
Generér Code 128- og GS1-stregkoder programmatisk via et simpelt REST-API med JSON-svar og download af billeder.
Free: 100 API-foresp./dag
Business: 50.000 API-foresp./md.
Hurtigstart
curl"https://www.barcode-code128.com/api/barcode/render?value=HELLO-WORLD&format=PNG&resolution=300"--outputbarcode.png
Endpoints
GET
/api/barcode/render
Download et stregkodebillede
| Parameter | Type | Standard | Beskrivelse |
|---|---|---|---|
| value | string | — | Påkrævet. Stregkodens indhold, der skal kodes. |
| 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 | Stregmodulets bredde i mm |
| barHeight | decimal | 25.4 | Stregens højde i mm |
| showText | bool | true | Vis læsbar tekst under stregkoden |
| foregroundColor | string | #000000 | Stregfarve (hex) |
| backgroundColor | string | #FFFFFF | Baggrundsfarve (hex) |
| barWidthReduction | decimal | 0 | Trykkorrektion i mm |
POST
/api/barcode/batch
Generér flere stregkoder som ZIP
Send et JSON-body med et array af værdier. Returnerer en ZIP-fil med én stregkode pr. værdi.
{
"values": ["SKU-001", "SKU-002", "SKU-003"],
"symbology": "Code128Auto",
"format": "PNG",
"resolution": 300
}
POST
/api/gs1/render
Generér en GS1-stregkode fra strukturerede data
Send felter med GS1-applikationsidentifikatorer. API'et håndterer kodning, FNC1-separatorer og kontrolcifre.
{
"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
Kontrollér Deres aktuelle forbrug
{ "usedToday": 3, "dailyLimit": 5, "remaining": 2, "tier": "Free" }
Playground
Prøv API'et live – ingen tilmelding påkrævet.
progress_activity
api
Send en forespørgsel for at se resultatet her.
Kodeeksempler
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)
);