跳至主要内容
REST API 现在已分版本。 有关详细信息,请参阅“关于 API 版本控制”。

里程碑的 REST API 端点

使用 REST API 管理里程碑。

列出里程碑

列出存储库的里程碑。

“列出里程碑”的细粒度访问令牌

此端点适用于以下细粒度令牌类型

细粒度令牌必须至少具有以下权限集之一

  • “问题”存储库权限(读取)
  • “拉取请求”存储库权限(读取)

如果仅请求公共资源,则无需身份验证或上述权限即可使用此端点。

“列出里程碑”的参数

标头
名称、类型、说明
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称、类型、说明
owner 字符串 必需

仓库的帐户所有者。名称不区分大小写。

repo 字符串 必需

不带 .git 扩展名的仓库名称。名称不区分大小写。

查询参数
名称、类型、说明
state 字符串

里程碑的状态。openclosedall

默认: open

可以为: open, closed, all

sort 字符串

按什么对结果进行排序。due_oncompleteness

默认: due_on

可以为: due_on, completeness

direction 字符串

排序的方向。ascdesc

默认: asc

可以为: asc, desc

per_page 整数

每页的结果数(最大 100)。有关详细信息,请参阅“在 REST API 中使用分页”。

默认: 30

page 整数

要获取的结果的页号。有关详细信息,请参阅“在 REST API 中使用分页”。

默认: 1

“列出里程碑”的 HTTP 响应状态代码

状态代码描述
200

OK

404

资源未找到

“列出里程碑”的代码示例

请求示例

get/repos/{owner}/{repo}/milestones
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/milestones

响应

状态:200
[ { "url": "https://api.github.com/repos/octocat/Hello-World/milestones/1", "html_url": "https://github.com/octocat/Hello-World/milestones/v1.0", "labels_url": "https://api.github.com/repos/octocat/Hello-World/milestones/1/labels", "id": 1002604, "node_id": "MDk6TWlsZXN0b25lMTAwMjYwNA==", "number": 1, "state": "open", "title": "v1.0", "description": "跟踪 1.0 版本的里程碑", "creator": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "open_issues": 4, "closed_issues": 8, "created_at": "2011-04-10T20:09:31Z", "updated_at": "2014-03-03T18:58:10Z", "closed_at": "2013-02-12T13:22:01Z", "due_on": "2012-10-09T23:39:01Z" } ]

创建里程碑

创建里程碑。

“创建里程碑”的细粒度访问令牌

此端点适用于以下细粒度令牌类型

细粒度令牌必须至少具有以下权限集之一

  • “问题”存储库权限(写)
  • “拉取请求”存储库权限(写)

“创建里程碑”的参数

标头
名称、类型、说明
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称、类型、说明
owner 字符串 必需

仓库的帐户所有者。名称不区分大小写。

repo 字符串 必需

不带 .git 扩展名的仓库名称。名称不区分大小写。

正文参数
名称、类型、说明
title 字符串 必需

里程碑的标题。

state 字符串

里程碑的状态。openclosed

默认: open

可以是以下之一: open, closed

description 字符串

里程碑的描述。

due_on 字符串

里程碑截止日期。这是 ISO 8601 格式的时间戳:YYYY-MM-DDTHH:MM:SSZ

“创建里程碑”的 HTTP 响应状态代码

状态代码描述
201

已创建

404

资源未找到

422

验证失败,或端点已被标记为垃圾邮件。

“创建里程碑”的代码示例

请求示例

post/repos/{owner}/{repo}/milestones
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/milestones \ -d '{"title":"v1.0","state":"open","description":"跟踪 1.0 版本的里程碑","due_on":"2012-10-09T23:39:01Z"}'

响应

状态:201
{ "url": "https://api.github.com/repos/octocat/Hello-World/milestones/1", "html_url": "https://github.com/octocat/Hello-World/milestones/v1.0", "labels_url": "https://api.github.com/repos/octocat/Hello-World/milestones/1/labels", "id": 1002604, "node_id": "MDk6TWlsZXN0b25lMTAwMjYwNA==", "number": 1, "state": "open", "title": "v1.0", "description": "跟踪 1.0 版本的里程碑", "creator": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "open_issues": 4, "closed_issues": 8, "created_at": "2011-04-10T20:09:31Z", "updated_at": "2014-03-03T18:58:10Z", "closed_at": "2013-02-12T13:22:01Z", "due_on": "2012-10-09T23:39:01Z" }

获取里程碑

使用给定的里程碑编号获取里程碑。

“获取里程碑”的细粒度访问令牌

此端点适用于以下细粒度令牌类型

