里程碑的 REST API 端点
使用 REST API 管理里程碑。
列出里程碑
列出某个代码库的里程碑。
“列出里程碑”的细粒度访问令牌
此端点可以使用以下细粒度令牌类型:
细粒度令牌必须至少具有以下权限集之一
- “问题”代码库权限(读取)
- “拉取请求”代码库权限(读取)
如果仅请求公共资源,则无需身份验证或上述权限即可使用此端点。
“列出里程碑”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
owner 字符串 必填代码库的帐户所有者。名称不区分大小写。 |
repo 字符串 必填不带 |
名称、类型、描述 |
---|
state 字符串里程碑的状态。可以是 默认值: 可以是: |
sort 字符串排序结果的依据。可以是 默认值: 可以是: |
direction 字符串排序的方向。可以是 默认值: 可以是: |
per_page 整数每页的结果数(最大 100)。更多信息,请参阅“REST API 中的分页使用”。 默认值: |
page 整数要获取的结果的页码。更多信息,请参阅“REST API 中的分页使用”。 默认值: |
“列出里程碑”的 HTTP 响应状态码
状态码 | 描述 |
---|---|
200 | OK |
404 | 资源未找到 |
“列出里程碑”的代码示例
请求示例
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": "Tracking milestone for version 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 字符串建议设置为 |
名称、类型、描述 |
---|
owner 字符串 必填代码库的帐户所有者。名称不区分大小写。 |
repo 字符串 必填不带 |
名称、类型、描述 |
---|
title 字符串 必填里程碑的标题。 |
state 字符串里程碑的状态。可以是 默认值: 可以是: |
description 字符串里程碑的描述。 |
due_on 字符串里程碑的截止日期。这是 ISO 8601 格式的时间戳: |
“创建里程碑”的 HTTP 响应状态码
状态码 | 描述 |
---|---|
201 | 已创建 |
404 | 资源未找到 |
422 | 验证失败,或端点已被垃圾信息滥用。 |
“创建里程碑”的代码示例
请求示例
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":"Tracking milestone for version 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": "Tracking milestone for version 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 字符串建议设置为 |
名称、类型、描述 |
---|
owner 字符串 必填代码库的帐户所有者。名称不区分大小写。 |
repo 字符串 必填不带 |
milestone_number 整数 必填标识里程碑的编号。 |
获取里程碑的HTTP响应状态码
状态码 | 描述 |
---|---|
200 | OK |
404 | 资源未找到 |
获取里程碑的代码示例
请求示例
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": "Tracking milestone for version 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 字符串建议设置为 |
名称、类型、描述 |
---|
owner 字符串 必填代码库的帐户所有者。名称不区分大小写。 |
repo 字符串 必填不带 |
milestone_number 整数 必填标识里程碑的编号。 |
名称、类型、描述 |
---|
title 字符串里程碑的标题。 |
state 字符串里程碑的状态。可以是 默认值: 可以是: |
description 字符串里程碑的描述。 |
due_on 字符串里程碑的截止日期。这是 ISO 8601 格式的时间戳: |
更新里程碑的HTTP响应状态码
状态码 | 描述 |
---|---|
200 | OK |
更新里程碑的代码示例
请求示例
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":"Tracking milestone for version 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": "Tracking milestone for version 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 字符串建议设置为 |
名称、类型、描述 |
---|
owner 字符串 必填代码库的帐户所有者。名称不区分大小写。 |
repo 字符串 必填不带 |
milestone_number 整数 必填标识里程碑的编号。 |
删除里程碑的HTTP响应状态码
状态码 | 描述 |
---|---|
204 | 无内容 |
404 | 资源未找到 |
删除里程碑的代码示例
请求示例
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