User API Documentation
1. Get a user
Request
GET https://api.gitcode.com/api/v5/users/{username}
Parameters
Parameter |
Type |
Data Type |
Description |
|---|---|---|---|
access_token |
query |
string |
personal access token |
username* |
path |
string |
username |
Response
{
"avatar_url": "https://cdn-img.gitcode.com/ec/fb/430ecf07b9ee91bbbbf341d92a36783d06e69086f82ce8cf5a6406f79f1c9cf4.png",
"followers_url": "https://api.gitcode.com/api/v5users/dengmengmian/followers",
"html_url": "https://gitcode.com/dengmengmian",
"id": "650d67fbae6d795139b49b41",
"login": "dengmengmian",
"name": "麻凡",
"type": "User",
"url": "https://api.gitcode.com/api/v5/dengmengmian",
"bio": "Nacos是由阿里巴巴开源的服务治理中间件,集成了动态服务发现、配置管理和服务元数据管理功能,广泛应用于微服务架构中,简化服务治理过程。",
"blog": "https://www.dengmengmian.com",
"company": "开发者",
"email": "my@dengmengmian.com",
"followers": 0,
"following": 6,
"top_languages": ["Python", "Shell"]
}
Demo
curl --location 'https://api.gitcode.com/api/v5/users/dengmengmian' \
--header 'Authorization: Bearer {your-token}'
4. Get the personal activity of a user
Request
GET https://api.gitcode.com/api/v5/users/{username}/events
Parameters
Parameter |
Type |
Data Type |
Description |
|---|---|---|---|
username |
path |
string |
username |
access_token* |
query |
string |
personal access token |
year |
ery st |
ring |
Start Year(2024) qu |
next |
query |
string |
End Date |
Response
{
"events": {
"2024-08-27": [
{
"action": 5,
"action_name": "pushed to",
"author": {
"id": 704,
"iam_id": "5c340cab034d455992541f00f9936fb4",
"username": "dengmengmian",
"state": "active",
"avatar_url": "https://gitcode-img.obs.cn-south-1.myhuaweicloud.com:443/fa/fe/f32a9fecc53e890afbd48fd098b0f6c5f20f062581400c76c85e5baab3f0d5b2.png",
"email": "",
"name": "dengmengmian",
"name_cn": "dengmengmian",
"web_url": "https://test.gitcode.net/dengmengmian"
},
"author_id": 704,
"author_username": "dengmengmian",
"created_at": "2024-08-27T10:34:05.093Z",
"project": {
"main_repository_language": [null, null],
"star_count": 0,
"forks_count": 0,
"develop_mode": "normal",
"stared": false
},
"project_id": 507167,
"project_name": "mactribe/midsommarcartoon",
"push_data": {
"commit_count": 1,
"action": "pushed",
"ref_type": "branch",
"commit_from": "2ce472fec073f77804c3480ccf128219a6172e54",
"commit_to": "14b742fe434797fb073ba536804011f735f2f430",
"ref": "main",
"commit_title": "文件title"
},
"_links": {
"project": "https://test.gitcode.net/mactribe/midsommarcartoon",
"action_type": ""
}
},
{
"action": 5,
"action_name": "pushed to",
"author": {
"id": 704,
"iam_id": "5c340cab034d455992541f00f9936fb4",
"username": "dengmengmian",
"state": "active",
"avatar_url": "https://gitcode-img.obs.cn-south-1.myhuaweicloud.com:443/fa/fe/f32a9fecc53e890afbd48fd098b0f6c5f20f062581400c76c85e5baab3f0d5b2.png",
"email": "",
"name": "dengmengmian",
"name_cn": "dengmengmian",
"web_url": "https://test.gitcode.net/dengmengmian"
},
"author_id": 704,
"author_username": "dengmengmian",
"created_at": "2024-08-27T10:31:17.494Z",
"project": {
"main_repository_language": [null, null],
"star_count": 0,
"forks_count": 0,
"develop_mode": "normal",
"stared": false
},
"project_id": 507167,
"project_name": "mactribe/midsommarcartoon",
"push_data": {
"commit_count": 1,
"action": "pushed",
"ref_type": "branch",
"commit_from": "ee25b0353dae9bf19f5e3e733e651e7870020386",
"commit_to": "2ce472fec073f77804c3480ccf128219a6172e54",
"ref": "main",
"commit_title": "文件title"
},
"_links": {
"project": "https://test.gitcode.net/mactribe/midsommarcartoon",
"action_type": ""
}
}
]
},
"next": "2024-08-01T10:10:40.370Z"
}
Demo
curl --location -g --request GET 'https://api.gitcode.com/api/v5/users/dengmengmian/events?access_token={your-token}&year=2024&next=2024-09-05T13%3A48%3A47.370Z'
5. Get the public repositories of a user
Request
GET https://api.gitcode.com/api/v5/users/{username}/repos
Parameters
Parameter |
Type |
Data Type |
Description |
|---|---|---|---|
access_token* |
query |
string |
personal access token |
username* |
path |
string |
username(username/login) |
type |
query |
string |
用户创建的仓库(owner),用户个人仓库(personal),用户为仓库成员(member),所有(all)。Default: 所有(all) Repository Ownership Types: Owner(Repositories created by the user), Personal(The user’s personal repositories), Member(Repositories where the user is a member), All(All repositories).Default: all |
sort |
query |
string |
Sorting Options: Created(Sort by creation time), Updated(Sort by update time), Pushed(Sort by last pushed time), Full Name(Sort by repository’s full name). Default: full_name |
direction |
query |
string |
If the sort parameter is set to full_name, the sorting will be in ascending order (asc). Otherwise, it will be in descending order (desc). |
page |
query |
int |
Current Page Number |
per_page |
query |
int |
Items Per Page, Maximum 100 |
Response
[
{
"id": 2734882,
"full_name": "dengmengmian/manifest",
"human_name": "dengmengmian / manifest",
"url": "https://api.gitcode.com/api/v5/repos/dengmengmian/manifest",
"namespace": {
"id": 199940,
"type": "user",
"name": "dengmengmian",
"path": "dengmengmian",
"html_url": "https://gitcode.com/dengmengmian"
},
"path": "manifest",
"name": "manifest",
"description": "manifest",
"status": "开始",
"ssh_url_to_repo": "git@gitcode.com:dengmengmian/manifest.git",
"http_url_to_repo": "https://gitcode.com/dengmengmian/manifest.git",
"web_url": "https://gitcode.com/dengmengmian/manifest",
"homepage": "https://gitcode.com/dengmengmian/manifest",
"members": ["dengmengmian"],
"assignee": [
{
"id": "268",
"login": "dengmengmian",
"name": "麻凡",
"avatar_url": "https://cdn-img.gitcode.com/ec/fb/430ecf07b9ee91bbbbf341d92a36783d06e69086f82ce8cf5a6406f79f1c9cf4.png",
"html_url": "https://gitcode.com/dengmengmian",
"type": "User"
}
],
"forks_count": 0,
"stargazers_count": 0,
"project_labels": [],
"relation": "master",
"permission": {
"pull": true,
"push": true,
"admin": true
},
"internal": false,
"open_issues_count": 0,
"has_issue": false,
"watched": false,
"watchers_count": 0,
"assignees_number": 1,
"enterprise": {
"id": 199940,
"path": "dengmengmian",
"html_url": "https://gitcode.com/dengmengmian",
"type": "user"
},
"default_branch": "master",
"fork": false,
"owner": {
"id": "268",
"login": "dengmengmian",
"name": "麻凡",
"type": "User"
},
"assigner": {
"id": "268",
"login": "dengmengmian",
"name": "麻凡",
"type": "User"
},
"issue_template_source": "project",
"private": false,
"public": true,
"gitee": {
"star": 10,
"fork": 15,
"watch": 1
}
}
]
Demo
curl --location -g --request GET 'https://api.gitcode.com/api/v5/users/dengmengmian/repos?access_token=yuBy&type=all&sort=full_name&page=1&pre_page=20'
6. Create a personal project repository
Request
POST https://api.gitcode.com/api/v5/user/repos
Parameters
Parameter |
Type |
Data Type |
Description |
|---|---|---|---|
access_token* |
query |
string |
personal access token |
name* |
formData |
string |
Repository Name |
description |
formData |
string |
Repository Description |
has_issues |
formData |
boolean |
Allow Issues to Be Created (Enabled/Disabled). Default: true |
has_wiki |
formData |
boolean |
Provide Wiki (Enabled/Disabled). Default: true |
auto_init |
formData |
boolean |
If the value is true, the repository will be initialized with a README. Default: Not Initialized (false) |
gitignore_template |
formData |
string |
gitignore template |
license_template |
formData |
string |
license template |
path |
formData |
string |
Repository Path |
private |
formData |
boolean |
Is Private |
default_branch |
formData |
string |
Default Branch Name when Initializing a Repository.Default: main |
*表示必填项。
Response
返回 “success” 表示成功,其他为失败
{
"id": 4106383,
"full_name": "dengmengmian/wunian-prj",
"human_name": "dengmengmian / wunian-prj",
"url": "https://api.gitcode.com/api/v5/user/repos",
"namespace": {
"id": 199940,
"name": "dengmengmian",
"path": "dengmengmian",
"develop_mode": "normal",
"kind": "user",
"full_path": "dengmengmian",
"full_name": "dengmengmian",
"visibility_level": 20,
"enable_file_control": false,
"owner_id": 268
},
"path": "wunian-prj",
"name": "wunian-prj",
"description": "wunian-prj",
"private": true,
"public": false,
"visibility": "private"
}
Demo
curl --location -g --request POST 'https://api.gitcode.com/api/v5/user/repos?access_token={your-token}' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "wunian-prj",
"description": "wunian-prj",
"has_issues": true,
"has_wiki": true,
"can_comment": true,
"public": 0,
"private": true,
"auto_init": true,
"gitignore_template": "string",
"license_template": "string",
"path": "wunian-prj"
}'
8. Get a specific repository of a user
Request
GET https://api.gitcode.com/api/v5/repos/{owner}/{repo}
Parameter |
Type |
Data Type |
Description |
|---|---|---|---|
access_token* |
query |
string |
personal access token |
owner* |
path |
string |
Repository Owner Path (Organization or User Path) |
repo* |
path |
string |
Repository Path(path) |
Response
{
"id": 4250980,
"full_name": "aron1/Model10123001",
"human_name": "aron1 / Model10123001tewteewtewteewtewteewtewteewtewteewtewteewtewteewtewteewtewteewtewteewtewteewtewteewtew",
"url": "https://api.gitcode.com/api/v5/repos/aron1/Model10123001",
"namespace": {
"id": 1364544,
"name": "aron1",
"path": "aron1",
"html_url": "https://gitcode.com/aron1"
},
"path": "Model10123001",
"name": "Model10123001tewteewtewteewtewteewtewteewtewteewtewteewtewteewtewteewtewteewtewteewtewteewtewteewtew",
"description": "",
"status": "关闭",
"ssh_url_to_repo": "git@gitcode.com:aron1/Model10123001.git",
"http_url_to_repo": "https://gitcode.com/aron1/Model10123001.git",
"web_url": "https://gitcode.com/aron1/Model10123001",
"readme_url": "https://gitcode.com/aron1/Model10123001/blob/main/README.md",
"created_at": "2024-10-22T22:14:06.922+08:00",
"updated_at": "2024-12-02T18:37:23.426+08:00",
"creator": {
"id": "660ba866683c570b25be06c8",
"arts_id": "332008",
"username": "aron1",
"nickname": "yanfan",
"email": "aron1@noreply.gitcode.com",
"photo": "https://cdn-img.gitcode.com/bd/ca/0115343247b338d0c53589a145501e84a58464272f2fb09b372cc3d2311b2b39.png?time=1722525295285"
},
"members": [
"aron1"
],
"forks_count": 0,
"stargazers_count": 1,
"project_labels": [],
"license": "Apache_License_v2.0",
"internal": false,
"open_issues_count": 0,
"watchers_count": 0,
"assignees_number": 0,
"enterprise": {
"id": 1364544,
"path": "aron1",
"html_url": "https://gitcode.com/aron1",
"type": "user"
},
"default_branch": "main",
"fork": false,
"owner": {
"id": "332008",
"login": "aron1",
"name": "yanfan",
"type": "User"
},
"assigner": {
"id": "332008",
"login": "aron1",
"name": "yanfan",
"type": "User"
},
"issue_template_source": "project",
"private": true,
"public": false
}
Demo
curl --location 'https://api.gitcode.com/api/v5/repos/xiaogang/test?access_token=?'
9. Add a public key
Request
POST https://api.gitcode.com/api/v5/user/keys
Parameters
Parameter |
Type |
Data Type |
Description |
|---|---|---|---|
access_token* |
query |
string |
personal access token |
key* |
body |
string |
Public Key Content |
title* |
body |
string |
Public Key Name |
Response
{
"id": 311915,
"title": "555555",
"key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIa6IyTGuI8V5wrhANDFyezQqL73dY9ctLGHgpOggp7E Gitee",
"created_at": "2024-11-14T03:34:40.318+00:00",
"url": "https://api.gitcode.com/v5/user/keys/311915"
}
Demo
curl --location --request POST 'https://api.gitcode.com/api/v5/user/keys?access_token=?' \
--header 'Content-Type: application/json;charset=UTF-8' \
--data '{
"key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIa6IyTGuI8V5wrhANDFyezQqL73dY9ctLGHgpOggp7E Gitee SSH Key",
"title": "555555"
}'
11. Delete a public key
Request
DELETE https://api.gitcode.com/api/v5/user/keys/{id}
Parameters
Parameter |
Type |
Data Type |
Description |
|---|---|---|---|
access_token* |
query |
string |
personal access token |
id* |
path |
string |
Public Key ID |
Response
无
Demo
curl --location --request DELETE 'https://api.gitcode.com/api/v5/user/keys/311914?access_token=?'
12. Get a specific public key
Request
GET https://api.gitcode.com/api/v5/user/keys/{id}
Parameters
Parameter |
Type |
Data Type |
Description |
|---|---|---|---|
access_token* |
query |
string |
personal access token |
id* |
path |
string |
Public Key ID |
Response
[
{
"id": 308357,
"title": "xiaogang@csdn.net\r\n",
"key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCwT9UXXtGfLa16tbxV+0RQ6m+BaAG2wJvqApr+juVNEmnM0lKNt1tyxY/V9SsCRf38UprPLTp71+btRpFIH9TLrGhkvT3tJOouYDXVUpSaigi7OO+6eLc+Cn0TZSLj4RmwVe/w93kmsCUzgqkeHk14K3S+2oCCm1rbpBAvpPhSKHhAH9LcTBecDoZ+NA2dsEDyfsloVH5cMJQO9n2W1QYduMuuaVHHpehSdDohN7cDI799Rwofaqqyz6ZJrc6eBjSVi1W+JPDTT6NW0+eFBYXo3KWybffixH4cAWdbS1Ms5Pe9Xh+G4WqFuhFh9zCoXlRUUrArLo5pYfpy5gv4iUVmniM0Pb0/Y5x8RJyGaPdS/2c68s8LQsm/9Ees8aeE5TcT5isDEvh+wy7jp1xi5nONk9QvOy7EdYYeHQtkw/0rklsz7UvAIjjHObNNYpY6RLQRT+dqN/lAb7stT047FSxqcNMCX/cybapLygs1y2ClcgU42p16RfgCH0NKA5emRhM= xiaogang@csdn.net",
"created_at": "2024-07-23T10:29:42.119+00:00",
"url": "https://api.gitcode.com/v5/user/keys/308357"
}
]
Demo
curl --location 'https://api.gitcode.com/api/v5/user/keys/311914?access_token=?'