Skip to main content
REST API 现已经过版本控制。 有关详细信息,请参阅“关于 API 版本控制”。

Projects (classic) 的 REST API 终结点

使用 REST API 在存储库中创建和管理 项目(经典)。

注意:

  • 这些终结点仅与 projects (classic) 交互。 若要管理 Projects,请使用 GraphQL API。 有关详细信息,请参阅“使用 API 管理 Projects”。
  • 若要创建新的 项目(经典),组织、用户或存储库必须至少有一个 项目(经典)。

用于管理 projects (classic) 的 REST API 仅支持使用 personal access token (classic) 进行身份验证。 有关详细信息,请参阅“管理个人访问令牌”。

List organization projects

Lists the projects in an organization. Returns a 404 Not Found status if projects are disabled in the organization. If you do not have sufficient privileges to perform this action, a 401 Unauthorized or 410 Gone status is returned.

“List organization projects”的细粒度访问令牌

此终结点适用于以下令牌类型:

令牌必须具有以下权限集:

  • organization_projects:read

“List organization projects”的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
org string 必须

The organization name. The name is not case sensitive.

查询参数
名称, 类型, 说明
state string

Indicates the state of the projects to return.

默认: open

可以是以下选项之一: open, closed, all

per_page integer

The number of results per page (max 100). For more information, see "Using pagination in the REST API."

默认: 30

page integer

The page number of the results to fetch. For more information, see "Using pagination in the REST API."

默认: 1

“List organization projects”的 HTTP 响应状态代码

状态代码说明
200

OK

422

Validation failed, or the endpoint has been spammed.

“List organization projects”的示例代码

请求示例

get/orgs/{org}/projects
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

Response

Status: 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": "Organization Roadmap", "body": "High-level roadmap for the upcoming year.", "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 } ]

Create an organization project

Creates an organization project board. Returns a 410 Gone status if projects are disabled in the organization or if the organization does not have existing classic projects. If you do not have sufficient privileges to perform this action, a 401 Unauthorized or 410 Gone status is returned.

“Create an organization project”的细粒度访问令牌

此终结点适用于以下令牌类型:

令牌必须具有以下权限集:

  • organization_projects:write

“Create an organization project”的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
org string 必须

The organization name. The name is not case sensitive.

正文参数
名称, 类型, 说明
name string 必须

The name of the project.

body string

The description of the project.

“Create an organization project”的 HTTP 响应状态代码

状态代码说明
201

Created

401

Requires authentication

403

Forbidden

404

Resource not found

410

Gone

422

Validation failed, or the endpoint has been spammed.

“Create an organization project”的示例代码

请求示例

post/orgs/{org}/projects
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."}'

Response

Status: 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": "Organization Roadmap", "body": "High-level roadmap for the upcoming year.", "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" }

Get a project

Gets a project by its id. Returns a 404 Not Found status if projects are disabled. If you do not have sufficient privileges to perform this action, a 401 Unauthorized or 410 Gone status is returned.

“Get a project”的细粒度访问令牌

此终结点适用于以下令牌类型:

令牌必须至少具有以下权限集之一:

  • repository_projects:read
  • organization_projects:read

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

“Get a project”的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
project_id integer 必须

The unique identifier of the project.

“Get a project”的 HTTP 响应状态代码

状态代码说明
200

OK

304

Not modified

401

Requires authentication

403

Forbidden

“Get a project”的示例代码

请求示例

get/projects/{project_id}
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

Response

Status: 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" }

Update a project

Updates a project board's information. Returns a 404 Not Found status if projects are disabled. If you do not have sufficient privileges to perform this action, a 401 Unauthorized or 410 Gone status is returned.

“Update a project”的细粒度访问令牌

此终结点适用于以下令牌类型:

令牌必须至少具有以下权限集之一:

  • repository_projects:write
  • organization_projects:write

“Update a project”的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
project_id integer 必须

The unique identifier of the project.

正文参数
名称, 类型, 说明
name string

Name of the project

body string or null

Body of the project

state string

State of the project; either 'open' or 'closed'

organization_permission string

The baseline permission that all organization members have on this project

可以是以下选项之一: read, write, admin, none

private boolean

Whether or not this project can be seen by everyone.

“Update a project”的 HTTP 响应状态代码

状态代码说明
200

OK

304

Not modified

401

Requires authentication

403

Forbidden

404

Not Found if the authenticated user does not have access to the project

410

Gone

422

Validation failed, or the endpoint has been spammed.

“Update a project”的示例代码

请求示例

patch/projects/{project_id}
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"}'

Response

