Skip to main content

Esta versión de GitHub Enterprise se discontinuó el 2022-10-12. No se realizarán lanzamientos de patch, ni siquiera para problemas de seguridad críticos. Para obtener rendimiento mejorado, seguridad mejorada y nuevas características, actualice a la versión más reciente de GitHub Enterprise. Para obtener ayuda con la actualización, póngase en contacto con el soporte técnico de GitHub Enterprise.

We've recently moved some of the REST API documentation. If you can't find what you're looking for, you might try the new Branches, Collaborators, Commits, Deploy Keys, Deployments, GitHub Pages, Releases, Metrics, Webhooks REST API pages.

Comentarios sobre confirmación de cambios

Commit comments API permite crear y editar comentarios relacionados con confirmaciones específicas.

Acerca de Commit comments API

Commit comments API permite crear y editar comentarios relacionados con confirmaciones específicas.

Tipos de medios personalizados para los comentarios de las confirmaciones

Estos son los tipos de medios compatibles para los comentarios de las confirmaciones. Aquí puede obtener más información sobre el uso de los tipos de medios en la API.

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 más información, vea "Tipos de medios personalizados".

List commit comments for a repository

Funciona con 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

Headers
Name, Type, Description
acceptstring

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

See preview notice
Path parameters
Name, Type, Description
ownerstringRequired

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

repostringRequired

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

Query parameters
Name, Type, Description
per_pageinteger

The number of results per page (max 100).

Default: 30

pageinteger

Page number of the results to fetch.

Default: 1

Códigos de estado de respuesta HTTP

status codeDescripción
200

OK

Ejemplos de código

get/repos/{owner}/{repo}/comments
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://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" } ]

Aviso de previsualización

An additional reactions object in the issue comment payload is currently available for developers to preview. During the preview period, the APIs may change without advance notice. Please see the blog post for full details.

To access the API you must provide a custom media type in the Accept header:

application/vnd.github.squirrel-girl-preview

The reactions key will have the following payload where url can be used to construct the API location for listing and creating reactions.

Get a commit comment

Funciona con GitHub Apps

Parámetros

Headers
Name, Type, Description
acceptstring

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

See preview notice
Path parameters
Name, Type, Description
ownerstringRequired

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

repostringRequired

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

comment_idintegerRequired

The unique identifier of the comment.

Códigos de estado de respuesta HTTP

status codeDescripción
200

OK

404

Resource not found

Ejemplos de código

get/repos/{owner}/{repo}/comments/{comment_id}
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://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" }

Aviso de previsualización

An additional reactions object in the issue comment payload is currently available for developers to preview. During the preview period, the APIs may change without advance notice. Please see the blog post for full details.

To access the API you must provide a custom media type in the Accept header:

application/vnd.github.squirrel-girl-preview

The reactions key will have the following payload where url can be used to construct the API location for listing and creating reactions.

Update a commit comment

Funciona con GitHub Apps

Parámetros

Headers
Name, Type, Description
acceptstring

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

Path parameters
Name, Type, Description
ownerstringRequired

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

repostringRequired

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

comment_idintegerRequired

The unique identifier of the comment.

Body parameters
Name, Type, Description
bodystringRequired

The contents of the comment

Códigos de estado de respuesta HTTP

status codeDescripción
200

OK

404

Resource not found

Ejemplos de código

patch/repos/{owner}/{repo}/comments/{comment_id}
curl \ -X PATCH \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://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 con GitHub Apps

Parámetros

Headers
Name, Type, Description
acceptstring

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

Path parameters
Name, Type, Description
ownerstringRequired

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

repostringRequired

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

comment_idintegerRequired

The unique identifier of the comment.

Códigos de estado de respuesta HTTP

status codeDescripción
204

No Content

404

Resource not found

Ejemplos de código

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

Response

Status: 204

List commit comments

Funciona con GitHub Apps

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

Parámetros

Headers
Name, Type, Description
acceptstring

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

See preview notice
Path parameters
Name, Type, Description
ownerstringRequired

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

repostringRequired

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

commit_shastringRequired

The SHA of the commit.

Query parameters
Name, Type, Description
per_pageinteger

The number of results per page (max 100).

Default: 30

pageinteger

Page number of the results to fetch.

Default: 1

Códigos de estado de respuesta HTTP

status codeDescripción
200

OK

Ejemplos de código

get/repos/{owner}/{repo}/commits/{commit_sha}/comments
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://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" } ]

Aviso de previsualización

An additional reactions object in the issue comment payload is currently available for developers to preview. During the preview period, the APIs may change without advance notice. Please see the blog post for full details.

To access the API you must provide a custom media type in the Accept header:

application/vnd.github.squirrel-girl-preview

The reactions key will have the following payload where url can be used to construct the API location for listing and creating reactions.

Create a commit comment

Funciona con 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

Headers
Name, Type, Description
acceptstring

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

Path parameters
Name, Type, Description
ownerstringRequired

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

repostringRequired

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

commit_shastringRequired

The SHA of the commit.

Body parameters
Name, Type, Description
bodystringRequired

The contents of the comment.

pathstring

Relative path of the file to comment on.

positioninteger

Line index in the diff to comment on.

lineinteger

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

Códigos de estado de respuesta HTTP

status codeDescripción
201

Created

403

Forbidden

422

Validation failed, or the endpoint has been spammed.

Ejemplos de código

post/repos/{owner}/{repo}/commits/{commit_sha}/comments
curl \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://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" }