API 概述

NexusTools 提供 RESTful API 接口,允许第三方应用访问工具数据。 所有 API 请求需要通过 API 密钥进行认证。

Base URL: https://tool.leleweb.cn/api/v1

认证方式

在请求头中添加 X-API-Key 或在 URL 参数中添加 api_key

# Header 方式(推荐) curl -H "X-API-Key: your_api_key" \ https://tool.leleweb.cn/api/v1/tools # Query 参数方式 curl "https://tool.leleweb.cn/api/v1/tools?api_key=your_api_key"

请求方式

API 支持两种请求方式,推荐使用 Query 参数方式(兼容性更好):

# 方式1: Query 参数(推荐) GET /api/index.php?action=tools GET /api/index.php?action=tool&slug=json-formatter GET /api/index.php?action=search&q=json GET /api/index.php?action=categories GET /api/index.php?action=category&id=1 GET /api/index.php?action=stats GET /api/index.php?action=miniapp&type=ads # 方式2: RESTful 风格(需要服务器支持 URL 重写) GET /api/v1/tools GET /api/v1/tools/json-formatter GET /api/v1/tools/search?q=json GET /api/v1/categories GET /api/v1/categories/1 GET /api/v1/stats GET /api/v1/miniapp/ads

工具接口

GET ?action=tools 或 /v1/tools
获取工具列表,支持分页和分类筛选
参数类型说明
pageint页码,默认 1
limitint每页数量,默认 20,最大 100
category_idint分类ID,筛选指定分类
{ "success": true, "data": { "data": [ { "id": 1, "name": "JSON格式化", "slug": "json-formatter", ... } ], "pagination": { "page": 1, "limit": 20, "total": 96, "total_pages": 5 } } }
GET ?action=tool&slug={slug} 或 /v1/tools/{slug}
获取单个工具详情
参数类型说明
slug *string工具别名或ID
GET ?action=search&q={keyword} 或 /v1/tools/search
搜索工具(此接口不强制要求认证)
参数类型说明
q *string搜索关键词
limitint返回数量,默认 20,最大 50

分类接口

GET ?action=categories 或 /v1/categories
获取所有分类列表
GET ?action=category&id={id} 或 /v1/categories/{id}
获取分类详情及其下的工具列表

统计接口

GET ?action=stats 或 /v1/stats
获取网站统计数据,包括工具数、分类数、访问量、热门工具等

小程序接口

GET ?action=miniapp&type=ads 或 /v1/miniapp/ads
获取小程序广告配置(此接口不强制要求认证),包括 Banner、插屏、激励视频、原生广告、解锁功能等
{ "success": true, "data": { "banner": { "unit_id": "adunit-xxx", "enabled": true, "position": "bottom" }, "interstitial": { "unit_id": "adunit-xxx", "enabled": false, "interval": 3 }, "rewarded": { "unit_id": "adunit-xxx", "enabled": false }, "native": { "unit_id": "adunit-xxx", "enabled": false } } }

错误码

状态码说明
200请求成功
400请求参数错误
401未认证或密钥无效
403没有访问权限
404资源不存在
429请求频率超限
500服务器内部错误
{ "success": false, "error": { "code": 401, "message": "无效的API密钥" } }

频率限制

每个 API 密钥都有独立的频率限制(默认 1000 次/小时)。 超出限制后将返回 429 错误,请合理控制请求频率。