API 接口

BestNav 的工具箱开放 API(Pro):50+ 工具引擎变成 REST 接口,供脚本与 CI 自动化调用。

X-API-Key 鉴权

在「工具箱 → API 网关」中创建 Key(仅创始账号可管理)。网关不走 Web 登录态,请求只需携带 X-API-Key 头:

Bashcurl -X POST -H "X-API-Key: bn_xxxxxxxx" \ -F "file=@report.pdf" \ https://你的域名/api/v1/tools/pdf/compress

Key 以哈希存储、恒定时间比对;连续鉴权失败的来源 IP 会被自动临时封禁。

每把 Key 独立管控

  • 按能力范围勾选开放的工具(支持通配符,如 pdf.*)
  • 可叠加来源 IP 白名单与每日调用配额
  • 每分钟限流默认 60 次(灰度阶段不可调高)
  • 任务与结果按 Key 归属隔离,可随时禁用 / 设过期 / 删除

端点总览

网关与界面工具箱共用同一引擎,路径前缀 /api/v1/tools/:PDF 14 个、图片 14 个、文本 4 个、开发者 12 个、OCR 2 个、文档转换 2 个、AI 图像 4 个;AI 系列为异步任务,配套任务状态查询、SSE 进度流、取消与下载接口。

BashPOST /api/v1/tools/pdf/merge # 合并 PDF POST /api/v1/tools/image/compress # 压缩图片 POST /api/v1/tools/text/hash # 哈希计算 GET /api/v1/tools/task/:id # 查询异步任务

内置文档

系统自带对外文档页(/api/v1/tools/docs)与完整可运行实例页(/api/v1/tools/examples,可下载单文件示例直接分享给同事);CORS 跨域来源可配置。

X-API-Key Auth

Create keys in Toolbox → API Gateway (founder account only). The gateway bypasses web sessions — requests only carry an X-API-Key header:

Bashcurl -X POST -H "X-API-Key: bn_xxxxxxxx" \ -F "file=@report.pdf" \ https://your-domain/api/v1/tools/pdf/compress

Keys are stored as hashes with constant-time comparison; source IPs with repeated auth failures are temporarily banned.

Per-key Control

  • Scope allowed tools per key (wildcards supported, e.g. pdf.*)
  • Optional source-IP allowlists and daily quotas
  • Rate limit defaults to 60 req/min per key
  • Tasks and results are isolated per key; disable, expire or delete anytime

Endpoint Matrix

The gateway shares the exact engines of the UI toolbox under /api/v1/tools/: 14 PDF, 14 image, 4 text, 12 dev, 2 OCR, 2 conversion and 4 AI imaging endpoints; the AI series runs async with task status, SSE progress stream, cancel and download.

BashPOST /api/v1/tools/pdf/merge # merge PDFs POST /api/v1/tools/image/compress # compress image POST /api/v1/tools/text/hash # hash text GET /api/v1/tools/task/:id # poll async task

Built-in Docs

A built-in docs page (/api/v1/tools/docs) and a runnable examples page (/api/v1/tools/examples, downloadable as a single HTML file) ship with the gateway; CORS origins are configurable.