Skip to main content
Publicamos atualizações frequentes em nossa documentação, e a tradução desta página ainda pode estar em andamento. Para obter as informações mais atualizadas, acesse a documentação em inglês.
Atualmente o GitHub AE está em versão limitada.

Recentemente, movemos algumas das documentações da API REST. Se você não conseguir encontrar o que está procurando, tente as novas páginas da API REST Branches, Collaborators, Commits, Deploy Keys, Deployments, GitHub Pages, Releases, Metrics, Webhooks}.

Comentários de commit

Use a API REST para interagir com comentários de commits.

Sobre os comentários de um commit

É possível criar, editar e exibir comentários de commits usando a API REST. Um comentário de commit é um comentário feito em um commit específico. Para obter mais informações, confira "Trabalhar com comentários".

Tipos de mídia personalizados para comentários de commit

Estes são os tipos de mídia compatíveis com os comentários do commit. Leia mais sobre o uso de tipos de mídia na API aqui.

application/vnd.github-commitcomment.raw+json
application/vnd.github-commitcomment.text+json
application/vnd.github-commitcomment.html+json
application/vnd.github-commitcomment.full+json

Para obter mais informações, confira "Tipos de mídia".

List commit comments for a repository

Funciona com GitHub Apps

Commit Comments use these custom media types. You can read more about the use of media types in the API here.

Comments are ordered by ascending ID.

Parâmetros para "List commit comments for a repository"

Cabeçalhos
Name, Tipo, Descrição
accept string

Setting to application/vnd.github+json is recommended.

Parâmetros de caminho
Name, Tipo, Descrição
owner string Obrigatório

The account owner of the repository. The name is not case sensitive.

repo string Obrigatório

The name of the repository. The name is not case sensitive.

Parâmetros de consulta
Name, Tipo, Descrição
per_page integer

The number of results per page (max 100).

Padrão: 30

page integer

Page number of the results to fetch.

Padrão: 1

Códigos de status de resposta HTTP para "List commit comments for a repository"

Código de statusDescrição
200

OK

Exemplos de código para "List commit comments for a repository"

get/repos/{owner}/{repo}/comments
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ https://HOSTNAME/api/v3/repos/OWNER/REPO/comments

Response

Status: 200
[ { "html_url": "https://github.com/octocat/Hello-World/commit/6dcb09b5b57875f334f61aebed695e2e4193db5e#commitcomment-1", "url": "https://api.github.com/repos/octocat/Hello-World/comments/1", "id": 1, "node_id": "MDEzOkNvbW1pdENvbW1lbnQx", "body": "Great stuff", "path": "file1.txt", "position": 4, "line": 14, "commit_id": "6dcb09b5b57875f334f61aebed695e2e4193db5e", "user": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "created_at": "2011-04-14T16:00:49Z", "updated_at": "2011-04-14T16:00:49Z", "author_association": "COLLABORATOR" } ]

Get a commit comment

Funciona com GitHub Apps

Parâmetros para "Get a commit comment"

Cabeçalhos
Name, Tipo, Descrição
accept string

Setting to application/vnd.github+json is recommended.

Parâmetros de caminho
Name, Tipo, Descrição
owner string Obrigatório

The account owner of the repository. The name is not case sensitive.

repo string Obrigatório

The name of the repository. The name is not case sensitive.

comment_id integer Obrigatório

The unique identifier of the comment.

Códigos de status de resposta HTTP para "Get a commit comment"

Código de statusDescrição
200

OK

404

Resource not found

Exemplos de código para "Get a commit comment"

get/repos/{owner}/{repo}/comments/{comment_id}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ https://HOSTNAME/api/v3/repos/OWNER/REPO/comments/COMMENT_ID

Response

Status: 200
{ "html_url": "https://github.com/octocat/Hello-World/commit/6dcb09b5b57875f334f61aebed695e2e4193db5e#commitcomment-1", "url": "https://api.github.com/repos/octocat/Hello-World/comments/1", "id": 1, "node_id": "MDEzOkNvbW1pdENvbW1lbnQx", "body": "Great stuff", "path": "file1.txt", "position": 4, "line": 14, "commit_id": "6dcb09b5b57875f334f61aebed695e2e4193db5e", "author_association": "COLLABORATOR", "user": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "created_at": "2011-04-14T16:00:49Z", "updated_at": "2011-04-14T16:00:49Z" }

Update a commit comment

Funciona com GitHub Apps

Parâmetros para "Update a commit comment"

Cabeçalhos
Name, Tipo, Descrição
accept string

Setting to application/vnd.github+json is recommended.

Parâmetros de caminho
Name, Tipo, Descrição
owner string Obrigatório

The account owner of the repository. The name is not case sensitive.

repo string Obrigatório

The name of the repository. The name is not case sensitive.

comment_id integer Obrigatório

The unique identifier of the comment.

Parâmetros do corpo
Name, Tipo, Descrição
body string Obrigatório

The contents of the comment

Códigos de status de resposta HTTP para "Update a commit comment"

Código de statusDescrição
200

OK

404

Resource not found

Exemplos de código para "Update a commit comment"

patch/repos/{owner}/{repo}/comments/{comment_id}
curl -L \ -X PATCH \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ https://HOSTNAME/api/v3/repos/OWNER/REPO/comments/COMMENT_ID \ -d '{"body":"Nice change"}'

