# 用户
# 获取用户信息列表
函数使用
page和per_page作为分页参数限制返回列表的大小。
# 作为普通用户
GET /api/v3/users
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| page | integer(可选) | 页数 (默认值:1) |
| per_page | integer(可选) | 默认页面大小 (默认值 20,最大值: 100) |
返回值:
[
{
"id": 2235,
"username": "luci",
"web_url": "https://git.tencent.com/u/luci",
"name": "luci",
"state": "active",
"avatar_url": "git.tencent.com/assets/images/avatar/no_user_avatar.png",
"last_active_at": "2024-01-11T01:55:12+0000"
}
]
# 获取用户关注项目列表
获取当前用户关注的项目列表
GET /api/v3/user/watched
返回值:
[
{
"id": 4484,
"description": "",
"public": false,
"archived": false,
"visibility_level": 0,
"namespace": {
"created_at": "2016-06-06T08:02:39+0000",
"description": "",
"id": 6854,
"name": "git_user",
"owner_id": 3654,
"path": "git_user",
"updated_at": "2016-06-06T08:02:39+0000"
},
"owner": {
"id": 627,
"username": "git_user",
"web_url": "https://git.tencent.com/u/git_user",
"name": "git_user",
"state": "blocked",
"avatar_url": "git.tencent.com/uploads/user/avatar/627/ae4f4ab5f5b6445bb97404a4638b68d7.gif"
},
"name": "pro-111",
"name_with_namespace": "git_user/pro-111",
"path": "pro-111",
"path_with_namespace": "git_user/pro-111",
"default_branch": "master",
"ssh_url_to_repo": "git@git.tencent.com:git_user/pro-111.git",
"http_url_to_repo": "http://git.tencent.com/git_user/pro-111.git",
"https_url_to_repo": "https://git.tencent.com/git_user/pro-111.git",
"web_url": "https://git.tencent.com/git_user/pro-111",
"tag_list": [],
"issues_enabled": true,
"merge_requests_enabled": true,
"wiki_enabled": true,
"snippets_enabled": true,
"review_enabled": true,
"fork_enabled": false,
"tag_name_regex": null,
"tag_create_push_level": 30,
"created_at": "2018-01-11T02:26:04+0000",
"last_activity_at": "2018-03-13T07:21:28+0000",
"creator_id": 6227,
"avatar_url": "https://git.tencent.com/uploads/project/avatar/4484",
"watchs_count": 5,
"stars_count": 0,
"forks_count": 2,
"config_storage": {
"limit_lfs_file_size": 500,
"limit_size": 100000,
"limit_file_size": 100000,
"limit_lfs_size": 100000
},
"config_confidential": {
"level": -1,
"allow_ai_coding_tool": true
},
"forked_from_project": "Forked Project not found",
"statistics": {
"commit_count": 8,
"repository_size": 0.013
}
},
]
# 获取当前用户快捷访问项目列表
获取当前用户快捷访问项目列表
GET /api/v3/user/projects/pinned
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| id | integer 或 string | 项目 ID 或 项目全路径 project_full_path |
返回值:
[
{
"id": 1323,
"name": "test",
"path": "test",
"type": "GIT",
"archived": false,
"avatar": null,
"description": "",
"fullPath": "xx/test",
"fullName": "xx/test"
},
]
# 单个用户
获取一个单独用户的信息。
# 获取某个用户的帐号信息
获取某个指定用户的信息
GET /api/v3/users/:id
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| id | integer 或 string | 用户唯一标识,或者用户名 |
返回值:
{
"id": 45,
"email": "bobi@tencent.com",
"name": "bobi",
"username": "bobi",
"web_url": "https://git.tencent.com/u/bobi",
"current_sign_in_at": "2015-07-06T04:12:40+0000",
"is_admin": false,
"projects_limit": 9999999,
"skype": null,
"linkedin": null,
"twitter": null,
"theme_id": 1,
"bio": null,
"state": "active",
"color_scheme_id": 1,
"website_url": null,
"created_at": "2015-01-25T08:12:01+0000",
"identities": [
{
"extern_uid": "bobi",
"provider": "ldapmain"
},
{
"extern_uid": "bobi",
"provider": "tof"
}
],
"can_create_project": true
}
# 当前认证用户
获取当前认证用户信息。
GET /api/v3/user
返回值:
{
"id": 18612,
"email": "bob@tencent.com",
"name": "bob",
"username": "bob",
"web_url": "https://git.tencent.com/u/bob",
"current_sign_in_at": "2017-07-19T06:51:23+0000",
"is_admin": true,
"projects_limit": 9999999,
"skype": "",
"linkedin": "",
"twitter": "",
"theme_id": 1,
"bio": "",
"state": "active",
"color_scheme_id": 1,
"website_url": "",
"created_at": "2017-01-16T08:29:42+0000",
"identities": [
{
"extern_uid": "bob",
"provider": "ldapmain"
},
{
"extern_uid": "bob",
"provider": "tof"
}
]
}
# 给当前用户创建一个 SSH key
创建一个新的 SSH key 给当前认证的用户。
POST /api/v3/user/keys
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| title | string | SSH Key 的标题 |
| key | string | 新的 SSH key |
返回值:
{
"id": 10127,
"title": "test",
"key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDXawA7+8VH0FmLbJ0m0hMfXjmQD/DXSsbL8DicG9/jk34BLr8mQ23EXr38te5wvRejhYV4ov3/V1HGB6M2o/cDVUc1ODQpcEBa6jZ1Q/VoqVO+49+UHN/FeOgQk60bF7Nu4hXhn/e/H6Tw2fTvUW1LPpaPtqNiqcylqtZ2qfLHfUXXXvOmRmM/4sTBZnjMoK61moZgxtrYaDtZOVxVVqF+AVpnbfHUDdGZofNQe2AW2g1PXpu3ikgeyxvXGoBLKXo6r1KVYD+uSPf4OouHnUsBpYJKy6PUpjxs13yzpk65TDy1xX4xylbO0TVEhNYXax2K6ih2RPPmSpq8juZzr7RZ",
"created_at": "2017-08-13T03:19:54+0000"
}
创建成功将返回状态201 Created。如果返回400 Bad Request错误将附带一个说明的错误信息:
{
"message": {
"fingerprint": [
"has already been taken"
],
"key": [
"has already been taken"
]
}
}
# 获取当前用户的 SSH key
获取当前认证用户的 SSH keys 列表。
GET /api/v3/user/keys
返回值:
[
{
"id": 2356,
"title": "git-key1",
"key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDXawA7+8VH0FmLbJ0m0hMfXjmQD/DXSsbL8DicG9/jk34BLr8mQ23EXr38te5wvRejhYV4ov3/V1HGB6M2o/cDVUc1ODQpcEBa6jZ1Q/VoqVO+49+UHN/FeOgQk60bF7Nu4hXhn/e/H6Tw2fTvSSSSPpaPtqNiqcylqtZ2qfLHfUXv5vOmRmM/4sTBZnjMoK61moZgxtrYaDtZOVxVVqF+AVpnbfHUDdGZofNQe2AW2g1PXpu3ikgeyxvXGoBLKXo6r1KVYD+uSPf4OouHnUsBpYJKy6PUpjxs13yzpk65TDy1xX4xylbO0TVEhNYXax2K6ih2RPPmSpq8juZzr7RZ",
"created_at": "2012-06-28T02:33:02+0000"
}
]
# 获取某个指定的 SSH key
获取一个特定的 SSH key
GET /api/v3/user/keys/:id
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| id | integer | SSH key 的 id |
返回值:
{
"id": 215,
"title": "git-key1",
"key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDXawA7+8VH0FmLbJ0m0hMfXjmQD/DXSsbL8DicG9/jk34BLr8mQ23EXr38te5wvRejhYV4ov3/V1HGB6M2o/cDVUc1ODQpcEBa6jZ1Q/VoqVO+49+UHN/FeOgQk60bF7Nu4hXhn/e/H6Tw2fTvUW1LPpaPtqNiqcylqtZ2qfLHfUXv5vOmRmM/4sTBZnjMoK61moZgxtrYaDtZOVxVVqF+AVpnbfHUDdGZofNQe2AW2g1PXpu3ikgeyxvXGoBLKXo6r1KVYD+uSPf4OouHnUsBpYJKy6PUpjxs13yzpk65TDy1xX4xylbO0TVEhNYXax2K6ih2RPPmSpq8juZzr7RZ",
"created_at": "2012-06-28T02:33:02+0000"
}
# 删除当前用户的 SSH key
删除当前认证用户拥有的 SSH key。
这是一个幂等的操作,调用它删除一个存在的或已经删除的 key 返回的结果都是200 OK。
DELETE /api/v3/user/keys/:id
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| id | integer | SSH key 的 ID |
# 添加邮箱
给当前认证用户增加邮箱。
POST /api/v3/user/emails
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| string | 邮箱地址 |
返回值:
{
"id": 98,
"email": "git02@tencent.com"
}
调用成功返回状态201 Created。如果发生400 Bad Request错误的话附带相关的错误信息:
{
"message": {
"email": [
"has not given"
]
}
}
# 通过邮箱获取用户信息
通过邮箱获取一个用户的基本信息。
GET /api/v3/user/email
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| string | 邮箱地址 |
返回值:
{
"name": "long",
"username": "long",
"web_url": "https://git.tencent.com/u/long"
}
# 获取用户邮箱列表
获取当前用户的邮箱列表
GET /api/v3/user/emails
返回值:
[
{
"id": 56,
"email": "git_user1@tencent.com"
},
{
"id": 98,
"email": "git_user1@tencent.com"
}
]
# 获取邮箱信息
获取某个特定邮箱信息。
GET /api/v3/user/emails/:id
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| id | integer | 邮箱的 ID |
返回值:
{
"id": 56,
"email": "git_user1@tencent.com"
}
# 删除当前用户的邮箱
删除当前认证用户拥有的邮箱。
这是一个幂等的操作,用户调用它删除一个存在的或已经删除的邮箱返回结果都是200 OK。
DELETE /api/v3/user/emails/:id
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| id | integer | 邮箱的 ID |
# 获取当前登录用户的事件信息列表
获取当前认证用户的事件信息列表。
GET /api/v3/events
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| begin_date | yyyy-MM-dd'T'HH:mm:ssZ(可选) | 事件起始时间;例如 2019-03-25T00:10:19+0000 或 2019-03-25T00:10:19+0800,时间参数必须转码,如"2019-03-25T00:10:19%2B0800"。默认值为 end_date 往前一个月,与 end_date 最大间隔为一年 |
| end_date | yyyy-MM-dd'T'HH:mm:ssZ(可选) | 事件结束时间;例如 2019-03-26T00:10:19+0000 或 2019-03-26T00:10:19+0800,时间参数必须转码,如"2019-03-26T00:10:19%2B0800"。默认值为当前时间,与 begin_date 最大间隔为一年 |
| event_filter | string(可选) | 事件类型过滤,多个类型用英文逗号分隔。可选值:push(推送)、merged(合并)、comments(评论)、team(团队成员变动)、wikiPush(Wiki 推送)、svnCommit(SVN 提交) |
| page | integer(可选) | 页数 (默认值:1) |
| per_page | integer(可选) | 默认页面大小 (默认值 20,最大值: 100) |
返回值:
[
{
"title": null,
"project_id": 1228252,
"action_name": "PUSHED",
"target_id": null,
"target_type": null,
"author_id": 2552,
"author_username": "bob",
"created_at": "2026-01-19T12:05:34+0000",
"target_title": null,
"data": {
"object_kind": "push",
"type": "update",
"before": "225a866f5cd80c065ff0966f1c66fc73c6ff28ac",
"after": "721c2160e00033b97a53377ca71b052f53401589",
"ref": "refs/heads/staging",
"user_id": "2552",
"username": "bob",
"commits": [
{
"id": "721c2160e00033b97a53377ca71b052f53401589",
"message": "Merge branch 'cherry-pick-490f8dd8' into 'staging' ...",
"timestamp": "2026-01-19 12:05:32",
"url": "https://git.tencent.com/code/code-business/code-business-app/commit/721c2160e00033b97a53377ca71b052f53401589"
}
],
"repository": {
"name": "code-business-app",
"description": "工蜂业务后端服务",
"homepage": "https://git.tencent.com/code/code-business/code-business-app",
"git_ssh_url": "git@git.tencent.com:code/code-business/code-business-app.git",
"git_http_url": "http://git.tencent.com/code/code-business/code-business-app.git",
"git_https_url": "https://git.tencent.com/code/code-business/code-business-app.git",
"visibility_level": "0"
}
}
},
{
"title": null,
"project_id": 28,
"action_name": "CREATED",
"target_id": 387,
"target_type": "MergeRequest",
"author_id": 11323,
"author_username": "luci",
"created_at": "2017-09-25T08:46:28+0000",
"target_title": null,
"data": {}
},
{
"title": null,
"project_id": 28,
"action_name": "COMMENTED",
"target_id": 732,
"target_type": "note",
"author_id": 11323,
"author_username": "luci",
"created_at": "2017-09-24T08:46:28+0000",
"target_title": null,
"data": {}
}
]
# 获取指定用户事件信息
获取某个指定用户的事件信息列表,仅能看到目标用户公开或你也有权限的项目动态。
GET /api/v3/users/:id/events
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| id | integer 或 string | 用户唯一标识,或者用户名 |
| begin_date | yyyy-MM-dd'T'HH:mm:ssZ(可选) | 事件起始时间;例如 2019-03-25T00:10:19+0000 或 2019-03-25T00:10:19+0800,时间参数必须转码,如"2019-03-25T00:10:19%2B0800"。默认值为 end_date 往前一个月,与 end_date 最大间隔为一年 |
| end_date | yyyy-MM-dd'T'HH:mm:ssZ(可选) | 事件结束时间;例如 2019-03-26T00:10:19+0000 或 2019-03-26T00:10:19+0800,时间参数必须转码,如"2019-03-26T00:10:19%2B0800"。默认值为当前时间,与 begin_date 最大间隔为一年 |
| event_filter | string(可选) | 事件类型过滤,多个类型用英文逗号分隔。可选值:push(推送)、merged(合并)、comments(评论)、team(团队成员变动)、wikiPush(Wiki 推送)、svnCommit(SVN 提交) |
| page | integer(可选) | 页数 (默认值:1) |
| per_page | integer(可选) | 默认页面大小 (默认值 20,最大值: 100) |
返回值:
[
{
"title": null,
"project_id": 1228252,
"action_name": "PUSHED",
"target_id": null,
"target_type": null,
"author_id": 2552,
"author_username": "bob",
"created_at": "2026-01-19T12:05:34+0000",
"target_title": null,
"data": {
"object_kind": "push",
"type": "update",
"before": "225a866f5cd80c065ff0966f1c66fc73c6ff28ac",
"after": "721c2160e00033b97a53377ca71b052f53401589",
"ref": "refs/heads/staging",
"user_id": "2552",
"username": "bob",
"commits": [
{
"id": "721c2160e00033b97a53377ca71b052f53401589",
"message": "Merge branch 'cherry-pick-490f8dd8' into 'staging' ...",
"timestamp": "2026-01-19 12:05:32",
"url": "https://git.tencent.com/code/code-business/code-business-app/commit/721c2160e00033b97a53377ca71b052f53401589"
}
],
"repository": {
"name": "code-business-app",
"description": "工蜂业务后端服务",
"homepage": "https://git.tencent.com/code/code-business/code-business-app",
"git_ssh_url": "git@git.tencent.com:code/code-business/code-business-app.git",
"git_http_url": "http://git.tencent.com/code/code-business/code-business-app.git",
"git_https_url": "https://git.tencent.com/code/code-business/code-business-app.git",
"visibility_level": "0"
}
}
},
{
"title": null,
"project_id": 28,
"action_name": "CREATED",
"target_id": 387,
"target_type": "MergeRequest",
"author_id": 11323,
"author_username": "luci",
"created_at": "2017-09-25T08:46:28+0000",
"target_title": null,
"data": {}
},
{
"title": null,
"project_id": 28,
"action_name": "COMMENTED",
"target_id": 732,
"target_type": "note",
"author_id": 11323,
"author_username": "luci",
"created_at": "2017-09-24T08:46:28+0000",
"target_title": null,
"data": {}
}
]