GET
图片处理
条形码生成
生成 Code128 条形码,支持一维码下方显示文字。
累计调用 23
今日调用 0
更新于 2026-10-16
调用地址
GET
https://itapi.top/api/barcode
请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| text | string | 必填 | 条形码内容(可见 ASCII,≤40 位) | 暂无 |
| code | string | 可选 | 条码内容(与 text 二选一) | 暂无 |
| unit | int | 可选 | 每根条宽度,默认 2 | 暂无 |
| height | int | 可选 | 条高,默认 80 | 600 |
| text_show | int | 可选 | 传 0 不显示下方文字 | 测试文本 |
| font | string | 可选 | 文字字体名(默认内置字体) | 测试文本 |
| img | int | 可选 | 传 1 直接输出 PNG | 1 |
| raw | string | 可选 | img 的别名,传 1 效果相同 | 1 |
返回字段
| 字段名 | 类型 | 说明 |
|---|---|---|
| code | int | 状态码 |
| data.image | string | data URI(可直接放 img src) |
| data.format | string | 图片格式 |
| data.width | int | 图片宽 |
| data.height | int | 图片高 |
响应示例
200 OK
{"code":200,"msg":"success","data":{"text":"ITAPI2026","type":"Code128","width":420,"height":122,"image":"data:image/png;base64,iVBOR...","format":"png"}}
在线测试
代码示例
cURL · GET
curl "https://itapi.top/api/barcode?text=%E6%9A%82%E6%97%A0&code=%E6%9A%82%E6%97%A0&unit=%E6%9A%82%E6%97%A0&height=600&text_show=%E6%B5%8B%E8%AF%95%E6%96%87%E6%9C%AC&font=%E6%B5%8B%E8%AF%95%E6%96%87%E6%9C%AC&img=1&raw=1"
PHP
<?php
$res = file_get_contents("https://itapi.top/api/barcode?text=%E6%9A%82%E6%97%A0&code=%E6%9A%82%E6%97%A0&unit=%E6%9A%82%E6%97%A0&height=600&text_show=%E6%B5%8B%E8%AF%95%E6%96%87%E6%9C%AC&font=%E6%B5%8B%E8%AF%95%E6%96%87%E6%9C%AC&img=1&raw=1");
$json = json_decode($res, true);
print_r($json);
JavaScript
const res = await fetch("https://itapi.top/api/barcode?text=%E6%9A%82%E6%97%A0&code=%E6%9A%82%E6%97%A0&unit=%E6%9A%82%E6%97%A0&height=600&text_show=%E6%B5%8B%E8%AF%95%E6%96%87%E6%9C%AC&font=%E6%B5%8B%E8%AF%95%E6%96%87%E6%9C%AC&img=1&raw=1");
const json = await res.json();
console.log(json);
Python
import requests
r = requests.get("https://itapi.top/api/barcode?text=%E6%9A%82%E6%97%A0&code=%E6%9A%82%E6%97%A0&unit=%E6%9A%82%E6%97%A0&height=600&text_show=%E6%B5%8B%E8%AF%95%E6%96%87%E6%9C%AC&font=%E6%B5%8B%E8%AF%95%E6%96%87%E6%9C%AC&img=1&raw=1", timeout=10)
print(r.json())