labels
Creates, updates, deletes, gets or lists a labels resource.
Overview
| Name | labels |
| Type | Resource |
| Id | github.issues.labels |
Fields
The following fields are returned by SELECT queries:
- list_labels_on_issue
- get_label
- list_labels_for_milestone
- list_labels_for_repo
Response
| Name | Datatype | Description |
|---|---|---|
id | integer (int64) | Unique identifier for the label. |
name | string | The name of the label. (example: bug) |
node_id | string | (example: MDU6TGFiZWwyMDgwNDU5NDY=) |
color | string | 6-character hex code, without the leading #, identifying the color (example: FFFFFF) |
default | boolean | Whether this label comes by default in a new repository. |
description | string | Optional description of the label, such as its purpose. (example: Something isn't working) |
url | string (uri) | URL for the label (example: https://api.github.com/repositories/42/labels/bug) |
Response
| Name | Datatype | Description |
|---|---|---|
id | integer (int64) | Unique identifier for the label. |
name | string | The name of the label. (example: bug) |
node_id | string | (example: MDU6TGFiZWwyMDgwNDU5NDY=) |
color | string | 6-character hex code, without the leading #, identifying the color (example: FFFFFF) |
default | boolean | Whether this label comes by default in a new repository. |
description | string | Optional description of the label, such as its purpose. (example: Something isn't working) |
url | string (uri) | URL for the label (example: https://api.github.com/repositories/42/labels/bug) |
Response
| Name | Datatype | Description |
|---|---|---|
id | integer (int64) | Unique identifier for the label. |
name | string | The name of the label. (example: bug) |
node_id | string | (example: MDU6TGFiZWwyMDgwNDU5NDY=) |
color | string | 6-character hex code, without the leading #, identifying the color (example: FFFFFF) |
default | boolean | Whether this label comes by default in a new repository. |
description | string | Optional description of the label, such as its purpose. (example: Something isn't working) |
url | string (uri) | URL for the label (example: https://api.github.com/repositories/42/labels/bug) |
Response
| Name | Datatype | Description |
|---|---|---|
id | integer (int64) | Unique identifier for the label. |
name | string | The name of the label. (example: bug) |
node_id | string | (example: MDU6TGFiZWwyMDgwNDU5NDY=) |
color | string | 6-character hex code, without the leading #, identifying the color (example: FFFFFF) |
default | boolean | Whether this label comes by default in a new repository. |
description | string | Optional description of the label, such as its purpose. (example: Something isn't working) |
url | string (uri) | URL for the label (example: https://api.github.com/repositories/42/labels/bug) |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
list_labels_on_issue | select | owner, repo, issue_number | per_page, page | Lists all labels for an issue. |
get_label | select | owner, repo, name | Gets a label using the given name. | |
list_labels_for_milestone | select | owner, repo, milestone_number | per_page, page | Lists labels for issues in a milestone. |
list_labels_for_repo | select | owner, repo | per_page, page | Lists all labels for a repository. |
add_labels | insert | owner, repo, issue_number | Adds labels to an issue. | |
create_label | insert | owner, repo, name | Creates a label for the specified repository with the given name and color. The name and color parameters are required. The color must be a valid hexadecimal color code. | |
update_label | update | owner, repo, name | Updates a label using the given label name. | |
set_labels | replace | owner, repo, issue_number | Removes any previous labels and sets the new labels for an issue. | |
remove_label | delete | owner, repo, issue_number, name | Removes the specified label from the issue, and returns the remaining labels on the issue. This endpoint returns a 404 Not Found status if the label does not exist. | |
remove_all_labels | delete | owner, repo, issue_number | Removes all labels from an issue. | |
delete_label | delete | owner, repo, name | Deletes a label using the given label name. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
issue_number | integer | The number that identifies the issue. |
milestone_number | integer | The number that identifies the milestone. |
name | string | |
owner | string | The account owner of the repository. The name is not case sensitive. |
repo | string | The name of the repository without the .git extension. The name is not case sensitive. |
page | integer | The page number of the results to fetch. For more information, see "Using pagination in the REST API." |
per_page | integer | The number of results per page (max 100). For more information, see "Using pagination in the REST API." |
SELECT examples
- list_labels_on_issue
- get_label
- list_labels_for_milestone
- list_labels_for_repo
Lists all labels for an issue.
SELECT
id,
name,
node_id,
color,
default,
description,
url
FROM github.issues.labels
WHERE owner = '{{ owner }}' -- required
AND repo = '{{ repo }}' -- required
AND issue_number = '{{ issue_number }}' -- required
AND per_page = '{{ per_page }}'
AND page = '{{ page }}'
;
Gets a label using the given name.
SELECT
id,
name,
node_id,
color,
default,
description,
url
FROM github.issues.labels
WHERE owner = '{{ owner }}' -- required
AND repo = '{{ repo }}' -- required
AND name = '{{ name }}' -- required
;
Lists labels for issues in a milestone.
SELECT
id,
name,
node_id,
color,
default,
description,
url
FROM github.issues.labels
WHERE owner = '{{ owner }}' -- required
AND repo = '{{ repo }}' -- required
AND milestone_number = '{{ milestone_number }}' -- required
AND per_page = '{{ per_page }}'
AND page = '{{ page }}'
;
Lists all labels for a repository.
SELECT
id,
name,
node_id,
color,
default,
description,
url
FROM github.issues.labels
WHERE owner = '{{ owner }}' -- required
AND repo = '{{ repo }}' -- required
AND per_page = '{{ per_page }}'
AND page = '{{ page }}'
;
INSERT examples
- add_labels
- create_label
- Manifest
Adds labels to an issue.
INSERT INTO github.issues.labels (
labels,
owner,
repo,
issue_number
)
SELECT
'{{ labels }}',
'{{ owner }}',
'{{ repo }}',
'{{ issue_number }}'
RETURNING
id,
name,
node_id,
color,
default,
description,
url
;
Creates a label for the specified repository with the given name and color. The name and color parameters are required. The color must be a valid hexadecimal color code.
INSERT INTO github.issues.labels (
name,
color,
description,
owner,
repo
)
SELECT
'{{ name }}' /* required */,
'{{ color }}',
'{{ description }}',
'{{ owner }}',
'{{ repo }}'
RETURNING
id,
name,
node_id,
color,
default,
description,
url
;
# Description fields are for documentation purposes
- name: labels
props:
- name: owner
value: "{{ owner }}"
description: Required parameter for the labels resource.
- name: repo
value: "{{ repo }}"
description: Required parameter for the labels resource.
- name: issue_number
value: {{ issue_number }}
description: Required parameter for the labels resource.
- name: labels
value:
- "{{ labels }}"
description: |
The names of the labels to add to the issue's existing labels. You can also pass an `array` of labels directly, but GitHub recommends passing an object with the `labels` key. To replace all of the labels for an issue, use "[Set labels for an issue](https://docs.github.com/rest/issues/labels#set-labels-for-an-issue)."
- name: name
value: "{{ name }}"
description: |
The name of the label. Emoji can be added to label names, using either native emoji or colon-style markup. For example, typing `:strawberry:` will render the emoji . For a full list of available emoji and codes, see "[Emoji cheat sheet](https://github.com/ikatyang/emoji-cheat-sheet)."
- name: color
value: "{{ color }}"
description: |
The [hexadecimal color code](http://www.color-hex.com/) for the label, without the leading `#`.
- name: description
value: "{{ description }}"
description: |
A short description of the label. Must be 100 characters or fewer.
UPDATE examples
- update_label
Updates a label using the given label name.
UPDATE github.issues.labels
SET
new_name = '{{ new_name }}',
color = '{{ color }}',
description = '{{ description }}'
WHERE
owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
AND name = '{{ name }}' --required
RETURNING
id,
name,
node_id,
color,
default,
description,
url;
REPLACE examples
- set_labels
Removes any previous labels and sets the new labels for an issue.
REPLACE github.issues.labels
SET
labels = '{{ labels }}'
WHERE
owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
AND issue_number = '{{ issue_number }}' --required
RETURNING
id,
name,
node_id,
color,
default,
description,
url;
DELETE examples
- remove_label
- remove_all_labels
- delete_label
Removes the specified label from the issue, and returns the remaining labels on the issue. This endpoint returns a 404 Not Found status if the label does not exist.
DELETE FROM github.issues.labels
WHERE owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
AND issue_number = '{{ issue_number }}' --required
AND name = '{{ name }}' --required
;
Removes all labels from an issue.
DELETE FROM github.issues.labels
WHERE owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
AND issue_number = '{{ issue_number }}' --required
;
Deletes a label using the given label name.
DELETE FROM github.issues.labels
WHERE owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
AND name = '{{ name }}' --required
;