API 文档

MCResource 提供完整的 RESTful API,方便您在自己的应用或服务器面板中集成资源搜索和下载功能。

GET /api/search.php

搜索资源,支持关键词、分类、类型、版本等筛选条件。

请求参数

参数 类型 必填 说明
keyword string 搜索关键词
category string 分类: mods, plugins, datapacks, maps, others
type string 类型: forge, fabric, paper, spigot, sponge, folia
version string Minecraft版本,如: 1.20.1
tag string 标签筛选
sort string 排序: time(最新), downloads(下载量), name(名称)
page int 页码,默认1
limit int 每页数量,默认20,最大100

响应示例

{ "success": true, "data": { "resources": [ { "id": 1, "name": "示例插件", "category": "plugins", "type": "paper", "download_count": 100, "versions": ["1.20.1", "1.20.2"], "tags": ["经济", "生存"] } ], "pagination": { "total": 100, "page": 1, "total_pages": 5, "limit": 20 } } }
GET /api/resource.php

获取单个资源的详细信息。

请求参数

参数 类型 必填 说明
id int 资源ID
GET /api/download.php

下载资源,支持直接下载和服务器面板集成。

请求参数

参数 类型 必填 说明
id int 资源ID
server string 服务器面板地址,用于远程下载
direct bool 直接下载文件
callback string JSONP回调函数名

服务器面板集成响应

{ "success": true, "data": { "resource_id": 1, "resource_name": "示例插件", "file_name": "plugin.jar", "file_size": 1024000, "file_hash": "md5_hash", "download_url": "https://...", "redirect_url": "http://panel.com/mcresource/download?..." } }
GET /api/categories.php

获取所有资源分类及其支持的类型。

GET /api/versions.php

获取支持的Minecraft版本列表。

错误处理

当API请求发生错误时,会返回以下格式的响应:

{ "success": false, "error": "Error Type", "message": "Detailed error message" }

HTTP状态码

状态码 说明
200 请求成功
400 请求参数错误
404 资源不存在
405 请求方法不允许
500 服务器内部错误