铁锈工坊 API 文档
这里提供了铁锈工坊的API接口文档,帮助开发者了解和使用我们的服务。
GET
获取模组列表
/api/mods
获取模组列表,支持分页、排序和搜索
请求参数
参数名 | 类型 | 必填 | 默认值 | 描述 |
---|---|---|---|---|
page | number | 可选 | 1 | 页码 |
size | number | 可选 | 10 | 每页数量 (max:30) |
order | string | 可选 | desc | 排序方向 (asc/desc) |
sort | string | 可选 | downloads | 排序字段 (downloads/views/rate/last_update_time) |
search | string | 可选 | - | 搜索关键词 |
响应
{
"mods": [
{
"id": 1,
"img": "https://example.com/image.jpg",
"title": "Example Mod",
"title_cn": "示例模组",
"author": "Author Name",
"downloads": 1234,
"views": 5678,
"rate": 5
}
],
"total": 100,
"hasNext": true,
"hasPrev": false,
"currentPage": 1,
"pageSize": 10,
"totalPage": 10
}
示例代码
fetch('https://apirw.d5v.cc/api/mods?page=1&size=10&order=desc&sort=downloads')
.then(response => response.json())
.then(data => console.log(data));
GET
获取模组详情
/api/mod/info
获取特定模组的详细信息
请求参数
参数名 | 类型 | 必填 | 默认值 | 描述 |
---|---|---|---|---|
id | string | 必填 | - | 模组ID |
响应
{
"mod": {
"id": 1,
"origin_id": 12345,
"platform": "steam",
"img": "https://example.com/image.jpg",
"title": "Example Mod",
"title_cn": "示例模组",
"author": "Author Name",
"author_url": "https://example.com/author",
"content": "Mod description in English",
"content_cn": "模组中文描述",
"create_time": "2023-01-01T00:00:00Z",
"last_update_time": "2023-01-02T00:00:00Z",
"downloads": 1234,
"views": 5678,
"rate": 5,
"modTags": ["tag1", "tag2"],
"modImages": ["https://example.com/image1.jpg", "https://example.com/image2.jpg"]
}
}
示例代码
fetch('https://apirw.d5v.cc/api/mod/info?id=1')
.then(response => response.json())
.then(data => console.log(data));
GET
获取模组下载链接
/api/mod/download
获取模组的下载链接,需要验证会话ID
请求参数
参数名 | 类型 | 必填 | 默认值 | 描述 |
---|---|---|---|---|
id | number | 必填 | - | 模组ID |
ssid | string | 必填 | - | 会话ID |
响应
{
"url": "https://example.com/download/mod.rwmod",
"error": null
}
示例代码
fetch('https://apirw.d5v.cc/api/mod/download?id=1&ssid=YOUR_SESSION_ID')
.then(response => response.json())
.then(data => {
if (data.error === null) {
window.location.href = data.url;
} else {
console.error(data.error);
}
});
POST
发表评论
/api/mod/comment
为特定模组发表评论
请求体
{
"mod_id": 1,
"author": "User Name",
"content": "This is a comment"
}
响应
{
"success": true,
"message": "Comment posted successfully"
}
示例代码
fetch('https://apirw.d5v.cc/api/mod/comment', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
mod_id: 1,
author: 'User Name',
content: 'This is a comment'
})
})
.then(response => response.json())
.then(data => console.log(data));
GET
获取评论列表
/api/mod/comments
获取特定模组的评论列表
请求参数
参数名 | 类型 | 必填 | 默认值 | 描述 |
---|---|---|---|---|
id | number | 必填 | - | 模组ID |
响应
{
"comments": [
{
"id": 1,
"mod_id": 1,
"author": "User Name",
"content": "This is a comment",
"avatar": "https://example.com/avatar.jpg",
"create_time": "2023-01-01T00:00:00Z"
}
]
}
示例代码
fetch('https://apirw.d5v.cc/api/mod/comments?id=1')
.then(response => response.json())
.then(data => console.log(data));
GET
系统健康检查
/api/system/ping
检查API服务是否正常运行
响应
{
"message": "pong"
}
示例代码
fetch('https://apirw.d5v.cc/api/system/ping')
.then(response => response.json())
.then(data => console.log(data));