Status: 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" }

Delete a project

Deletes a project board. Returns a 404 Not Found status if projects are disabled.

“Delete a project”的细粒度访问令牌

此终结点适用于以下令牌类型:

令牌必须至少具有以下权限集之一:

  • repository_projects:write
  • organization_projects:write

“Delete a project”的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
project_id integer 必须

The unique identifier of the project.

“Delete a project”的 HTTP 响应状态代码

状态代码说明
204

Delete Success

304

Not modified

401

Requires authentication

403

Forbidden

404

Resource not found

410

Gone

“Delete a project”的示例代码

请求示例

delete/projects/{project_id}
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

Delete Success

Status: 204

List repository projects

Lists the projects in a repository. Returns a 404 Not Found status if projects are disabled in the repository. If you do not have sufficient privileges to perform this action, a 401 Unauthorized or 410 Gone status is returned.

“List repository projects”的细粒度访问令牌

此终结点适用于以下令牌类型:

令牌必须具有以下权限集:

  • repository_projects:read

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

“List repository projects”的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
owner string 必须

The account owner of the repository. The name is not case sensitive.

repo string 必须

The name of the repository without the .git extension. The name is not case sensitive.

查询参数
名称, 类型, 说明
state string

Indicates the state of the projects to return.

默认: open

可以是以下选项之一: open, closed, all

per_page integer

The number of results per page (max 100). For more information, see "Using pagination in the REST API."

默认: 30

page integer

The page number of the results to fetch. For more information, see "Using pagination in the REST API."

默认: 1

“List repository projects”的 HTTP 响应状态代码

状态代码说明
200

OK

401

Requires authentication

403

Forbidden

404

Resource not found

410

Gone

422

Validation failed, or the endpoint has been spammed.

“List repository projects”的示例代码

请求示例

get/repos/{owner}/{repo}/projects
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

Response

Status: 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" } ]

Create a repository project

Creates a repository project board. Returns a 410 Gone status if projects are disabled in the repository or if the repository does not have existing classic projects. If you do not have sufficient privileges to perform this action, a 401 Unauthorized or 410 Gone status is returned.

“Create a repository project”的细粒度访问令牌

此终结点适用于以下令牌类型:

令牌必须具有以下权限集:

  • repository_projects:write

“Create a repository project”的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
owner string 必须

The account owner of the repository. The name is not case sensitive.

repo string 必须

The name of the repository without the .git extension. The name is not case sensitive.

正文参数
名称, 类型, 说明
name string 必须

The name of the project.

body string

The description of the project.

“Create a repository project”的 HTTP 响应状态代码

状态代码说明
201

Created

401

Requires authentication

403

Forbidden

404

Resource not found

410

Gone

422

Validation failed, or the endpoint has been spammed.

“Create a repository project”的示例代码

请求示例

post/repos/{owner}/{repo}/projects
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."}'

Response

Status: 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" }

Create a user project

Creates a user project board. Returns a 410 Gone status if the user does not have existing classic projects. If you do not have sufficient privileges to perform this action, a 401 Unauthorized or 410 Gone status is returned.

“Create a user project”的细粒度访问令牌

此终结点不适用于 GitHub 应用程序用户访问令牌、GitHub 应用程序安装访问令牌或细粒度个人访问令牌。

“Create a user project”的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

正文参数
名称, 类型, 说明
name string 必须

Name of the project

body string or null

Body of the project

“Create a user project”的 HTTP 响应状态代码

状态代码说明
201

Created

304

Not modified

401

Requires authentication

403

Forbidden

422

Validation failed, or the endpoint has been spammed.

“Create a user project”的示例代码

请求示例

post/user/projects
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."}'

Response

Status: 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" }

List user projects

Lists projects for a user.

“List user projects”的细粒度访问令牌

此终结点不适用于 GitHub 应用程序用户访问令牌、GitHub 应用程序安装访问令牌或细粒度个人访问令牌。

“List user projects”的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
username string 必须

The handle for the GitHub user account.

查询参数
名称, 类型, 说明
state string

Indicates the state of the projects to return.

默认: open

可以是以下选项之一: open, closed, all

per_page integer

The number of results per page (max 100). For more information, see "Using pagination in the REST API."

默认: 30

page integer

The page number of the results to fetch. For more information, see "Using pagination in the REST API."

默认: 1

“List user projects”的 HTTP 响应状态代码

状态代码说明
200

OK

422

Validation failed, or the endpoint has been spammed.

“List user projects”的示例代码

请求示例

get/users/{username}/projects
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

Response

Status: 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" } ]