ラベル
REST API を使用して、リポジトリ、issue、pull request のラベルを管理します。
ラベルについて
REST API を使用してリポジトリのラベルを管理し、issue と pull request に対してラベルの追加と削除を行うことができます。 すべてのPull Requestは Issue ですが、すべての Issue がPull Requestというわけではありません。 このため、担当者、ラベル、マイルストーンの管理など、両機能で "共通する" アクションは Issues エンドポイント内に用意されています。
List labels for an issue
パラメーター
| ヘッダー |
|---|
| 名前, Type, 説明 |
acceptstringSetting to |
| パス パラメーター |
| 名前, Type, 説明 |
ownerstring必須The account owner of the repository. The name is not case sensitive. |
repostring必須The name of the repository. The name is not case sensitive. |
issue_numberinteger必須The number that identifies the issue. |
| クエリ パラメーター |
| 名前, Type, 説明 |
per_pageintegerThe number of results per page (max 100). Default: |
pageintegerPage number of the results to fetch. Default: |
HTTP 応答状態コード
| 状態コード | 説明 |
|---|---|
200 | OK |
301 | Moved permanently |
404 | Resource not found |
410 | Gone |
コード サンプル
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER/labelsResponse
Status: 200[
{
"id": 208045946,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDY=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/bug",
"name": "bug",
"description": "Something isn't working",
"color": "f29513",
"default": true
},
{
"id": 208045947,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDc=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/enhancement",
"name": "enhancement",
"description": "New feature or request",
"color": "a2eeef",
"default": false
}
]Add labels to an issue
パラメーター
| ヘッダー |
|---|
| 名前, Type, 説明 |
acceptstringSetting to |
| パス パラメーター |
| 名前, Type, 説明 |
ownerstring必須The account owner of the repository. The name is not case sensitive. |
repostring必須The name of the repository. The name is not case sensitive. |
issue_numberinteger必須The number that identifies the issue. |
| 本文のパラメーター |
| 名前, Type, 説明 |
labelsarray of stringsThe names of the labels to add to the issue's existing labels. You can pass an empty array to remove all labels. Alternatively, you can pass a single label as a |
HTTP 応答状態コード
| 状態コード | 説明 |
|---|---|
200 | OK |
301 | Moved permanently |
404 | Resource not found |
410 | Gone |
422 | Validation failed, or the endpoint has been spammed. |
コード サンプル
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER/labels \
-d '{"labels":["bug","enhancement"]}'Response
Status: 200[
{
"id": 208045946,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDY=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/bug",
"name": "bug",
"description": "Something isn't working",
"color": "f29513",
"default": true
},
{
"id": 208045947,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDc=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/enhancement",
"name": "enhancement",
"description": "New feature or request",
"color": "a2eeef",
"default": false
}
]Set labels for an issue
Removes any previous labels and sets the new labels for an issue.
パラメーター
| ヘッダー |
|---|
| 名前, Type, 説明 |
acceptstringSetting to |
| パス パラメーター |
| 名前, Type, 説明 |
ownerstring必須The account owner of the repository. The name is not case sensitive. |
repostring必須The name of the repository. The name is not case sensitive. |
issue_numberinteger必須The number that identifies the issue. |
| 本文のパラメーター |
| 名前, Type, 説明 |
labelsarray of stringsThe names of the labels to set for the issue. The labels you set replace any existing labels. You can pass an empty array to remove all labels. Alternatively, you can pass a single label as a |
HTTP 応答状態コード
| 状態コード | 説明 |
|---|---|
200 | OK |
301 | Moved permanently |
404 | Resource not found |
410 | Gone |
422 | Validation failed, or the endpoint has been spammed. |
コード サンプル
curl \
-X PUT \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER/labels \
-d '{"labels":["bug","enhancement"]}'Response
Status: 200[
{
"id": 208045946,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDY=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/bug",
"name": "bug",
"description": "Something isn't working",
"color": "f29513",
"default": true
},
{
"id": 208045947,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDc=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/enhancement",
"name": "enhancement",
"description": "New feature or request",
"color": "a2eeef",
"default": false
}
]Remove all labels from an issue
パラメーター
| ヘッダー |
|---|
| 名前, Type, 説明 |
acceptstringSetting to |
| パス パラメーター |
| 名前, Type, 説明 |
ownerstring必須The account owner of the repository. The name is not case sensitive. |
repostring必須The name of the repository. The name is not case sensitive. |
issue_numberinteger必須The number that identifies the issue. |
HTTP 応答状態コード
| 状態コード | 説明 |
|---|---|
204 | No Content |
301 | Moved permanently |
404 | Resource not found |
410 | Gone |
コード サンプル
curl \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER/labelsResponse
Status: 204Remove a label from an issue
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.
パラメーター
| ヘッダー |
|---|
| 名前, Type, 説明 |
acceptstringSetting to |
| パス パラメーター |
| 名前, Type, 説明 |
ownerstring必須The account owner of the repository. The name is not case sensitive. |
repostring必須The name of the repository. The name is not case sensitive. |
issue_numberinteger必須The number that identifies the issue. |
namestring必須 |
HTTP 応答状態コード
| 状態コード | 説明 |
|---|---|
200 | OK |
301 | Moved permanently |
404 | Resource not found |
410 | Gone |
コード サンプル
curl \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER/labels/NAMEResponse
Status: 200[
{
"id": 208045946,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDY=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/bug",
"name": "bug",
"description": "Something isn't working",
"color": "f29513",
"default": true
}
]List labels for a repository
パラメーター
| ヘッダー |
|---|
| 名前, Type, 説明 |
acceptstringSetting to |
| パス パラメーター |
| 名前, Type, 説明 |
ownerstring必須The account owner of the repository. The name is not case sensitive. |
repostring必須The name of the repository. The name is not case sensitive. |
| クエリ パラメーター |
| 名前, Type, 説明 |
per_pageintegerThe number of results per page (max 100). Default: |
pageintegerPage number of the results to fetch. Default: |
HTTP 応答状態コード
| 状態コード | 説明 |
|---|---|
200 | OK |
404 | Resource not found |
コード サンプル
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/labelsResponse
Status: 200[
{
"id": 208045946,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDY=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/bug",
"name": "bug",
"description": "Something isn't working",
"color": "f29513",
"default": true
},
{
"id": 208045947,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDc=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/enhancement",
"name": "enhancement",
"description": "New feature or request",
"color": "a2eeef",
"default": false
}
]Create a label
パラメーター
| ヘッダー |
|---|
| 名前, Type, 説明 |
acceptstringSetting to |
| パス パラメーター |
| 名前, Type, 説明 |
ownerstring必須The account owner of the repository. The name is not case sensitive. |
repostring必須The name of the repository. The name is not case sensitive. |
| 本文のパラメーター |
| 名前, Type, 説明 |
namestring必須The name of the label. Emoji can be added to label names, using either native emoji or colon-style markup. For example, typing |
colorstringThe hexadecimal color code for the label, without the leading |
descriptionstringA short description of the label. Must be 100 characters or fewer. |
HTTP 応答状態コード
| 状態コード | 説明 |
|---|---|
201 | Created |
404 | Resource not found |
422 | Validation failed, or the endpoint has been spammed. |
コード サンプル
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/labels \
-d '{"name":"bug","description":"Something isn'\''t working","color":"f29513"}'Response
Status: 201{
"id": 208045946,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDY=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/bug",
"name": "bug",
"description": "Something isn't working",
"color": "f29513",
"default": true
}Get a label
パラメーター
| ヘッダー |
|---|
| 名前, Type, 説明 |
acceptstringSetting to |
| パス パラメーター |
| 名前, Type, 説明 |
ownerstring必須The account owner of the repository. The name is not case sensitive. |
repostring必須The name of the repository. The name is not case sensitive. |
namestring必須 |
HTTP 応答状態コード
| 状態コード | 説明 |
|---|---|
200 | OK |
404 | Resource not found |
コード サンプル
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/labels/NAMEResponse
Status: 200{
"id": 208045946,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDY=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/bug",
"name": "bug",
"description": "Something isn't working",
"color": "f29513",
"default": true
}Update a label
パラメーター
| ヘッダー |
|---|
| 名前, Type, 説明 |
acceptstringSetting to |
| パス パラメーター |
| 名前, Type, 説明 |
ownerstring必須The account owner of the repository. The name is not case sensitive. |
repostring必須The name of the repository. The name is not case sensitive. |
namestring必須 |
| 本文のパラメーター |
| 名前, Type, 説明 |
new_namestringThe new name of the label. Emoji can be added to label names, using either native emoji or colon-style markup. For example, typing |
colorstringThe hexadecimal color code for the label, without the leading |
descriptionstringA short description of the label. Must be 100 characters or fewer. |
HTTP 応答状態コード
| 状態コード | 説明 |
|---|---|
200 | OK |
コード サンプル
curl \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/labels/NAME \
-d '{"new_name":"bug :bug:","description":"Small bug fix required","color":"b01f26"}'Response
Status: 200{
"id": 208045946,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDY=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/bug%20:bug:",
"name": "bug :bug:",
"description": "Small bug fix required",
"color": "b01f26",
"default": true
}Delete a label
パラメーター
| ヘッダー |
|---|
| 名前, Type, 説明 |
acceptstringSetting to |
| パス パラメーター |
| 名前, Type, 説明 |
ownerstring必須The account owner of the repository. The name is not case sensitive. |
repostring必須The name of the repository. The name is not case sensitive. |
namestring必須 |
HTTP 応答状態コード
| 状態コード | 説明 |
|---|---|
204 | No Content |
コード サンプル
curl \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/labels/NAMEResponse
Status: 204List labels for issues in a milestone
パラメーター
| ヘッダー |
|---|
| 名前, Type, 説明 |
acceptstringSetting to |
| パス パラメーター |
| 名前, Type, 説明 |
ownerstring必須The account owner of the repository. The name is not case sensitive. |
repostring必須The name of the repository. The name is not case sensitive. |
milestone_numberinteger必須The number that identifies the milestone. |
| クエリ パラメーター |
| 名前, Type, 説明 |
per_pageintegerThe number of results per page (max 100). Default: |
pageintegerPage number of the results to fetch. Default: |
HTTP 応答状態コード
| 状態コード | 説明 |
|---|---|
200 | OK |
コード サンプル
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/milestones/MILESTONE_NUMBER/labelsResponse
Status: 200[
{
"id": 208045946,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDY=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/bug",
"name": "bug",
"description": "Something isn't working",
"color": "f29513",
"default": true
},
{
"id": 208045947,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDc=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/enhancement",
"name": "enhancement",
"description": "New feature or request",
"color": "a2eeef",
"default": false
}
]