跳转到内容
开发者文档 / 资源接口

创建资源

为当前开发者凭证所属用户创建资源。作者 memberId 由服务端写入,不能通过请求体代替其他用户创建。

POST/api/resources

鉴权方式 请求头 Api-Key、Api-Secret

Content-Type application/json

请求体

参数类型必填说明
resourceTypeIdinteger是资源类型 ID
namestring是资源名称
englishNamestring否英文名称
identifystring否资源唯一标识,使用字母、数字 1–9、-、_
languagestring否资源语言
descriptionstring是简短介绍
textstring否Markdown 长介绍
customTagsstring[]否自定义标签数组
tagsinteger[]否平台标签 ID 数组
settingobject否展示、下载与讨论设置
metaobject否来源、许可、开源和反馈信息

setting 可包含 view、original、hasServer、enablePost、enableRewardDownload、loginDownload。meta 可包含 source、sourceUrl、videoUrl、recommendConfig、license、openSourceUrl、issueUrl。

bash
curl -X POST 'https://resource-api.xyeidc.com/api/resources' \
  -H 'Api-Key: YOUR_API_KEY' \
  -H 'Api-Secret: YOUR_API_SECRET' \
  -H 'Content-Type: application/json' \
  -d '{
    "resourceTypeId": 4,
    "name": "Example Mod",
    "englishName": "Example Mod",
    "identify": "example-mod",
    "language": "zh-CN",
    "description": "一个精简的示例资源",
    "text": "## 介绍\n这是资源详情。",
    "customTags": ["冒险", "实用"],
    "tags": [16, 17],
    "setting": {
      "view": true,
      "original": true,
      "hasServer": false,
      "enablePost": true,
      "enableRewardDownload": false,
      "loginDownload": true
    },
    "meta": {
      "source": "原创",
      "license": "MIT",
      "openSourceUrl": "https://github.com/example/example-mod",
      "issueUrl": "https://github.com/example/example-mod/issues"
    }
  }'

响应示例

json
{
  "code": 200,
  "msg": "Success!",
  "data": {
    "id": 42,
    "resourceTypeId": 4,
    "memberId": 10001,
    "name": "Example Mod",
    "identify": "example-mod",
    "description": "一个精简的示例资源"
  }
}

verified、archived 和部分推荐设置受管理员权限控制,普通开发者不应依赖在创建请求中修改这些字段。