View a repository member's permissions¶
GET /api/v5/repos/{owner}/{repo}/collaborators/{username}/permission
This endpoint queries the permission information of a member in the specified repository, including the member's basic profile, permission level (admin/write/read), and permission details, so that you can see which operations the member can perform in the repository.
Supported access tokens¶
- AtomGit user access tokens
Anonymous access¶
This endpoint does not allow anonymous access.
Request parameters¶
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
owner |
path | string | Yes | Namespace address of the repository (address path of the enterprise, organization, or individual) |
repo |
path | string | Yes | Repository path (path) |
username |
path | string | Yes | User name (username/login); a numeric-only value is not supported |
access_token |
query | string | Yes | User authorization code |
Response parameters¶
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
id |
string | Yes | Yes | User ID |
name |
string | Yes | Yes | User name |
username |
string | Yes | Yes | Username |
login |
string | Yes | Yes | Login name (same as username) |
nick_name |
string | Yes | Yes | User nickname |
state |
string | Yes | Yes | State |
email |
string | Yes | Yes | User email address |
web_url |
string | Yes | Yes | Web URL |
access_level |
integer | Yes | Yes | Permission level |
type |
string | Yes | Yes | Type |
join_way |
string | Yes | Yes | Join method |
source_name |
string | Yes | Yes | Source name |
role_name |
string | Yes | Yes | Role name |
role_name_cn |
string | Yes | Yes | Role name in Chinese |
object_id |
string | No | Yes | Internal object ID of the user; returned when the user information associated with the member exists |
permission |
string | Yes | Yes | Member permission; enum: admin / write / read |
permissions |
object | Yes | Yes | Permission details object |
permissions object
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
permissions.pull |
boolean | No | Yes | Whether the member can pull; currently not populated |
permissions.push |
boolean | No | Yes | Whether the member can push; currently not populated |
permissions.admin |
boolean | Yes | Yes | Whether the member is an administrator (true when access_level is 50) |
HTTP status codes¶
| Status code | Description |
|---|---|
200 |
Success (OK) |
401 |
Authentication required (Requires authentication) |
404 |
Member not found (User not found) |
Request example¶
Parameter notes¶
Replace
<owner>with the namespace address of the repository (address path of the enterprise, organization, or individual);
replace<repo>with the repository path (path);
replace<username>with the user name (username/login);
replace<token>with your AtomGit user access token.
cURL¶
curl -X GET 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/collaborators/<username>/permission?access_token=<token>' \
-H 'Accept: application/json'
JavaScript¶
// Native fetch (Node.js 18+ / browser)
const owner = "<owner>";
const repo = "<repo>";
const username = "<username>";
const token = "<YOUR-TOKEN>";
const response = await fetch(
`https://api.atomgit.com/api/v5/repos/${owner}/${repo}/collaborators/${username}/permission?access_token=${token}`,
{
headers: {
"Accept": "application/json",
},
}
);
if (!response.ok) {
throw new Error(`Request failed: ${response.status}`);
}
const data = await response.json();
console.log(data);
Python¶
import requests
owners = "<owner>"
repo = "<repo>"
username = "<username>"
token = "<YOUR-TOKEN>"
resp = requests.get(
f"https://api.atomgit.com/api/v5/repos/{owners}/{repo}/collaborators/{username}/permission",
params={"access_token": token},
headers={"Accept": "application/json"},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
Response example¶
Status code: 200
{
"id": "268",
"name": "Zhang San",
"username": "zhangsan",
"nick_name": "Zhang San",
"state": "active",
"email": "zhangsan@example.com",
"web_url": "https://api.atomgit.com/zhangsan",
"access_level": 50,
"type": "member",
"join_way": "invite",
"source_name": "zhangsan",
"role_name": "admin",
"role_name_cn": "Administrator",
"object_id": "1001",
"permission": "admin",
"permissions": {
"pull": true,
"push": true,
"admin": true
}
}
Error codes¶
| Error code | Description |
|---|---|
401 |
Unauthenticated or invalid credentials (missing or invalid access token) |
404 |
The user is not a member of the repository, or the user does not exist |
500 |
Internal server error |
Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc