Skip to content

Get label list

GET /api/v8/enterprises/{enterprise}/labels

Get the list of labels under an enterprise (organization), with support for keyword search, pagination, and sorting.

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)
sort query string No Sort field, enum: created_at / updated_at / name; default updated_at
direction query string No Sort direction, enum: asc / desc; default desc
search query string No Keyword query
page query integer No The current page number
per_page query integer No The number of items per page, maximum 100, default 20

Response parameters

Field Type Always returned Nullable Description
id integer Yes No Label ID
name string Yes No Label name
color string Yes No Label color
url string No Yes Label URL
repository_id integer No Yes Repository ID
created_at string No Yes Creation time
updated_at string No Yes Update time

Note: The response body is an array of label objects; the fields in the table above are the fields of each element in the array.

Error responses

400 Invalid parameters

{
  "error": "invalid_request",
  "message": "Invalid parameters"
}

401 Unauthenticated

{
  "error": "unauthorized",
  "message": "Missing or invalid access token"
}

404 Enterprise not found

{
  "error": "not_found",
  "message": "Enterprise does not exist"
}

The actual error field names are determined by what the backend returns.

HTTP status codes

Status code Description
200 Success (OK)
401 Requires authentication
403 Forbidden
404 Not found
429 Too many requests
500 Internal server error

Request example

Parameter notes

Replace <enterprise> with the path name of the enterprise/organization (the address path of an enterprise, organization, or individual); this endpoint allows anonymous access, and you can also carry access_token (user authorization code) in the query parameters for authentication.

cURL

curl -X GET 'https://api.atomgit.com/api/v8/enterprises/<enterprise>/labels?sort=updated_at&direction=desc&page=1&per_page=20' \
  -H 'Accept: application/json'

JavaScript

// Native fetch (Node.js 18+ / browsers)
const response = await fetch("https://api.atomgit.com/api/v8/enterprises/<enterprise>/labels?sort=updated_at&direction=desc&page=1&per_page=20", {
  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

resp = requests.get(
    "https://api.atomgit.com/api/v8/enterprises/<enterprise>/labels",
    params={
        "sort": "updated_at",
        "direction": "desc",
        "page": 1,
        "per_page": 20,
    },
    headers={"Accept": "application/json"},
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

Response example

Status code: 200

[
  {
    "id": 382218,
    "name": "bug",
    "color": "#e03529",
    "url": "https://api.atomgit.com/enterprises/example/labels/382218",
    "repository_id": 1,
    "created_at": "2024-10-09T18:37:00",
    "updated_at": "2024-10-09T18:37:00"
  }
]

Error codes

Error code Description
401 Unauthenticated or invalid credentials (missing/invalid access credentials)
400 Invalid parameters or the request cannot be parsed
404 Request path does not exist
405 Request method not supported
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