项目(经典版)的 REST API 端点
使用 REST API 在代码库中创建和管理项目(经典版)。
注意
项目(经典版)已被移除。您可以在 GitHub 博客 上阅读有关此更改的更多信息。
新的改进型项目体验现已推出。有关更多信息,请参阅“关于项目”。
这些端点仅与项目(经典版)交互。要管理项目,请使用 GraphQL API。有关更多信息,请参阅“使用 API 管理项目”。
用于管理项目(经典版)的 REST API 仅支持使用个人访问令牌(经典版)进行身份验证。有关更多信息,请参阅“管理您的个人访问令牌”。
列出组织项目
列出组织中的项目。如果组织中禁用了项目,则返回 404 未找到
状态。如果您没有足够的权限执行此操作,则会返回 401 未授权
或 410 已删除
状态。
“列出组织项目”的细粒度访问令牌
此端点适用于以下细粒度令牌类型:
细粒度令牌必须具有以下权限集
- “项目”组织权限(读取)
“列出组织项目”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
org 字符串 必填组织名称。名称不区分大小写。 |
名称、类型、描述 |
---|
state 字符串指示要返回的项目状态。 默认值: 可以是以下之一: |
per_page 整数每页结果数(最大 100)。有关更多信息,请参阅“在 REST API 中使用分页”。 默认值: |
page 整数要提取的结果的页码。有关更多信息,请参阅“在 REST API 中使用分页”。 默认值: |
“列出组织项目”的 HTTP 响应状态代码
状态代码 | 描述 |
---|---|
200 | OK |
422 | 验证失败或端点已被垃圾邮件轰炸。 |
“列出组织项目”的代码示例
请求示例
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/orgs/ORG/projects
响应
状态:200
[ { "owner_url": "https://api.github.com/orgs/octocat", "url": "https://api.github.com/projects/1002605", "html_url": "https://github.com/orgs/api-playground/projects/1", "columns_url": "https://api.github.com/projects/1002605/columns", "id": 1002605, "node_id": "MDc6UHJvamVjdDEwMDI2MDU=", "name": "组织路线图", "body": "未来一年的高级路线图。", "number": 1, "state": "open", "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 }, "created_at": "2011-04-11T20:09:31Z", "updated_at": "2014-03-04T18:58:10Z", "organization_permission": "write", "private": true } ]
创建组织项目
创建组织项目看板。如果组织中禁用了项目或组织没有现有的经典项目,则返回 410 已删除
状态。如果您没有足够的权限执行此操作,则会返回 401 未授权
或 410 已删除
状态。
“创建组织项目”的细粒度访问令牌
此端点适用于以下细粒度令牌类型:
细粒度令牌必须具有以下权限集
- “项目”组织权限(写入)
“创建组织项目”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
org 字符串 必填组织名称。名称不区分大小写。 |
名称、类型、描述 |
---|
name 字符串 必填项目的名称。 |
body 字符串项目的描述。 |
“创建组织项目”的 HTTP 响应状态代码
状态代码 | 描述 |
---|---|
201 | 已创建 |
401 | 需要身份验证 |
403 | 禁止 |
404 | 资源未找到 |
410 | 已删除 |
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/orgs/ORG/projects \ -d '{"name":"Organization Roadmap","body":"High-level roadmap for the upcoming year."}'
响应
状态:201
{ "owner_url": "https://api.github.com/orgs/octocat", "url": "https://api.github.com/projects/1002605", "html_url": "https://github.com/orgs/api-playground/projects/1", "columns_url": "https://api.github.com/projects/1002605/columns", "id": 1002605, "node_id": "MDc6UHJvamVjdDEwMDI2MDU=", "name": "组织路线图", "body": "未来一年的高级路线图。", "number": 1, "state": "open", "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 }, "created_at": "2011-04-11T20:09:31Z", "updated_at": "2014-03-04T18:58:10Z" }
获取项目
通过其 id
获取项目。如果禁用了项目,则返回 404 未找到
状态。如果您没有足够的权限执行此操作,则会返回 401 未授权
或 410 已删除
状态。
“获取项目”的细粒度访问令牌
此端点适用于以下细粒度令牌类型:
细粒度令牌必须至少具有以下权限集之一
- “项目”代码库权限(读取)
- “项目”组织权限(读取)
如果仅请求公共资源,则可以在没有身份验证或上述权限的情况下使用此端点。
“获取项目”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
project_id 整数 必填项目的唯一标识符。 |
“获取项目”的 HTTP 响应状态代码
状态代码 | 描述 |
---|---|
200 | OK |
304 | 未修改 |
401 | 需要身份验证 |
403 | 禁止 |
“获取项目”的代码示例
请求示例
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/projects/PROJECT_ID
响应
状态:200
{ "owner_url": "https://api.github.com/repos/api-playground/projects-test", "url": "https://api.github.com/projects/1002604", "html_url": "https://github.com/api-playground/projects-test/projects/1", "columns_url": "https://api.github.com/projects/1002604/columns", "id": 1002604, "node_id": "MDc6UHJvamVjdDEwMDI2MDQ=", "name": "Projects Documentation", "body": "Developer documentation project for the developer site.", "number": 1, "state": "open", "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 }, "created_at": "2011-04-10T20:09:31Z", "updated_at": "2014-03-03T18:58:10Z" }
更新项目
更新项目看板的信息。如果项目已禁用,则返回404 Not Found
状态。如果您没有足够的权限执行此操作,则会返回401 Unauthorized
或410 Gone
状态。
“更新项目”的细粒度访问令牌
此端点适用于以下细粒度令牌类型:
细粒度令牌必须至少具有以下权限集之一
- “项目”存储库权限(写入)
- “项目”组织权限(写入)
“更新项目”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
project_id 整数 必填项目的唯一标识符。 |
名称、类型、描述 |
---|
name 字符串项目的名称 |
body 字符串或 null项目的正文 |
state 字符串项目的的状态;可以是“open”或“closed” |
organization_permission 字符串所有组织成员对该项目的基线权限 可以是以下之一: |
private 布尔值此项目是否对所有人可见。 |
“更新项目”的HTTP响应状态代码
状态代码 | 描述 |
---|---|
200 | OK |
304 | 未修改 |
401 | 需要身份验证 |
403 | 禁止 |
404 | 如果经过身份验证的用户无权访问该项目,则返回“未找到” |
410 | 已删除 |
422 | 验证失败或端点已被垃圾邮件轰炸。 |
“更新项目”的代码示例
请求示例
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/projects/PROJECT_ID \ -d '{"name":"Week One Sprint","state":"open","organization_permission":"write"}'
响应
状态:200
{ "owner_url": "https://api.github.com/repos/api-playground/projects-test", "url": "https://api.github.com/projects/1002604", "html_url": "https://github.com/api-playground/projects-test/projects/1", "columns_url": "https://api.github.com/projects/1002604/columns", "id": 1002604, "node_id": "MDc6UHJvamVjdDEwMDI2MDQ=", "name": "Projects Documentation", "body": "Developer documentation project for the developer site.", "number": 1, "state": "open", "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 }, "created_at": "2011-04-10T20:09:31Z", "updated_at": "2014-03-03T18:58:10Z" }
删除项目
删除项目看板。如果项目已禁用,则返回404 Not Found
状态。
“删除项目”的细粒度访问令牌
此端点适用于以下细粒度令牌类型:
细粒度令牌必须至少具有以下权限集之一
- “项目”存储库权限(写入)
- “项目”组织权限(写入)
“删除项目”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
project_id 整数 必填项目的唯一标识符。 |
“删除项目”的HTTP响应状态代码
状态代码 | 描述 |
---|---|
204 | 删除成功 |
304 | 未修改 |
401 | 需要身份验证 |
403 | 禁止 |
404 | 资源未找到 |
410 | 已删除 |
“删除项目”的代码示例
请求示例
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/projects/PROJECT_ID
删除成功
状态:204
列出存储库项目
列出存储库中的项目。如果存储库中禁用了项目,则返回404 Not Found
状态。如果您没有足够的权限执行此操作,则会返回401 Unauthorized
或410 Gone
状态。
“列出存储库项目”的细粒度访问令牌
此端点适用于以下细粒度令牌类型:
细粒度令牌必须具有以下权限集
- “项目”代码库权限(读取)
如果仅请求公共资源,则可以在没有身份验证或上述权限的情况下使用此端点。
“列出存储库项目”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
owner 字符串 必需存储库的帐户所有者。名称不区分大小写。 |
repo 字符串 必需存储库的名称,不含 |
名称、类型、描述 |
---|
state 字符串指示要返回的项目状态。 默认值: 可以是以下之一: |
per_page 整数每页结果数(最大 100)。有关更多信息,请参阅“在 REST API 中使用分页”。 默认值: |
page 整数要提取的结果的页码。有关更多信息,请参阅“在 REST API 中使用分页”。 默认值: |
“列出存储库项目”的HTTP响应状态代码
状态代码 | 描述 |
---|---|
200 | OK |
401 | 需要身份验证 |
403 | 禁止 |
404 | 资源未找到 |
410 | 已删除 |
422 | 验证失败或端点已被垃圾邮件轰炸。 |
“列出存储库项目”的代码示例
请求示例
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/projects
响应
状态:200
[ { "owner_url": "https://api.github.com/repos/api-playground/projects-test", "url": "https://api.github.com/projects/1002604", "html_url": "https://github.com/api-playground/projects-test/projects/1", "columns_url": "https://api.github.com/projects/1002604/columns", "id": 1002604, "node_id": "MDc6UHJvamVjdDEwMDI2MDQ=", "name": "Projects Documentation", "body": "Developer documentation project for the developer site.", "number": 1, "state": "open", "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 }, "created_at": "2011-04-10T20:09:31Z", "updated_at": "2014-03-03T18:58:10Z" } ]
创建存储库项目
创建一个存储库项目看板。如果存储库中禁用了项目或存储库没有现有的经典项目,则返回410 Gone
状态。如果您没有足够的权限执行此操作,则会返回401 Unauthorized
或410 Gone
状态。
“创建存储库项目”的细粒度访问令牌
此端点适用于以下细粒度令牌类型:
细粒度令牌必须具有以下权限集
- “项目”存储库权限(写入)
“创建存储库项目”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
owner 字符串 必需存储库的帐户所有者。名称不区分大小写。 |
repo 字符串 必需存储库的名称,不含 |
名称、类型、描述 |
---|
name 字符串 必填项目的名称。 |
body 字符串项目的描述。 |
“创建存储库项目”的HTTP响应状态代码
状态代码 | 描述 |
---|---|
201 | 已创建 |
401 | 需要身份验证 |
403 | 禁止 |
404 | 资源未找到 |
410 | 已删除 |
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/projects \ -d '{"name":"Projects Documentation","body":"Developer documentation project for the developer site."}'
响应
状态:201
{ "owner_url": "https://api.github.com/repos/api-playground/projects-test", "url": "https://api.github.com/projects/1002604", "html_url": "https://github.com/api-playground/projects-test/projects/1", "columns_url": "https://api.github.com/projects/1002604/columns", "id": 1002604, "node_id": "MDc6UHJvamVjdDEwMDI2MDQ=", "name": "Projects Documentation", "body": "Developer documentation project for the developer site.", "number": 1, "state": "open", "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 }, "created_at": "2011-04-10T20:09:31Z", "updated_at": "2014-03-03T18:58:10Z" }
创建用户项目
创建一个用户项目看板。如果用户没有现有的经典项目,则返回410 Gone
状态。如果您没有足够的权限执行此操作,则会返回401 Unauthorized
或410 Gone
状态。
“创建用户项目”的细粒度访问令牌
此端点不适用于GitHub App用户访问令牌、GitHub App安装访问令牌或细粒度个人访问令牌。
“创建用户项目”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
name 字符串 必填项目的名称 |
body 字符串或 null项目的正文 |
“创建用户项目”的HTTP响应状态代码
状态代码 | 描述 |
---|---|
201 | 已创建 |
304 | 未修改 |
401 | 需要身份验证 |
403 | 禁止 |
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/user/projects \ -d '{"name":"My Projects","body":"A board to manage my personal projects."}'
响应
状态:201
{ "owner_url": "https://api.github.com/users/octocat", "url": "https://api.github.com/projects/1002603", "html_url": "https://github.com/users/octocat/projects/1", "columns_url": "https://api.github.com/projects/1002603/columns", "id": 1002603, "node_id": "MDc6UHJvamVjdDEwMDI2MDM=", "name": "My Projects", "body": "A board to manage my personal projects.", "number": 1, "state": "open", "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 }, "created_at": "2011-04-10T20:09:31Z", "updated_at": "2014-03-03T18:58:10Z" }
列出用户项目
列出用户的所有项目。
“列出用户项目”的细粒度访问令牌
此端点不适用于GitHub App用户访问令牌、GitHub App安装访问令牌或细粒度个人访问令牌。
“列出用户项目”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
username 字符串 必需GitHub 用户帐户的用户名。 |
名称、类型、描述 |
---|
state 字符串指示要返回的项目状态。 默认值: 可以是以下之一: |
per_page 整数每页结果数(最大 100)。有关更多信息,请参阅“在 REST API 中使用分页”。 默认值: |
page 整数要提取的结果的页码。有关更多信息,请参阅“在 REST API 中使用分页”。 默认值: |
“列出用户项目”的HTTP响应状态代码
状态代码 | 描述 |
---|---|
200 | OK |
422 | 验证失败或端点已被垃圾邮件轰炸。 |
“列出用户项目”的代码示例
请求示例
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/users/USERNAME/projects
响应
状态:200
[ { "owner_url": "https://api.github.com/users/octocat", "url": "https://api.github.com/projects/1002603", "html_url": "https://github.com/users/octocat/projects/1", "columns_url": "https://api.github.com/projects/1002603/columns", "id": 1002603, "node_id": "MDc6UHJvamVjdDEwMDI2MDM=", "name": "My Projects", "body": "A board to manage my personal projects.", "number": 1, "state": "open", "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 }, "created_at": "2011-04-10T20:09:31Z", "updated_at": "2014-03-03T18:58:10Z" } ]