细粒度令牌必须至少具有以下权限集之一

  • “问题”存储库权限(读取)
  • “拉取请求”存储库权限(读取)

如果仅请求公共资源,则无需身份验证或上述权限即可使用此端点。

“获取里程碑”的参数

标头
名称、类型、说明
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称、类型、说明
owner 字符串 必需

仓库的帐户所有者。名称不区分大小写。

repo 字符串 必需

不带 .git 扩展名的仓库名称。名称不区分大小写。

milestone_number 整数 必需

标识里程碑的编号。

“获取里程碑”的 HTTP 响应状态代码

状态代码描述
200

OK

404

资源未找到

“获取里程碑”的代码示例

请求示例

get/repos/{owner}/{repo}/milestones/{milestone_number}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/milestones/MILESTONE_NUMBER

响应

状态:200
{ "url": "https://api.github.com/repos/octocat/Hello-World/milestones/1", "html_url": "https://github.com/octocat/Hello-World/milestones/v1.0", "labels_url": "https://api.github.com/repos/octocat/Hello-World/milestones/1/labels", "id": 1002604, "node_id": "MDk6TWlsZXN0b25lMTAwMjYwNA==", "number": 1, "state": "open", "title": "v1.0", "description": "跟踪 1.0 版本的里程碑", "creator": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "open_issues": 4, "closed_issues": 8, "created_at": "2011-04-10T20:09:31Z", "updated_at": "2014-03-03T18:58:10Z", "closed_at": "2013-02-12T13:22:01Z", "due_on": "2012-10-09T23:39:01Z" }

更新里程碑

“更新里程碑”的细粒度访问令牌

此端点适用于以下细粒度令牌类型

细粒度令牌必须至少具有以下权限集之一

  • “问题”存储库权限(写)
  • “拉取请求”存储库权限(写)

“更新里程碑”的参数

标头
名称、类型、说明
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称、类型、说明
owner 字符串 必需

仓库的帐户所有者。名称不区分大小写。

repo 字符串 必需

不带 .git 扩展名的仓库名称。名称不区分大小写。

milestone_number 整数 必需

标识里程碑的编号。

正文参数
名称、类型、说明
title 字符串

里程碑的标题。

state 字符串

里程碑的状态。openclosed

默认: open

可以是以下之一: open, closed

description 字符串

里程碑的描述。

due_on 字符串

里程碑截止日期。这是 ISO 8601 格式的时间戳:YYYY-MM-DDTHH:MM:SSZ

“更新里程碑”的 HTTP 响应状态代码

状态代码描述
200

OK

“更新里程碑”的代码示例

请求示例

patch/repos/{owner}/{repo}/milestones/{milestone_number}
curl -L \ -X PATCH \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/milestones/MILESTONE_NUMBER \ -d '{"title":"v1.0","state":"open","description":"跟踪 1.0 版本的里程碑","due_on":"2012-10-09T23:39:01Z"}'

响应

状态:200
{ "url": "https://api.github.com/repos/octocat/Hello-World/milestones/1", "html_url": "https://github.com/octocat/Hello-World/milestones/v1.0", "labels_url": "https://api.github.com/repos/octocat/Hello-World/milestones/1/labels", "id": 1002604, "node_id": "MDk6TWlsZXN0b25lMTAwMjYwNA==", "number": 1, "state": "open", "title": "v1.0", "description": "跟踪 1.0 版本的里程碑", "creator": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "open_issues": 4, "closed_issues": 8, "created_at": "2011-04-10T20:09:31Z", "updated_at": "2014-03-03T18:58:10Z", "closed_at": "2013-02-12T13:22:01Z", "due_on": "2012-10-09T23:39:01Z" }

删除里程碑

使用给定的里程碑编号删除里程碑。

“删除里程碑”的细粒度访问令牌

此端点适用于以下细粒度令牌类型

细粒度令牌必须至少具有以下权限集之一

  • “问题”存储库权限(写)
  • “拉取请求”存储库权限(写)

“删除里程碑”的参数

标头
名称、类型、说明
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称、类型、说明
owner 字符串 必需

仓库的帐户所有者。名称不区分大小写。

repo 字符串 必需

不带 .git 扩展名的仓库名称。名称不区分大小写。

milestone_number 整数 必需

标识里程碑的编号。

“删除里程碑”的 HTTP 响应状态代码

状态代码描述
204

无内容

404

资源未找到

“删除里程碑”的代码示例

请求示例

delete/repos/{owner}/{repo}/milestones/{milestone_number}
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/milestones/MILESTONE_NUMBER

响应

状态:204