团队的 REST API 端点
使用 REST API 在您的 GitHub 组织中创建和管理团队。
关于团队
这些端点仅对团队的已认证成员可用组织。OAuth 访问令牌需要read:org
范围。GitHub 从团队的name
生成团队的slug
。
在接受pull
和push
权限的地方,这些权限将映射到组织代码库的**读取**和**写入**角色。有关代码库角色的更多信息,请参阅“组织的代码库角色”。
列出团队
列出已认证用户可见的组织中的所有团队。
“列出团队”的细粒度访问令牌
此端点适用于以下细粒度令牌类型:
细粒度令牌必须具有以下权限集
- “成员”组织权限(读取)
“列出团队”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
名称、类型、描述 |
---|
per_page 整数每页结果数(最大 100)。更多信息,请参阅“在 REST API 中使用分页”。 默认值: |
page 整数要获取的结果的页码。更多信息,请参阅“在 REST API 中使用分页”。 默认值: |
“列出团队”的 HTTP 响应状态代码
状态码 | 描述 |
---|---|
200 | OK |
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/orgs/ORG/teams
响应
状态:200
[ { "id": 1, "node_id": "MDQ6VGVhbTE=", "url": "https://api.github.com/teams/1", "html_url": "https://github.com/orgs/github/teams/justice-league", "name": "Justice League", "slug": "justice-league", "description": "A great team.", "privacy": "closed", "notification_setting": "notifications_enabled", "permission": "admin", "members_url": "https://api.github.com/teams/1/members{/member}", "repositories_url": "https://api.github.com/teams/1/repos", "parent": null } ]
创建团队
要创建团队,已认证用户必须是{org}
的成员或所有者。默认情况下,组织成员可以创建团队。组织所有者可以将团队创建限制为组织所有者。更多信息,请参阅“设置组织中的团队创建权限”。
创建新团队时,您会自动成为团队维护者,而无需显式地将自己添加到maintainers
的可选项数组中。更多信息,请参阅“关于团队”。
“创建团队”的细粒度访问令牌
此端点适用于以下细粒度令牌类型:
细粒度令牌必须具有以下权限集
- “成员”组织权限(写入)
“创建团队”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
名称、类型、描述 |
---|
name 字符串 必需团队的名称。 |
description 字符串团队的描述。 |
maintainers 字符串数组将成为团队维护者的组织成员的 GitHub ID 列表。 |
repo_names 字符串数组要将团队添加到其中的代码库的全名(例如,“组织名称/代码库名称”)。 |
privacy 字符串此团队应具有的隐私级别。选项包括:
可以是其中之一: |
notification_setting 字符串团队选择的通知设置。选项包括:
可以是其中之一: |
permission 字符串**停用通知**。未指定权限时,将向团队添加新代码库的权限。 默认值: 可以是其中之一: |
parent_team_id 整数设置为父团队的团队 ID。 |
“创建团队”的 HTTP 响应状态代码
状态码 | 描述 |
---|---|
201 | 已创建 |
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/orgs/ORG/teams \ -d '{"name":"Justice League","description":"A great team","permission":"push","notification_setting":"notifications_enabled","privacy":"closed"}'
响应
状态:201
{ "id": 1, "node_id": "MDQ6VGVhbTE=", "url": "https://api.github.com/teams/1", "html_url": "https://github.com/orgs/github/teams/justice-league", "name": "Justice League", "slug": "justice-league", "description": "A great team.", "privacy": "closed", "notification_setting": "notifications_enabled", "permission": "admin", "members_url": "https://api.github.com/teams/1/members{/member}", "repositories_url": "https://api.github.com/teams/1/repos", "parent": null, "members_count": 3, "repos_count": 10, "created_at": "2017-07-14T16:53:42Z", "updated_at": "2017-08-17T12:37:15Z", "organization": { "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization", "name": "github", "company": "GitHub", "blog": "https://github.com/blog", "location": "San Francisco", "email": "octocat@github.com", "is_verified": true, "has_organization_projects": true, "has_repository_projects": true, "public_repos": 2, "public_gists": 1, "followers": 20, "following": 0, "html_url": "https://github.com/octocat", "created_at": "2008-01-14T04:33:35Z", "updated_at": "2017-08-17T12:37:15Z", "type": "Organization" } }
按名称获取团队
使用团队的slug
获取团队。为了创建slug
,GitHub 会替换name
字符串中的特殊字符,将所有单词转换为小写,并将空格替换为-
分隔符。例如,"My TEam Näme"
将变为my-team-name
。
注意
您也可以使用路由GET /organizations/{org_id}/team/{team_id}
通过org_id
和team_id
指定团队。
“按名称获取团队”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
team_slug 字符串 必填团队名称的slug。 |
“按名称获取团队”的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/orgs/ORG/teams/TEAM_SLUG
响应
状态:200
{ "id": 1, "node_id": "MDQ6VGVhbTE=", "url": "https://api.github.com/teams/1", "html_url": "https://github.com/orgs/github/teams/justice-league", "name": "Justice League", "slug": "justice-league", "description": "A great team.", "privacy": "closed", "notification_setting": "notifications_enabled", "permission": "admin", "members_url": "https://api.github.com/teams/1/members{/member}", "repositories_url": "https://api.github.com/teams/1/repos", "parent": null, "members_count": 3, "repos_count": 10, "created_at": "2017-07-14T16:53:42Z", "updated_at": "2017-08-17T12:37:15Z", "organization": { "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization", "name": "github", "company": "GitHub", "blog": "https://github.com/blog", "location": "San Francisco", "email": "octocat@github.com", "is_verified": true, "has_organization_projects": true, "has_repository_projects": true, "public_repos": 2, "public_gists": 1, "followers": 20, "following": 0, "html_url": "https://github.com/octocat", "created_at": "2008-01-14T04:33:35Z", "updated_at": "2017-08-17T12:37:15Z", "type": "Organization" } }
更新团队
要编辑团队,经过身份验证的用户必须是组织所有者或团队维护者。
注意
您也可以使用路由PATCH /organizations/{org_id}/team/{team_id}
通过org_id
和team_id
指定团队。
“更新团队”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
team_slug 字符串 必填团队名称的slug。 |
名称、类型、描述 |
---|
name 字符串团队的名称。 |
description 字符串团队的描述。 |
privacy 字符串此团队应具有的隐私级别。编辑团队时不指定此参数会保留
可以是其中之一: |
notification_setting 字符串团队选择的通知设置。编辑团队时不指定此参数会保留
可以是其中之一: |
permission 字符串**停用通知**。未指定权限时,将向团队添加新代码库的权限。 默认值: 可以是以下之一: |
parent_team_id 整数或null设置为父团队的团队 ID。 |
“更新团队”的HTTP响应状态码
状态码 | 描述 |
---|---|
200 | 更新的信息已存在时的响应 |
201 | 已创建 |
403 | 禁止 |
404 | 资源未找到 |
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/orgs/ORG/teams/TEAM_SLUG \ -d '{"name":"new team name","description":"new team description","privacy":"closed","notification_setting":"notifications_enabled"}'
更新的信息已存在时的响应
状态:200
{ "id": 1, "node_id": "MDQ6VGVhbTE=", "url": "https://api.github.com/teams/1", "html_url": "https://github.com/orgs/github/teams/justice-league", "name": "Justice League", "slug": "justice-league", "description": "A great team.", "privacy": "closed", "notification_setting": "notifications_enabled", "permission": "admin", "members_url": "https://api.github.com/teams/1/members{/member}", "repositories_url": "https://api.github.com/teams/1/repos", "parent": null, "members_count": 3, "repos_count": 10, "created_at": "2017-07-14T16:53:42Z", "updated_at": "2017-08-17T12:37:15Z", "organization": { "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization", "name": "github", "company": "GitHub", "blog": "https://github.com/blog", "location": "San Francisco", "email": "octocat@github.com", "is_verified": true, "has_organization_projects": true, "has_repository_projects": true, "public_repos": 2, "public_gists": 1, "followers": 20, "following": 0, "html_url": "https://github.com/octocat", "created_at": "2008-01-14T04:33:35Z", "updated_at": "2017-08-17T12:37:15Z", "type": "Organization" } }
删除团队
要删除团队,经过身份验证的用户必须是组织所有者或团队维护者。
如果您是组织所有者,删除父团队也将删除其所有子团队。
注意
您也可以使用路由DELETE /organizations/{org_id}/team/{team_id}
通过org_id
和team_id
指定团队。
“删除团队”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
team_slug 字符串 必填团队名称的slug。 |
“删除团队”的HTTP响应状态码
状态码 | 描述 |
---|---|
204 | 无内容 |
“删除团队”的代码示例
请求示例
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/orgs/ORG/teams/TEAM_SLUG
响应
状态:204
列出团队项目
列出团队的组织项目。
注意
您也可以使用路由GET /organizations/{org_id}/team/{team_id}/projects
通过org_id
和team_id
指定团队。
“列出团队项目”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
team_slug 字符串 必填团队名称的slug。 |
名称、类型、描述 |
---|
per_page 整数每页结果数(最大 100)。更多信息,请参阅“在 REST API 中使用分页”。 默认值: |
page 整数要获取的结果的页码。更多信息,请参阅“在 REST API 中使用分页”。 默认值: |
“列出团队项目”的HTTP响应状态码
状态码 | 描述 |
---|---|
200 | OK |
“列出团队项目”的代码示例
请求示例
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/teams/TEAM_SLUG/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": "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": false, "permissions": { "read": true, "write": true, "admin": false } } ]
检查团队对项目的权限
检查团队是否对组织项目具有read
、write
或admin
权限。响应包括从父团队继承的项目。
注意
您也可以使用路由GET /organizations/{org_id}/team/{team_id}/projects/{project_id}
通过org_id
和team_id
指定团队。
“检查团队对项目的权限”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
team_slug 字符串 必填团队名称的slug。 |
project_id 整数 必填项目的唯一标识符。 |
“检查团队对项目的权限”的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/orgs/ORG/teams/TEAM_SLUG/projects/PROJECT_ID
响应
状态: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": false, "permissions": { "read": true, "write": true, "admin": false } }
添加或更新团队项目权限
将组织项目添加到团队。要将项目添加到团队或更新团队对项目的权限,经过身份验证的用户必须对项目具有admin
权限。项目和团队必须属于同一个组织。
注意
您也可以使用路由PUT /organizations/{org_id}/team/{team_id}/projects/{project_id}
通过org_id
和team_id
指定团队。
“添加或更新团队项目权限”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
team_slug 字符串 必填团队名称的slug。 |
project_id 整数 必填项目的唯一标识符。 |
名称、类型、描述 |
---|
permission 字符串要授予团队对该项目的权限。默认情况下:将使用团队的 可以是以下之一: |
“添加或更新团队项目权限”的HTTP响应状态码
状态码 | 描述 |
---|---|
204 | 无内容 |
403 | 如果项目不是由组织拥有,则返回“禁止” |
“添加或更新团队项目权限”的代码示例
请求示例
curl -L \ -X PUT \ -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/teams/TEAM_SLUG/projects/PROJECT_ID \ -d '{"permission":"write"}'
响应
状态:204
从团队中移除项目
从团队中移除组织项目。组织所有者或团队维护者可以从团队中移除任何项目。要作为组织成员从团队中移除项目,经过身份验证的用户必须对团队和项目都具有read
访问权限,或者对团队或项目具有admin
访问权限。此端点会从团队中移除项目,但不会删除项目。
注意
您也可以使用路由DELETE /organizations/{org_id}/team/{team_id}/projects/{project_id}
通过org_id
和team_id
指定团队。
“从团队中移除项目”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
team_slug 字符串 必填团队名称的slug。 |
project_id 整数 必填项目的唯一标识符。 |
“从团队中移除项目”的HTTP响应状态码
状态码 | 描述 |
---|---|
204 | 无内容 |
“从团队中移除项目”的代码示例
请求示例
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/orgs/ORG/teams/TEAM_SLUG/projects/PROJECT_ID
响应
状态:204
列出团队仓库
列出经过身份验证的用户可见的团队仓库。
注意
您也可以使用路由GET /organizations/{org_id}/team/{team_id}/repos
通过org_id
和team_id
指定团队。
“列出团队仓库”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
team_slug 字符串 必填团队名称的slug。 |
名称、类型、描述 |
---|
per_page 整数每页结果数(最大 100)。更多信息,请参阅“在 REST API 中使用分页”。 默认值: |
page 整数要获取的结果的页码。更多信息,请参阅“在 REST API 中使用分页”。 默认值: |
“列出团队仓库”的HTTP响应状态码
状态码 | 描述 |
---|---|
200 | OK |
“列出团队仓库”的代码示例
请求示例
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/teams/TEAM_SLUG/repos
响应
状态:200
[ { "id": 1296269, "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5", "name": "Hello-World", "full_name": "octocat/Hello-World", "owner": { "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 }, "private": false, "html_url": "https://github.com/octocat/Hello-World", "description": "This your first repo!", "fork": false, "url": "https://api.github.com/repos/octocat/Hello-World", "archive_url": "https://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}", "assignees_url": "https://api.github.com/repos/octocat/Hello-World/assignees{/user}", "blobs_url": "https://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}", "branches_url": "https://api.github.com/repos/octocat/Hello-World/branches{/branch}", "collaborators_url": "https://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}", "comments_url": "https://api.github.com/repos/octocat/Hello-World/comments{/number}", "commits_url": "https://api.github.com/repos/octocat/Hello-World/commits{/sha}", "compare_url": "https://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}", "contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/{+path}", "contributors_url": "https://api.github.com/repos/octocat/Hello-World/contributors", "deployments_url": "https://api.github.com/repos/octocat/Hello-World/deployments", "downloads_url": "https://api.github.com/repos/octocat/Hello-World/downloads", "events_url": "https://api.github.com/repos/octocat/Hello-World/events", "forks_url": "https://api.github.com/repos/octocat/Hello-World/forks", "git_commits_url": "https://api.github.com/repos/octocat/Hello-World/git/commits{/sha}", "git_refs_url": "https://api.github.com/repos/octocat/Hello-World/git/refs{/sha}", "git_tags_url": "https://api.github.com/repos/octocat/Hello-World/git/tags{/sha}", "git_url": "git:github.com/octocat/Hello-World.git", "issue_comment_url": "https://api.github.com/repos/octocat/Hello-World/issues/comments{/number}", "issue_events_url": "https://api.github.com/repos/octocat/Hello-World/issues/events{/number}", "issues_url": "https://api.github.com/repos/octocat/Hello-World/issues{/number}", "keys_url": "https://api.github.com/repos/octocat/Hello-World/keys{/key_id}", "labels_url": "https://api.github.com/repos/octocat/Hello-World/labels{/name}", "languages_url": "https://api.github.com/repos/octocat/Hello-World/languages", "merges_url": "https://api.github.com/repos/octocat/Hello-World/merges", "milestones_url": "https://api.github.com/repos/octocat/Hello-World/milestones{/number}", "notifications_url": "https://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}", "pulls_url": "https://api.github.com/repos/octocat/Hello-World/pulls{/number}", "releases_url": "https://api.github.com/repos/octocat/Hello-World/releases{/id}", "ssh_url": "git@github.com:octocat/Hello-World.git", "stargazers_url": "https://api.github.com/repos/octocat/Hello-World/stargazers", "statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/{sha}", "subscribers_url": "https://api.github.com/repos/octocat/Hello-World/subscribers", "subscription_url": "https://api.github.com/repos/octocat/Hello-World/subscription", "tags_url": "https://api.github.com/repos/octocat/Hello-World/tags", "teams_url": "https://api.github.com/repos/octocat/Hello-World/teams", "trees_url": "https://api.github.com/repos/octocat/Hello-World/git/trees{/sha}", "clone_url": "https://github.com/octocat/Hello-World.git", "mirror_url": "git:git.example.com/octocat/Hello-World", "hooks_url": "https://api.github.com/repos/octocat/Hello-World/hooks", "svn_url": "https://svn.github.com/octocat/Hello-World", "homepage": "https://github.com", "language": null, "forks_count": 9, "stargazers_count": 80, "watchers_count": 80, "size": 108, "default_branch": "master", "open_issues_count": 0, "is_template": false, "topics": [ "octocat", "atom", "electron", "api" ], "has_issues": true, "has_projects": true, "has_wiki": true, "has_pages": false, "has_downloads": true, "archived": false, "disabled": false, "visibility": "public", "pushed_at": "2011-01-26T19:06:43Z", "created_at": "2011-01-26T19:01:12Z", "updated_at": "2011-01-26T19:14:43Z", "permissions": { "admin": false, "push": false, "pull": true } } ]
检查团队对仓库的权限
检查团队是否对仓库拥有admin
、push
、maintain
、triage
或pull
权限。 通过父团队继承的仓库也将被检查。
您也可以通过传递以下自定义媒体类型(通过application/vnd.github.v3.repository+json
accept header),获取指定仓库的信息,包括团队授予的权限。
如果团队没有该仓库的权限,您将收到404 Not Found
响应状态。
如果仓库是私有的,您必须至少拥有该仓库的read
权限,并且您的令牌必须具有repo
或admin:org
作用域。否则,您将收到404 Not Found
响应状态。
注意
您也可以使用路由GET /organizations/{org_id}/team/{team_id}/repos/{owner}/{repo}
,通过org_id
和team_id
指定团队。
"检查团队对仓库的权限"参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
team_slug 字符串 必填团队名称的slug。 |
owner 字符串 必填仓库的账户所有者。名称不区分大小写。 |
repo 字符串 必填仓库的名称,不包含 |
"检查团队对仓库的权限" HTTP 响应状态码
状态码 | 描述 |
---|---|
200 | 包含仓库权限的替代响应 |
204 | 如果团队拥有仓库权限的响应。这是在 Accept header 中未提供仓库媒体类型时的响应。 |
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/orgs/ORG/teams/TEAM_SLUG/repos/OWNER/REPO
包含仓库权限的替代响应
状态:200
{ "id": 1296269, "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5", "name": "Hello-World", "full_name": "octocat/Hello-World", "owner": { "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 }, "private": false, "html_url": "https://github.com/octocat/Hello-World", "description": "This your first repo!", "fork": false, "url": "https://api.github.com/repos/octocat/Hello-World", "archive_url": "https://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}", "assignees_url": "https://api.github.com/repos/octocat/Hello-World/assignees{/user}", "blobs_url": "https://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}", "branches_url": "https://api.github.com/repos/octocat/Hello-World/branches{/branch}", "collaborators_url": "https://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}", "comments_url": "https://api.github.com/repos/octocat/Hello-World/comments{/number}", "commits_url": "https://api.github.com/repos/octocat/Hello-World/commits{/sha}", "compare_url": "https://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}", "contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/{+path}", "contributors_url": "https://api.github.com/repos/octocat/Hello-World/contributors", "deployments_url": "https://api.github.com/repos/octocat/Hello-World/deployments", "downloads_url": "https://api.github.com/repos/octocat/Hello-World/downloads", "events_url": "https://api.github.com/repos/octocat/Hello-World/events", "forks_url": "https://api.github.com/repos/octocat/Hello-World/forks", "git_commits_url": "https://api.github.com/repos/octocat/Hello-World/git/commits{/sha}", "git_refs_url": "https://api.github.com/repos/octocat/Hello-World/git/refs{/sha}", "git_tags_url": "https://api.github.com/repos/octocat/Hello-World/git/tags{/sha}", "git_url": "git:github.com/octocat/Hello-World.git", "issue_comment_url": "https://api.github.com/repos/octocat/Hello-World/issues/comments{/number}", "issue_events_url": "https://api.github.com/repos/octocat/Hello-World/issues/events{/number}", "issues_url": "https://api.github.com/repos/octocat/Hello-World/issues{/number}", "keys_url": "https://api.github.com/repos/octocat/Hello-World/keys{/key_id}", "labels_url": "https://api.github.com/repos/octocat/Hello-World/labels{/name}", "languages_url": "https://api.github.com/repos/octocat/Hello-World/languages", "merges_url": "https://api.github.com/repos/octocat/Hello-World/merges", "milestones_url": "https://api.github.com/repos/octocat/Hello-World/milestones{/number}", "notifications_url": "https://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}", "pulls_url": "https://api.github.com/repos/octocat/Hello-World/pulls{/number}", "releases_url": "https://api.github.com/repos/octocat/Hello-World/releases{/id}", "ssh_url": "git@github.com:octocat/Hello-World.git", "stargazers_url": "https://api.github.com/repos/octocat/Hello-World/stargazers", "statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/{sha}", "subscribers_url": "https://api.github.com/repos/octocat/Hello-World/subscribers", "subscription_url": "https://api.github.com/repos/octocat/Hello-World/subscription", "tags_url": "https://api.github.com/repos/octocat/Hello-World/tags", "teams_url": "https://api.github.com/repos/octocat/Hello-World/teams", "trees_url": "https://api.github.com/repos/octocat/Hello-World/git/trees{/sha}", "clone_url": "https://github.com/octocat/Hello-World.git", "mirror_url": "git:git.example.com/octocat/Hello-World", "hooks_url": "https://api.github.com/repos/octocat/Hello-World/hooks", "svn_url": "https://svn.github.com/octocat/Hello-World", "homepage": "https://github.com", "language": null, "forks_count": 9, "stargazers_count": 80, "watchers_count": 80, "size": 108, "default_branch": "master", "open_issues_count": 0, "is_template": false, "topics": [ "octocat", "atom", "electron", "api" ], "has_issues": true, "has_projects": true, "has_wiki": true, "has_pages": false, "has_downloads": true, "archived": false, "disabled": false, "visibility": "public", "pushed_at": "2011-01-26T19:06:43Z", "created_at": "2011-01-26T19:01:12Z", "updated_at": "2011-01-26T19:14:43Z", "permissions": { "admin": false, "maintain": false, "push": false, "triage": false, "pull": true }, "role_name": "read", "allow_rebase_merge": true, "temp_clone_token": "ABTLWHOULUVAXGTRYU7OC2876QJ2O", "allow_squash_merge": true, "allow_auto_merge": false, "delete_branch_on_merge": true, "allow_merge_commit": true, "subscribers_count": 42, "network_count": 0, "license": { "key": "mit", "name": "MIT License", "url": "https://api.github.com/licenses/mit", "spdx_id": "MIT", "node_id": "MDc6TGljZW5zZW1pdA==", "html_url": "https://api.github.com/licenses/mit" }, "forks": 1, "open_issues": 1, "watchers": 1 }
添加或更新团队仓库权限
要向团队添加仓库或更新团队对仓库的权限,经过身份验证的用户必须对仓库拥有管理员访问权限,并且必须能够查看该团队。仓库必须由组织拥有,或者是由组织拥有的仓库的直接分支。如果您尝试将仓库添加到不属于组织的团队,您将获得422 Unprocessable Entity
状态。请注意,如果您选择不传递任何参数,则在调用此端点时需要将Content-Length
设置为零。有关更多信息,请参见"HTTP 方法"。
注意
您也可以使用路由PUT /organizations/{org_id}/team/{team_id}/repos/{owner}/{repo}
,通过org_id
和team_id
指定团队。
有关权限级别的更多信息,请参见"组织拥有的仓库的权限级别"。
"添加或更新团队仓库权限"参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
team_slug 字符串 必填团队名称的slug。 |
owner 字符串 必填仓库的账户所有者。名称不区分大小写。 |
repo 字符串 必填仓库的名称,不包含 |
名称、类型、描述 |
---|
permission 字符串要授予团队对该仓库的权限。我们接受设置以下权限: |
"添加或更新团队仓库权限" HTTP 响应状态码
状态码 | 描述 |
---|---|
204 | 无内容 |
"添加或更新团队仓库权限"代码示例
请求示例
curl -L \ -X PUT \ -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/teams/TEAM_SLUG/repos/OWNER/REPO \ -d '{"permission":"push"}'
响应
状态:204
从团队中删除仓库
如果已认证用户是组织所有者或团队维护者,他们可以从团队中移除任何代码库。要作为组织成员从团队中移除代码库,已认证用户必须对代码库具有管理员访问权限,并且必须能够查看该团队。这不会删除代码库,只会将其从团队中移除。
注意
您也可以使用路由DELETE /organizations/{org_id}/team/{team_id}/repos/{owner}/{repo}
通过org_id
和team_id
指定团队。
“从团队中移除代码库”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
team_slug 字符串 必填团队名称的slug。 |
owner 字符串 必填仓库的账户所有者。名称不区分大小写。 |
repo 字符串 必填仓库的名称,不包含 |
“从团队中移除代码库”的HTTP响应状态码
状态码 | 描述 |
---|---|
204 | 无内容 |
“从团队中移除代码库”的代码示例
请求示例
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/orgs/ORG/teams/TEAM_SLUG/repos/OWNER/REPO
响应
状态:204
列出子团队
列出由{team_slug}
指定的团队的子团队。
注意
您也可以使用路由GET /organizations/{org_id}/team/{team_id}/teams
通过org_id
和team_id
指定团队。
“列出子团队”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
team_slug 字符串 必填团队名称的slug。 |
名称、类型、描述 |
---|
per_page 整数每页结果数(最大 100)。更多信息,请参阅“在 REST API 中使用分页”。 默认值: |
page 整数要获取的结果的页码。更多信息,请参阅“在 REST API 中使用分页”。 默认值: |
“列出子团队”的HTTP响应状态码
状态码 | 描述 |
---|---|
200 | 如果存在子团队 |
“列出子团队”的代码示例
请求示例
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/teams/TEAM_SLUG/teams
如果存在子团队
状态:200
[ { "id": 2, "node_id": "MDQ6VGVhbTI=", "url": "https://api.github.com/teams/2", "name": "Original Roster", "slug": "original-roster", "description": "Started it all.", "privacy": "closed", "notification_setting": "notifications_enabled", "permission": "admin", "members_url": "https://api.github.com/teams/2/members{/member}", "repositories_url": "https://api.github.com/teams/2/repos", "parent": { "id": 1, "node_id": "MDQ6VGVhbTE=", "url": "https://api.github.com/teams/1", "html_url": "https://github.com/orgs/github/teams/justice-league", "name": "Justice League", "slug": "justice-league", "description": "A great team.", "privacy": "closed", "notification_setting": "notifications_enabled", "permission": "admin", "members_url": "https://api.github.com/teams/1/members{/member}", "repositories_url": "https://api.github.com/teams/1/repos" }, "html_url": "https://github.com/orgs/rails/teams/core" } ]
获取团队(旧版)
警告
端点关闭通知:此端点路由即将关闭,并将从团队API中移除。我们建议您迁移现有代码以使用按名称获取团队端点。
“获取团队(旧版)”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
team_id 整数 必填团队的唯一标识符。 |
“获取团队(旧版)”的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/teams/TEAM_ID
响应
状态:200
{ "id": 1, "node_id": "MDQ6VGVhbTE=", "url": "https://api.github.com/teams/1", "html_url": "https://github.com/orgs/github/teams/justice-league", "name": "Justice League", "slug": "justice-league", "description": "A great team.", "privacy": "closed", "notification_setting": "notifications_enabled", "permission": "admin", "members_url": "https://api.github.com/teams/1/members{/member}", "repositories_url": "https://api.github.com/teams/1/repos", "parent": null, "members_count": 3, "repos_count": 10, "created_at": "2017-07-14T16:53:42Z", "updated_at": "2017-08-17T12:37:15Z", "organization": { "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization", "name": "github", "company": "GitHub", "blog": "https://github.com/blog", "location": "San Francisco", "email": "octocat@github.com", "is_verified": true, "has_organization_projects": true, "has_repository_projects": true, "public_repos": 2, "public_gists": 1, "followers": 20, "following": 0, "html_url": "https://github.com/octocat", "created_at": "2008-01-14T04:33:35Z", "updated_at": "2017-08-17T12:37:15Z", "type": "Organization" } }
更新团队(旧版)
警告
端点关闭通知:此端点路由即将关闭,并将从团队API中移除。我们建议您迁移现有代码以使用新的更新团队端点。
要编辑团队,经过身份验证的用户必须是组织所有者或团队维护者。
注意
对于嵌套团队,父团队的privacy
不能为secret
。
“更新团队(旧版)”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
team_id 整数 必填团队的唯一标识符。 |
名称、类型、描述 |
---|
name 字符串 必需团队的名称。 |
description 字符串团队的描述。 |
privacy 字符串此团队应具有的隐私级别。编辑团队时未指定此参数将保留
可以是其中之一: |
notification_setting 字符串团队选择的通知设置。编辑团队时不指定此参数会保留
可以是其中之一: |
permission 字符串**停用通知**。未指定权限时,将向团队添加新代码库的权限。 默认值: 可以是以下之一: |
parent_team_id 整数或null设置为父团队的团队 ID。 |
“更新团队(旧版)”的HTTP响应状态码
状态码 | 描述 |
---|---|
200 | 更新的信息已存在时的响应 |
201 | 已创建 |
403 | 禁止 |
404 | 资源未找到 |
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/teams/TEAM_ID \ -d '{"name":"new team name","description":"new team description","privacy":"closed","notification_setting":"notifications_enabled"}'
更新的信息已存在时的响应
状态:200
{ "id": 1, "node_id": "MDQ6VGVhbTE=", "url": "https://api.github.com/teams/1", "html_url": "https://github.com/orgs/github/teams/justice-league", "name": "Justice League", "slug": "justice-league", "description": "A great team.", "privacy": "closed", "notification_setting": "notifications_enabled", "permission": "admin", "members_url": "https://api.github.com/teams/1/members{/member}", "repositories_url": "https://api.github.com/teams/1/repos", "parent": null, "members_count": 3, "repos_count": 10, "created_at": "2017-07-14T16:53:42Z", "updated_at": "2017-08-17T12:37:15Z", "organization": { "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization", "name": "github", "company": "GitHub", "blog": "https://github.com/blog", "location": "San Francisco", "email": "octocat@github.com", "is_verified": true, "has_organization_projects": true, "has_repository_projects": true, "public_repos": 2, "public_gists": 1, "followers": 20, "following": 0, "html_url": "https://github.com/octocat", "created_at": "2008-01-14T04:33:35Z", "updated_at": "2017-08-17T12:37:15Z", "type": "Organization" } }
删除团队(旧版)
警告
端点关闭通知:此端点路由即将关闭,并将从团队API中移除。我们建议您迁移现有代码以使用新的删除团队端点。
要删除团队,经过身份验证的用户必须是组织所有者或团队维护者。
如果您是组织所有者,删除父团队也将删除其所有子团队。
“删除团队(旧版)”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
team_id 整数 必填团队的唯一标识符。 |
“删除团队(旧版)”的HTTP响应状态码
状态码 | 描述 |
---|---|
204 | 无内容 |
404 | 资源未找到 |
422 | 验证失败,或端点已被滥用。 |
“删除团队(旧版)”的代码示例
请求示例
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/teams/TEAM_ID
响应
状态:204
列出团队项目(旧版)
警告
端点关闭通知:此端点路由即将关闭,并将从团队API中移除。我们建议您迁移现有代码以使用新的列出团队项目
端点。
列出团队的组织项目。
“列出团队项目(旧版)”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
team_id 整数 必填团队的唯一标识符。 |
名称、类型、描述 |
---|
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/teams/TEAM_ID/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": "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": false, "permissions": { "read": true, "write": true, "admin": false } } ]
检查团队对项目的权限(旧版)
警告
端点关闭通知:此端点路由即将关闭,并将从团队API中移除。我们建议您迁移现有代码以使用新的检查团队对项目的权限端点。
检查团队是否对组织项目具有read
、write
或admin
权限。响应包括从父团队继承的项目。
“检查团队对项目的权限(旧版)”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
team_id 整数 必填团队的唯一标识符。 |
project_id 整数 必填项目的唯一标识符。 |
“检查团队对项目的权限(旧版)”的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/teams/TEAM_ID/projects/PROJECT_ID
响应
状态: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": false, "permissions": { "read": true, "write": true, "admin": false } }
添加或更新团队项目权限(旧版)
警告
端点关闭通知:此端点路由即将关闭,并将从团队API中移除。我们建议您迁移现有代码以使用新的添加或更新团队项目权限端点。
将组织项目添加到团队。要将项目添加到团队或更新团队对项目的权限,经过身份验证的用户必须对项目具有admin
权限。项目和团队必须属于同一个组织。
“添加或更新团队项目权限(旧版)”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
team_id 整数 必填团队的唯一标识符。 |
project_id 整数 必填项目的唯一标识符。 |
名称、类型、描述 |
---|
permission 字符串要授予团队对该项目的权限。默认情况下:将使用团队的 可以是以下之一: |
“添加或更新团队项目权限(旧版)”的HTTP响应状态码
状态码 | 描述 |
---|---|
204 | 无内容 |
403 | 如果项目不是由组织拥有,则返回“禁止” |
404 | 资源未找到 |
422 | 验证失败,或端点已被滥用。 |
“添加或更新团队项目权限(旧版)”的代码示例
请求示例
curl -L \ -X PUT \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/teams/TEAM_ID/projects/PROJECT_ID \ -d '{"permission":"read"}'
响应
状态:204
从团队中移除项目(旧版)
警告
端点关闭通知:此端点路由即将关闭,并将从团队API中移除。我们建议您迁移现有代码以使用新的从团队中移除项目端点。
从团队中移除组织项目。组织所有者或团队维护者可以从团队中移除任何项目。要作为组织成员从团队中移除项目,已认证用户必须对团队和项目都具有read
访问权限,或者对团队或项目具有admin
访问权限。注意:此端点会将项目从团队中移除,但不会删除它。
“从团队中移除项目(旧版)”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
team_id 整数 必填团队的唯一标识符。 |
project_id 整数 必填项目的唯一标识符。 |
“从团队中移除项目(旧版)”的HTTP响应状态码
状态码 | 描述 |
---|---|
204 | 无内容 |
404 | 资源未找到 |
422 | 验证失败,或端点已被滥用。 |
“从团队中移除项目(旧版)”的代码示例
请求示例
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/teams/TEAM_ID/projects/PROJECT_ID
响应
状态:204
列出团队代码库(旧版)
警告
端点关闭通知:此端点路由即将关闭,并将从团队API中移除。我们建议您迁移现有代码以使用新的列出团队代码库端点。
“列出团队代码库(旧版)”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
team_id 整数 必填团队的唯一标识符。 |
名称、类型、描述 |
---|
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/teams/TEAM_ID/repos
响应
状态:200
[ { "id": 1296269, "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5", "name": "Hello-World", "full_name": "octocat/Hello-World", "owner": { "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 }, "private": false, "html_url": "https://github.com/octocat/Hello-World", "description": "This your first repo!", "fork": false, "url": "https://api.github.com/repos/octocat/Hello-World", "archive_url": "https://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}", "assignees_url": "https://api.github.com/repos/octocat/Hello-World/assignees{/user}", "blobs_url": "https://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}", "branches_url": "https://api.github.com/repos/octocat/Hello-World/branches{/branch}", "collaborators_url": "https://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}", "comments_url": "https://api.github.com/repos/octocat/Hello-World/comments{/number}", "commits_url": "https://api.github.com/repos/octocat/Hello-World/commits{/sha}", "compare_url": "https://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}", "contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/{+path}", "contributors_url": "https://api.github.com/repos/octocat/Hello-World/contributors", "deployments_url": "https://api.github.com/repos/octocat/Hello-World/deployments", "downloads_url": "https://api.github.com/repos/octocat/Hello-World/downloads", "events_url": "https://api.github.com/repos/octocat/Hello-World/events", "forks_url": "https://api.github.com/repos/octocat/Hello-World/forks", "git_commits_url": "https://api.github.com/repos/octocat/Hello-World/git/commits{/sha}", "git_refs_url": "https://api.github.com/repos/octocat/Hello-World/git/refs{/sha}", "git_tags_url": "https://api.github.com/repos/octocat/Hello-World/git/tags{/sha}", "git_url": "git:github.com/octocat/Hello-World.git", "issue_comment_url": "https://api.github.com/repos/octocat/Hello-World/issues/comments{/number}", "issue_events_url": "https://api.github.com/repos/octocat/Hello-World/issues/events{/number}", "issues_url": "https://api.github.com/repos/octocat/Hello-World/issues{/number}", "keys_url": "https://api.github.com/repos/octocat/Hello-World/keys{/key_id}", "labels_url": "https://api.github.com/repos/octocat/Hello-World/labels{/name}", "languages_url": "https://api.github.com/repos/octocat/Hello-World/languages", "merges_url": "https://api.github.com/repos/octocat/Hello-World/merges", "milestones_url": "https://api.github.com/repos/octocat/Hello-World/milestones{/number}", "notifications_url": "https://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}", "pulls_url": "https://api.github.com/repos/octocat/Hello-World/pulls{/number}", "releases_url": "https://api.github.com/repos/octocat/Hello-World/releases{/id}", "ssh_url": "git@github.com:octocat/Hello-World.git", "stargazers_url": "https://api.github.com/repos/octocat/Hello-World/stargazers", "statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/{sha}", "subscribers_url": "https://api.github.com/repos/octocat/Hello-World/subscribers", "subscription_url": "https://api.github.com/repos/octocat/Hello-World/subscription", "tags_url": "https://api.github.com/repos/octocat/Hello-World/tags", "teams_url": "https://api.github.com/repos/octocat/Hello-World/teams", "trees_url": "https://api.github.com/repos/octocat/Hello-World/git/trees{/sha}", "clone_url": "https://github.com/octocat/Hello-World.git", "mirror_url": "git:git.example.com/octocat/Hello-World", "hooks_url": "https://api.github.com/repos/octocat/Hello-World/hooks", "svn_url": "https://svn.github.com/octocat/Hello-World", "homepage": "https://github.com", "language": null, "forks_count": 9, "stargazers_count": 80, "watchers_count": 80, "size": 108, "default_branch": "master", "open_issues_count": 0, "is_template": false, "topics": [ "octocat", "atom", "electron", "api" ], "has_issues": true, "has_projects": true, "has_wiki": true, "has_pages": false, "has_downloads": true, "archived": false, "disabled": false, "visibility": "public", "pushed_at": "2011-01-26T19:06:43Z", "created_at": "2011-01-26T19:01:12Z", "updated_at": "2011-01-26T19:14:43Z", "permissions": { "admin": false, "push": false, "pull": true } } ]
检查团队对代码库的权限(旧版)
警告
端点关闭通知:此端点路由即将关闭,并将从团队API中移除。我们建议您迁移现有代码以使用新的检查团队对代码库的权限端点。
注意
通过父团队继承的代码库也将被检查。
您还可以通过Accept
标头传递以下自定义媒体类型来获取指定代码库的信息,包括团队授予的权限。
“检查团队对代码库的权限(旧版)”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
team_id 整数 必填团队的唯一标识符。 |
owner 字符串 必填仓库的账户所有者。名称不区分大小写。 |
repo 字符串 必填仓库的名称,不包含 |
“检查团队对代码库的权限(旧版)”的HTTP响应状态码
状态码 | 描述 |
---|---|
200 | 包含额外代码库信息的替代响应 |
204 | 如果代码库由此团队管理的响应 |
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/teams/TEAM_ID/repos/OWNER/REPO
包含额外代码库信息的替代响应
状态:200
{ "id": 1296269, "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5", "name": "Hello-World", "full_name": "octocat/Hello-World", "owner": { "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 }, "private": false, "html_url": "https://github.com/octocat/Hello-World", "description": "This your first repo!", "fork": false, "url": "https://api.github.com/repos/octocat/Hello-World", "archive_url": "https://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}", "assignees_url": "https://api.github.com/repos/octocat/Hello-World/assignees{/user}", "blobs_url": "https://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}", "branches_url": "https://api.github.com/repos/octocat/Hello-World/branches{/branch}", "collaborators_url": "https://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}", "comments_url": "https://api.github.com/repos/octocat/Hello-World/comments{/number}", "commits_url": "https://api.github.com/repos/octocat/Hello-World/commits{/sha}", "compare_url": "https://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}", "contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/{+path}", "contributors_url": "https://api.github.com/repos/octocat/Hello-World/contributors", "deployments_url": "https://api.github.com/repos/octocat/Hello-World/deployments", "downloads_url": "https://api.github.com/repos/octocat/Hello-World/downloads", "events_url": "https://api.github.com/repos/octocat/Hello-World/events", "forks_url": "https://api.github.com/repos/octocat/Hello-World/forks", "git_commits_url": "https://api.github.com/repos/octocat/Hello-World/git/commits{/sha}", "git_refs_url": "https://api.github.com/repos/octocat/Hello-World/git/refs{/sha}", "git_tags_url": "https://api.github.com/repos/octocat/Hello-World/git/tags{/sha}", "git_url": "git:github.com/octocat/Hello-World.git", "issue_comment_url": "https://api.github.com/repos/octocat/Hello-World/issues/comments{/number}", "issue_events_url": "https://api.github.com/repos/octocat/Hello-World/issues/events{/number}", "issues_url": "https://api.github.com/repos/octocat/Hello-World/issues{/number}", "keys_url": "https://api.github.com/repos/octocat/Hello-World/keys{/key_id}", "labels_url": "https://api.github.com/repos/octocat/Hello-World/labels{/name}", "languages_url": "https://api.github.com/repos/octocat/Hello-World/languages", "merges_url": "https://api.github.com/repos/octocat/Hello-World/merges", "milestones_url": "https://api.github.com/repos/octocat/Hello-World/milestones{/number}", "notifications_url": "https://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}", "pulls_url": "https://api.github.com/repos/octocat/Hello-World/pulls{/number}", "releases_url": "https://api.github.com/repos/octocat/Hello-World/releases{/id}", "ssh_url": "git@github.com:octocat/Hello-World.git", "stargazers_url": "https://api.github.com/repos/octocat/Hello-World/stargazers", "statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/{sha}", "subscribers_url": "https://api.github.com/repos/octocat/Hello-World/subscribers", "subscription_url": "https://api.github.com/repos/octocat/Hello-World/subscription", "tags_url": "https://api.github.com/repos/octocat/Hello-World/tags", "teams_url": "https://api.github.com/repos/octocat/Hello-World/teams", "trees_url": "https://api.github.com/repos/octocat/Hello-World/git/trees{/sha}", "clone_url": "https://github.com/octocat/Hello-World.git", "mirror_url": "git:git.example.com/octocat/Hello-World", "hooks_url": "https://api.github.com/repos/octocat/Hello-World/hooks", "svn_url": "https://svn.github.com/octocat/Hello-World", "homepage": "https://github.com", "language": null, "forks_count": 9, "stargazers_count": 80, "watchers_count": 80, "size": 108, "default_branch": "master", "open_issues_count": 0, "is_template": false, "topics": [ "octocat", "atom", "electron", "api" ], "has_issues": true, "has_projects": true, "has_wiki": true, "has_pages": false, "has_downloads": true, "archived": false, "disabled": false, "visibility": "public", "pushed_at": "2011-01-26T19:06:43Z", "created_at": "2011-01-26T19:01:12Z", "updated_at": "2011-01-26T19:14:43Z", "permissions": { "admin": false, "maintain": false, "push": false, "triage": false, "pull": true }, "role_name": "read", "allow_rebase_merge": true, "temp_clone_token": "ABTLWHOULUVAXGTRYU7OC2876QJ2O", "allow_squash_merge": true, "allow_auto_merge": false, "delete_branch_on_merge": true, "allow_merge_commit": true, "subscribers_count": 42, "network_count": 0, "license": { "key": "mit", "name": "MIT License", "url": "https://api.github.com/licenses/mit", "spdx_id": "MIT", "node_id": "MDc6TGljZW5zZW1pdA==", "html_url": "https://api.github.com/licenses/mit" }, "forks": 1, "open_issues": 1, "watchers": 1 }
添加或更新团队仓库权限(旧版)
警告
端点关闭通知:此端点路由即将关闭,并将从团队 API 中删除。我们建议您迁移现有代码以使用新的“添加或更新团队仓库权限”端点。
要向团队添加仓库或更新团队对仓库的权限,经过身份验证的用户必须对仓库具有管理员访问权限,并且必须能够查看该团队。仓库必须由组织拥有,或者是由组织拥有的仓库的直接派生仓库。如果您尝试将仓库添加到组织不拥有的团队,则会收到422 Unprocessable Entity
状态码。
请注意,如果您选择不传递任何参数,则在调用此端点时需要将Content-Length
设置为零。有关更多信息,请参阅“HTTP 方法”。
“添加或更新团队仓库权限(旧版)”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
team_id 整数 必填团队的唯一标识符。 |
owner 字符串 必填仓库的账户所有者。名称不区分大小写。 |
repo 字符串 必填仓库的名称,不包含 |
名称、类型、描述 |
---|
permission 字符串授予团队在此仓库上的权限。如果未指定权限,则将使用团队的 可以是以下之一: |
“添加或更新团队仓库权限(旧版)”的 HTTP 响应状态码
状态码 | 描述 |
---|---|
204 | 无内容 |
403 | 禁止 |
422 | 验证失败,或端点已被滥用。 |
“添加或更新团队仓库权限(旧版)”的代码示例
请求示例
curl -L \ -X PUT \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/teams/TEAM_ID/repos/OWNER/REPO \ -d '{"permission":"push"}'
响应
状态:204
从团队中删除仓库(旧版)
警告
端点关闭通知:此端点路由即将关闭,并将从团队 API 中删除。我们建议您迁移现有代码以使用新的从团队中删除仓库端点。
如果经过身份验证的用户是组织所有者或团队维护者,他们可以从团队中删除任何仓库。要作为组织成员从团队中删除仓库,经过身份验证的用户必须对仓库具有管理员访问权限,并且必须能够查看该团队。注意:这不会删除仓库,只是将其从团队中移除。
“从团队中删除仓库(旧版)”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
team_id 整数 必填团队的唯一标识符。 |
owner 字符串 必填仓库的账户所有者。名称不区分大小写。 |
repo 字符串 必填仓库的名称,不包含 |
“从团队中删除仓库(旧版)”的 HTTP 响应状态码
状态码 | 描述 |
---|---|
204 | 无内容 |
“从团队中删除仓库(旧版)”的代码示例
请求示例
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/teams/TEAM_ID/repos/OWNER/REPO
响应
状态:204
列出子团队(旧版)
警告
端点关闭通知:此端点路由即将关闭,并将从团队 API 中删除。我们建议您迁移现有代码以使用新的列出子团队
端点。
“列出子团队(旧版)”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
team_id 整数 必填团队的唯一标识符。 |
名称、类型、描述 |
---|
per_page 整数每页结果数(最大 100)。更多信息,请参阅“在 REST API 中使用分页”。 默认值: |
page 整数要获取的结果的页码。更多信息,请参阅“在 REST API 中使用分页”。 默认值: |
“列出子团队(旧版)”的 HTTP 响应状态码
状态码 | 描述 |
---|---|
200 | 如果存在子团队 |
403 | 禁止 |
404 | 资源未找到 |
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/teams/TEAM_ID/teams
如果存在子团队
状态:200
[ { "id": 2, "node_id": "MDQ6VGVhbTI=", "url": "https://api.github.com/teams/2", "name": "Original Roster", "slug": "original-roster", "description": "Started it all.", "privacy": "closed", "notification_setting": "notifications_enabled", "permission": "admin", "members_url": "https://api.github.com/teams/2/members{/member}", "repositories_url": "https://api.github.com/teams/2/repos", "parent": { "id": 1, "node_id": "MDQ6VGVhbTE=", "url": "https://api.github.com/teams/1", "html_url": "https://github.com/orgs/github/teams/justice-league", "name": "Justice League", "slug": "justice-league", "description": "A great team.", "privacy": "closed", "notification_setting": "notifications_enabled", "permission": "admin", "members_url": "https://api.github.com/teams/1/members{/member}", "repositories_url": "https://api.github.com/teams/1/repos" }, "html_url": "https://github.com/orgs/rails/teams/core" } ]
列出经过身份验证用户的团队
列出经过身份验证的用户所属所有组织中的所有团队。
OAuth 应用令牌和个人访问令牌(经典版)需要user
、repo
或read:org
范围才能使用此端点。
使用细粒度个人访问令牌时,令牌的资源所有者必须是单个组织,并且响应将仅包含来自该组织的团队。
“列出经过身份验证用户的团队”的细粒度访问令牌
此端点适用于以下细粒度令牌类型:
细粒度令牌不需要任何权限。
“列出经过身份验证用户的团队”的参数
名称、类型、描述 |
---|
accept 字符串建议设置为 |
名称、类型、描述 |
---|
per_page 整数每页结果数(最大 100)。更多信息,请参阅“在 REST API 中使用分页”。 默认值: |
page 整数要获取的结果的页码。更多信息,请参阅“在 REST API 中使用分页”。 默认值: |
“列出经过身份验证用户的团队”的 HTTP 响应状态码
状态码 | 描述 |
---|---|
200 | OK |
304 | 未修改 |
403 | 禁止 |
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/user/teams
响应
状态:200
[ { "id": 1, "node_id": "MDQ6VGVhbTE=", "url": "https://api.github.com/teams/1", "html_url": "https://github.com/orgs/github/teams/justice-league", "name": "Justice League", "slug": "justice-league", "description": "A great team.", "privacy": "closed", "notification_setting": "notifications_enabled", "permission": "admin", "members_url": "https://api.github.com/teams/1/members{/member}", "repositories_url": "https://api.github.com/teams/1/repos", "parent": null, "members_count": 3, "repos_count": 10, "created_at": "2017-07-14T16:53:42Z", "updated_at": "2017-08-17T12:37:15Z", "organization": { "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization", "name": "github", "company": "GitHub", "blog": "https://github.com/blog", "location": "San Francisco", "email": "octocat@github.com", "is_verified": true, "has_organization_projects": true, "has_repository_projects": true, "public_repos": 2, "public_gists": 1, "followers": 20, "following": 0, "html_url": "https://github.com/octocat", "created_at": "2008-01-14T04:33:35Z", "updated_at": "2017-08-17T12:37:15Z", "type": "Organization" } } ]