Response

Status: 200
{ "html_url": "https://github.com/octocat/Hello-World/commit/6dcb09b5b57875f334f61aebed695e2e4193db5e#commitcomment-1", "url": "https://api.github.com/repos/octocat/Hello-World/comments/1", "id": 1, "node_id": "MDEzOkNvbW1pdENvbW1lbnQx", "body": "Nice change", "path": "file1.txt", "position": 4, "line": 14, "commit_id": "6dcb09b5b57875f334f61aebed695e2e4193db5e", "author_association": "COLLABORATOR", "user": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "created_at": "2011-04-14T16:00:49Z", "updated_at": "2011-04-14T16:00:49Z" }

Delete a commit comment

Funciona com GitHub Apps

Parâmetros para "Delete a commit comment"

Cabeçalhos
Name, Tipo, Descrição
accept string

Setting to application/vnd.github+json is recommended.

Parâmetros de caminho
Name, Tipo, Descrição
owner string Obrigatório

The account owner of the repository. The name is not case sensitive.

repo string Obrigatório

The name of the repository. The name is not case sensitive.

comment_id integer Obrigatório

The unique identifier of the comment.

Códigos de status de resposta HTTP para "Delete a commit comment"

Código de statusDescrição
204

No Content

404

Resource not found

Exemplos de código para "Delete a commit comment"

delete/repos/{owner}/{repo}/comments/{comment_id}
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ https://HOSTNAME/api/v3/repos/OWNER/REPO/comments/COMMENT_ID

Response

Status: 204

List commit comments

Funciona com GitHub Apps

Use the :commit_sha to specify the commit that will have its comments listed.

Parâmetros para "List commit comments"

Cabeçalhos
Name, Tipo, Descrição
accept string

Setting to application/vnd.github+json is recommended.

Parâmetros de caminho
Name, Tipo, Descrição
owner string Obrigatório

The account owner of the repository. The name is not case sensitive.

repo string Obrigatório

The name of the repository. The name is not case sensitive.

commit_sha string Obrigatório

The SHA of the commit.

Parâmetros de consulta
Name, Tipo, Descrição
per_page integer

The number of results per page (max 100).

Padrão: 30

page integer

Page number of the results to fetch.

Padrão: 1

Códigos de status de resposta HTTP para "List commit comments"

Código de statusDescrição
200

OK

Exemplos de código para "List commit comments"

get/repos/{owner}/{repo}/commits/{commit_sha}/comments
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ https://HOSTNAME/api/v3/repos/OWNER/REPO/commits/COMMIT_SHA/comments

Response

Status: 200
[ { "html_url": "https://github.com/octocat/Hello-World/commit/6dcb09b5b57875f334f61aebed695e2e4193db5e#commitcomment-1", "url": "https://api.github.com/repos/octocat/Hello-World/comments/1", "id": 1, "node_id": "MDEzOkNvbW1pdENvbW1lbnQx", "body": "Great stuff", "path": "file1.txt", "position": 4, "line": 14, "commit_id": "6dcb09b5b57875f334f61aebed695e2e4193db5e", "user": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "created_at": "2011-04-14T16:00:49Z", "updated_at": "2011-04-14T16:00:49Z", "author_association": "COLLABORATOR" } ]

Create a commit comment

Funciona com GitHub Apps

Create a comment for a commit using its :commit_sha.

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in secondary rate limiting. See "Secondary rate limits" and "Dealing with secondary rate limits" for details.

Parâmetros para "Create a commit comment"

Cabeçalhos
Name, Tipo, Descrição
accept string

Setting to application/vnd.github+json is recommended.

Parâmetros de caminho
Name, Tipo, Descrição
owner string Obrigatório

The account owner of the repository. The name is not case sensitive.

repo string Obrigatório

The name of the repository. The name is not case sensitive.

commit_sha string Obrigatório

The SHA of the commit.

Parâmetros do corpo
Name, Tipo, Descrição
body string Obrigatório

The contents of the comment.

path string

Relative path of the file to comment on.

position integer

Line index in the diff to comment on.

line integer

Deprecated. Use position parameter instead. Line number in the file to comment on.

Códigos de status de resposta HTTP para "Create a commit comment"

Código de statusDescrição
201

Created

403

Forbidden

422

Validation failed, or the endpoint has been spammed.

Exemplos de código para "Create a commit comment"

post/repos/{owner}/{repo}/commits/{commit_sha}/comments
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ https://HOSTNAME/api/v3/repos/OWNER/REPO/commits/COMMIT_SHA/comments \ -d '{"body":"Great stuff","path":"file1.txt","position":4,"line":1}'

Response

Status: 201
{ "html_url": "https://github.com/octocat/Hello-World/commit/6dcb09b5b57875f334f61aebed695e2e4193db5e#commitcomment-1", "url": "https://api.github.com/repos/octocat/Hello-World/comments/1", "id": 1, "node_id": "MDEzOkNvbW1pdENvbW1lbnQx", "body": "Great stuff", "path": "file1.txt", "position": 4, "line": 14, "commit_id": "6dcb09b5b57875f334f61aebed695e2e4193db5e", "author_association": "COLLABORATOR", "user": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "created_at": "2011-04-14T16:00:49Z", "updated_at": "2011-04-14T16:00:49Z" }