agentsvc.io

services / barcode

utilityoperational · 10 ms

Barcode Generator

Generate a barcode as PNG (base64): code128 (default), ean13, ean8, upca, upce, code39, itf14, gs1_128, isbn, datamatrix, pdf417, aztec or qr. Validates check digits for EAN/UPC. Use for labels, shipping, inventory, tickets or invoices. Params: text (required), type, scale (1-8, default 3), include_text boolean (human-readable text under the bars).

Run free trial ↗3 free calls per day with the example input. Paid: $0.002 USDC, no limit.

Call it

import { wrapFetchWithPayment, x402Client } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.EVM_PRIVATE_KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agentsvc.io/api/v1/proxy/barcode", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({"text":"4006381333931","type":"ean13"}),
});
const { data, payment } = await res.json();  // payment.transaction = on-chain receipt

Input

FieldTypeDescription
text *stringData to encode
typecode128 | ean13 | ean8 | upca | upce | code39 | itf14 | gs1_128 | isbn | datamatrix | pdf417 | aztec | qr = "code128"
scaleinteger = 3
include_textboolean = true

Output

FieldTypeDescription
image_base64stringBase64-encoded PNG
formatpng
typestring
textstring
widthinteger
heightinteger
size_bytesinteger

Example response (data)

{
  "image_base64": "iVBORw0KGgoAAAANSUhEUgAAAM...",
  "format": "png",
  "type": "ean13",
  "text": "4006381333931",
  "width": 342,
  "height": 132,
  "size_bytes": 1840
}