Add documentation for Mod Releaser project

This commit is contained in:
CPTProgrammer
2026-07-06 04:56:50 +08:00
parent 7dff3d0f3f
commit 346b0783d8
9 changed files with 5749 additions and 0 deletions
+130
View File
@@ -0,0 +1,130 @@
# CurseForge Get Mod Files API
> 来源:https://docs.curseforge.com/rest-api/
>
> API 基础地址:`https://api.curseforge.com`,认证方式:Header `x-api-key: <token>`
---
## Get Mod Files
```
GET https://api.curseforge.com/v1/mods/{modId}/files
```
获取指定项目的所有文件。
### 参数
| 参数 | 位置 | 类型 | 必填 | 说明 |
|------|------|------|------|------|
| `modId` | path | int32 | 是 | 项目 ID |
| `gameVersion` | query | string | 否 | 按游戏版本过滤 |
| `modLoaderType` | query | int | 否 | 按 Mod Loader 类型过滤(见下表) |
| `gameVersionTypeId` | query | int32 | 否 | 按 `gameVersionTypeId` 过滤 |
| `index` | query | int32 | 否 | 分页起始索引(从 0 开始,限制 `index + pageSize <= 10000` |
| `pageSize` | query | int32 | 否 | 每页数量,默认/最大 50 |
**modLoaderType 枚举值:**
| 值 | 含义 |
|----|------|
| 0 | Any |
| 1 | Forge |
| 2 | Cauldron |
| 3 | LiteLoader |
| 4 | Fabric |
| 5 | Quilt |
| 6 | NeoForge |
### 成功响应
```jsonc
{
"data": [
{
"id": 12345, // 文件 ID
"gameId": 432, // 游戏 ID
"modId": 789, // 项目 ID
"isAvailable": true, // 是否可下载
"displayName": "My Mod v1.0", // 显示名称
"fileName": "my-mod-1.0.jar", // 文件名
"releaseType": 1, // 1=Release, 2=Beta, 3=Alpha
"fileStatus": 10, // 文件状态(见附表)
"hashes": [
{ "value": "abc123...", "algo": 1 } // algo: 1=Sha1, 2=Md5
],
"fileDate": "2025-01-01T00:00:00Z", // 文件时间戳
"fileLength": 1048576, // 文件大小(字节)
"downloadCount": 5000, // 下载次数
"fileSizeOnDisk": 1048576, // 磁盘占用
"downloadUrl": "https://...", // 下载地址
"gameVersions": ["1.21.5", "1.21.4"], // 关联的游戏版本(字符串列表)
"sortableGameVersions": [ // 排序用版本信息
{
"gameVersionName": "1.21.5",
"gameVersionPadded": "0000000001.0000000021.0000000005",
"gameVersion": "1.21.5",
"gameVersionReleaseDate": "2025-04-01T00:00:00Z",
"gameVersionTypeId": 83806
}
],
"dependencies": [ // 依赖关系
{
"modId": 123, // 依赖的项目 ID
"relationType": 3 // 关系类型(见附表)
}
],
"exposeAsAlternative": false,
"parentProjectFileId": null,
"alternateFileId": null,
"isServerPack": false,
"serverPackFileId": null,
"isEarlyAccessContent": false,
"earlyAccessEndDate": null,
"fileFingerprint": 1234567890,
"modules": [
{ "name": "main", "fingerprint": 1234567890 }
]
}
],
"pagination": {
"index": 0, // 本次返回的起始索引
"pageSize": 50, // 请求的页大小
"resultCount": 1, // 本次实际返回数量
"totalCount": 10 // 总文件数
}
}
```
---
## 附表
### releaseType
| 值 | 含义 |
|----|------|
| 1 | Release |
| 2 | Beta |
| 3 | Alpha |
### relationType
| 值 | 含义 |
|----|------|
| 1 | EmbeddedLibrary |
| 2 | OptionalDependency |
| 3 | RequiredDependency |
| 4 | Tool |
| 5 | Incompatible |
| 6 | Include |
### fileStatus(常用值)
| 值 | 含义 |
|----|------|
| 1 | Processing |
| 4 | Approved |
| 10 | Released |
| 12 | Deprecated |
+200
View File
@@ -0,0 +1,200 @@
# CurseForge Upload API
> 基于 CurseForge 官方 API 文档及实测整理。
>
> API 基础地址:`https://minecraft.curseforge.com`**必须带浏览器 `User-Agent` 请求头**,否则 Cloudflare 会拦截返回 403。
>
> 推荐 User-Agent`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36`
---
## 生成 Token
在 [API Tokens](https://authors.curseforge.com/account/api-tokens) 页面生成 API Token。
## 认证
通过以下两种方式之一传递 Token:
- HTTP Header`X-Api-Token: <token>`
- Query String`?token=<token>`
---
## Game Version Types API
```
GET https://minecraft.curseforge.com/api/game/version-types
```
> **注意:** 此端点必须带浏览器 `User-Agent` 请求头,否则会被 Cloudflare 拦截返回 403。
>
> 推荐值:`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36`
返回版本类型列表,直接返回 JSON 数组,每个对象包含:
| 字段 | 类型 | 说明 |
|------|------|------|
| `id` | int | 版本类型 ID(即 `gameVersionTypeID` |
| `name` | string | 类型名称 |
| `slug` | string | 类型标识 |
其中 `id: 68441, name: "Modloader"` 对应 Modloader 分类。
`id: 75208, name: "Environment"` 对应运行环境,包含 `name: "Client"``name: "Server"` 两个 Game Version。
## Game Versions API
```
GET https://minecraft.curseforge.com/api/game/versions
```
> **注意:** 此端点必须带浏览器 `User-Agent` 请求头,否则会被 Cloudflare 拦截返回 403。
>
> 推荐值:`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36`
返回 Minecraft 版本列表,直接返回 JSON 数组(无 `{"data": ...}` 包装),每个对象包含:
| 字段 | 类型 | 说明 |
|------|------|------|
| `id` | int | 版本 ID(用于上传时的 `gameVersions` 字段) |
| `gameVersionTypeID` | int | 版本类型 ID |
| `name` | string | 版本名称(如 `1.21.5` |
| `slug` | string | 版本标识(如 `1-21-5` |
| `apiVersion` | int \| null | API 版本号 |
> **注意:** Game Versions 列表并非仅包含游戏版本号,而是将 Mod LoaderForge、Fabric 等)、EnvironmentClient、Server)甚至 Java 版本都混在一起。具体某个版本属于哪个类型,看它的 `gameVersionTypeID`,对应 [Game Version Types API](#game-version-types-api) 中的 `id`。
---
## Project Upload File API
```
POST https://minecraft.curseforge.com/api/projects/{projectId}/upload-file
Content-Type: multipart/form-data
```
上传文件到项目。`projectId` 可在项目概览页面的 URL 中找到。
### 请求字段
| 字段 | 类型 | 说明 |
|------|------|------|
| `metadata` | string (JSON) | 文件元数据(见下方) |
| `file` | file | 要上传的实际文件 |
### metadata JSON 结构
```jsonc
{
"changelog": "更新日志内容", // 必填。支持 HTML / Markdown(需设置 changelogType
"changelogType": "markdown", // 可选,默认 "text"。可选值: "text", "html", "markdown"
"displayName": "Foo", // 可选,站点上显示的文件友好名称
"parentFileID": 42, // 可选,父文件 ID
"gameVersions": [157, 158], // 可选,支持的 Game Version ID 列表(通过 Game Versions API 获取)。若提供 parentFileID 则不支持此字段
"releaseType": "release", // 必填。可选值: "alpha", "beta", "release"
"isMarkedForManualRelease": false, // 可选,若为 true,审核通过后不会立即发布,可手动选择发布时间
"relations": {
"projects": [{
"slug": "mantle", // 关联项目的 slug
"projectID": "74924", // 可选,用于精确匹配项目
"type": "requiredDependency" // 关联类型,可选值见下方
}]
}
}
```
**relations.type 可选值:**
- `embeddedLibrary` — 内嵌库
- `incompatible` — 不兼容
- `optionalDependency` — 可选依赖
- `requiredDependency` — 必需依赖
- `tool` — 工具
### 成功响应
```jsonc
{
"id": 20402 // 新建文件的 ID
}
```
---
## Project File Management API
```
POST https://minecraft.curseforge.com/api/projects/{projectId}/update-file
Content-Type: multipart/form-data
```
更新已上传的文件信息。
### 请求字段
| 字段 | 类型 | 说明 |
|------|------|------|
| `metadata` | string (JSON) | 文件更新元数据(见下方) |
### metadata JSON 结构
```jsonc
{
"fileID": 20402, // 必填,要更新的文件 ID
// 以下字段均为可选,可任意组合,但至少要包含一个
"changelog": "更新日志内容",
"changelogType": "markdown", // 可选值: "text", "html", "markdown",默认 "text"
"displayName": "Foo",
"gameVersions": [157, 158],
"releaseType": "release", // 可选值: "alpha", "beta", "release"
"relations": {
"projects": [{
"slug": "mantle",
"projectID": "74924",
"type": "requiredDependency"
}]
}
}
```
> **注意:** 若未填写任何可选字段,API 将返回失败。
### 成功响应
```jsonc
{
"id": 20402 // 被更新文件的 ID
}
```
---
## Maven
CurseForge 提供 Maven 端点,可在构建脚本中引用依赖。
```
https://www.curseforge.com/api/maven/{projectSlug}/{mavenArtifact}/{mavenVersion}/{projectFileNameArtifact}-{projectFileNameVersion}-{projectFileNameTag}.jar
```
**URL 参数说明:**
| 参数 | 说明 |
|------|------|
| `{projectSlug}` | 项目的 slug |
| `{mavenArtifact}` | 文件名 artifact |
| `{mavenVersion}` | 版本号,或使用 `release` 获取最新版 |
| `{projectFileNameArtifact}` | 同 `mavenArtifact` |
| `{projectFileNameVersion}` | 同 `mavenVersion` |
| `{projectFileNameTag}` | 文件名标签(如 `universal``dev` |
> **注意:** Maven 认证不支持 Header 方式,需将 API Key 直接编入 Maven URL。
---
## 参考链接
- [CurseForge API Tokens](https://authors.curseforge.com/account/api-tokens)
- [官方文档原文](https://support.curseforge.com/support/solutions/articles/9000197321-curseforge-upload-api)