Get all enterprise labels¶
GET /api/v5/enterprises/{enterprise}/labels
This endpoint gets all labels of the specified enterprise and supports paginated queries with a maximum of 100 per page. The result is a list of labels, including label ID, name, color, creation time, and update time, among other information, which can be used for enterprise label management and display.
Access token support¶
- AtomGit user access tokens
Anonymous access allowed¶
Anonymous access is allowed for this endpoint.
Request parameters¶
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
enterprise |
path | string | Yes | The namespace address the repository belongs to (the address path of an enterprise, organization, or individual) |
access_token |
query | string | No | User authorization code |
page |
query | string | No | The current page number |
per_page |
query | string | No | The number of items per page, maximum 100, default 100 |
Response parameters¶
The response body is a JSON array whose elements are label objects, with the following fields:
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
id |
integer | Yes | — | Label ID |
name |
string | Yes | — | Label name |
color |
string | Yes | — | Label color |
created_at |
string | Yes | — | Label creation time |
updated_at |
string | Yes | — | Label update time |
Error responses¶
This endpoint returns non-200 status codes (such as 400, 401, 404) when parameters are invalid, authentication fails, or the resource does not exist. The specific field names of the error response body are determined by what the backend returns.
HTTP status codes¶
| Status code | Description |
|---|---|
200 |
Success (OK) |
401 |
Requires authentication |
403 |
Forbidden |
404 |
Not found |
500 |
Internal server error |
Request example¶
Parameter notes¶
Replace
<enterprise>with the namespace address the repository belongs to (the address path of an enterprise, organization, or individual); replace<token>with your AtomGit user access token (optional; this endpoint allows anonymous access).
cURL¶
curl -X GET 'https://api.atomgit.com/api/v5/enterprises/<enterprise>/labels?access_token=<token>' \
-H 'Accept: application/json'
This endpoint allows anonymous access;
access_tokenis an optional parameter and may be omitted.
JavaScript¶
// Native fetch (Node.js 18+ / browsers)
const enterprise = "<enterprise>";
const token = "<token>"; // Optional; this endpoint allows anonymous access
const url = `https://api.atomgit.com/api/v5/enterprises/${enterprise}/labels${
token ? `?access_token=${token}` : ""
}`;
const response = await fetch(url, {
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
enterprise = "<enterprise>"
token = "<token>" # Optional; this endpoint allows anonymous access
params = {}
if token:
params["access_token"] = token
resp = requests.get(
f"https://api.atomgit.com/api/v5/enterprises/{enterprise}/labels",
params=params,
headers={"Accept": "application/json"},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
Response example¶
Status code: 200
[
{
"id": 471,
"name": "aaaaa",
"color": "#2865E0",
"created_at": "2024-11-22T11:25:36.769+08:00",
"updated_at": "2024-11-22T11:25:36.769+08:00"
}
]
Error codes¶
| Error code | Description |
|---|---|
400 |
Invalid parameters or the request cannot be parsed |
401 |
Unauthenticated or invalid credentials (missing/invalid access credentials) |
404 |
Request path does not exist |
429 |
Too many requests, rate limit triggered |
500 |
Internal system error |
Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc