Frecuentemente publicamos actualizaciones de nuestra documentación. Es posible que la traducción de esta página esté en curso. Para conocer la información más actual, visita la documentación en inglés. Si existe un problema con las traducciones en esta página, por favor infórmanos.

Esta versión de GitHub Enterprise se discontinuó el 2020-11-12. No se realizarán lanzamientos de patch, ni siquiera para problemas de seguridad críticos. Para obtener un mejor desempeño, más seguridad y nuevas características, actualiza a la última versión de GitHub Enterprise. Para obtener ayuda con la actualización, contacta al soporte de GitHub Enterprise.

Gists

En este artículo

Autenticación

Puedes leer gists públicos y crearlos para usuarios anónimos sin un token Para leer o escribir gists en nombre de un usuario, necesitas el alcance de OAuth para gists y un token. Par aobtener más información, consulta la sección "Alcances para las Apps de OAuth".

Truncamiento

La API de Gist proporciona hasta un megabyte de contenido para cada archivo en el gist. Cada archivo que se devuelve para un gist a través de la API tiene una clave que se llama truncated. Si truncated aparece como true, significa que el archivo es demasiado grande y solo se devolvió una parte de su contenido en content.

Si necesitas el contenido completo del archivo, puedes hacer una solicitud de tipo GET a la URL que se especifica en raw_url. Ten en cuent que, para los archivos mayores a diez megabytes, necesitarás clonar el gist a través de la URL que proprocionó git_pull_url.

Adicionalmente a el truncamiento del contenido específico del archivo, la lista de archivos completa podría truncarse si la cantidad total excede los 300 archivos. Si la clave truncated de nivel superior aparece como true, únicamente se han devuelto los primeros 300 archivos en la lista. Si necesitas recuperar todos los archivos del gist, necesitarás clonarlo a través de la URL que te proporcionó git_pull_url.

Tipos de medios personalizados para los gists

Estos son los tipos de medios compatibles para recuperar el contenido de los gists.

application/vnd.github.VERSION.raw
application/vnd.github.VERSION.base64

Para obtener más información, consulta la sección "Tipos de medios".

List gists for the authenticated user

Lists the authenticated user's gists or if called anonymously, this endpoint returns all public gists:

get /gists

Parámetros

Name Type In Description
accept string header

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

since string query

Only show notifications updated after the given time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.

per_page integer query

Results per page (max 100)

page integer query

Page number of the results to fetch.

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/gists
JavaScript (@octokit/core.js)
await octokit.request('GET /gists')

Default response

Status: 200 OK
[
  {
    "url": "https://api.github.com/gists/aa5a315d61ae9438b18d",
    "forks_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/forks",
    "commits_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/commits",
    "id": "aa5a315d61ae9438b18d",
    "node_id": "MDQ6R2lzdGFhNWEzMTVkNjFhZTk0MzhiMThk",
    "git_pull_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
    "git_push_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
    "html_url": "https://gist.github.com/aa5a315d61ae9438b18d",
    "files": {
      "hello_world.rb": {
        "filename": "hello_world.rb",
        "type": "application/x-ruby",
        "language": "Ruby",
        "raw_url": "https://gist.githubusercontent.com/octocat/6cad326836d38bd3a7ae/raw/db9c55113504e46fa076e7df3a04ce592e2e86d8/hello_world.rb",
        "size": 167
      }
    },
    "public": true,
    "created_at": "2010-04-14T02:15:15Z",
    "updated_at": "2011-06-20T11:34:15Z",
    "description": "Hello World Examples",
    "comments": 0,
    "user": null,
    "comments_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/comments/",
    "owner": {
      "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
    },
    "truncated": false
  }
]

Not modified

Status: 304 Not Modified

Forbidden

Status: 403 Forbidden

Create a gist

Allows you to add a new gist with one or more files.

Note: Don't name your files "gistfile" with a numerical suffix. This is the format of the automatic naming scheme that Gist uses internally.

post /gists

Parámetros

Name Type In Description
accept string header

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

description string body

Description of the gist

files object body

Required. Names and content for the files that make up the gist

public body

undefined

Ejemplos de código

Shell
curl \
  -X POST \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/gists \
  -d '{"files":{}}'
JavaScript (@octokit/core.js)
await octokit.request('POST /gists', {
  files: {}
})

Default response

Status: 201 Created
{
  "url": "https://api.github.com/gists/aa5a315d61ae9438b18d",
  "forks_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/forks",
  "commits_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/commits",
  "id": "aa5a315d61ae9438b18d",
  "node_id": "MDQ6R2lzdGFhNWEzMTVkNjFhZTk0MzhiMThk",
  "git_pull_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
  "git_push_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
  "html_url": "https://gist.github.com/aa5a315d61ae9438b18d",
  "created_at": "2010-04-14T02:15:15Z",
  "updated_at": "2011-06-20T11:34:15Z",
  "description": "Hello World Examples",
  "comments": 0,
  "comments_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/comments/"
}

Not modified

Status: 304 Not Modified

Forbidden

Status: 403 Forbidden

Resource not found

Status: 404 Not Found

Validation failed

Status: 422 Unprocessable Entity

List public gists

List public gists sorted by most recently updated to least recently updated.

Note: With pagination, you can fetch up to 3000 gists. For example, you can fetch 100 pages with 30 gists per page or 30 pages with 100 gists per page.

get /gists/public

Parámetros

Name Type In Description
accept string header

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

since string query

Only show notifications updated after the given time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.

per_page integer query

Results per page (max 100)

page integer query

Page number of the results to fetch.

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/gists/public
JavaScript (@octokit/core.js)
await octokit.request('GET /gists/public')

Default response

Status: 200 OK
[
  {
    "url": "https://api.github.com/gists/aa5a315d61ae9438b18d",
    "forks_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/forks",
    "commits_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/commits",
    "id": "aa5a315d61ae9438b18d",
    "node_id": "MDQ6R2lzdGFhNWEzMTVkNjFhZTk0MzhiMThk",
    "git_pull_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
    "git_push_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
    "html_url": "https://gist.github.com/aa5a315d61ae9438b18d",
    "files": {
      "hello_world.rb": {
        "filename": "hello_world.rb",
        "type": "application/x-ruby",
        "language": "Ruby",
        "raw_url": "https://gist.githubusercontent.com/octocat/6cad326836d38bd3a7ae/raw/db9c55113504e46fa076e7df3a04ce592e2e86d8/hello_world.rb",
        "size": 167
      }
    },
    "public": true,
    "created_at": "2010-04-14T02:15:15Z",
    "updated_at": "2011-06-20T11:34:15Z",
    "description": "Hello World Examples",
    "comments": 0,
    "user": null,
    "comments_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/comments/",
    "owner": {
      "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
    },
    "truncated": false
  }
]

Not modified

Status: 304 Not Modified

Forbidden

Status: 403 Forbidden

Validation failed

Status: 422 Unprocessable Entity

List starred gists

List the authenticated user's starred gists:

get /gists/starred

Parámetros

Name Type In Description
accept string header

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

since string query

Only show notifications updated after the given time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.

per_page integer query

Results per page (max 100)

page integer query

Page number of the results to fetch.

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/gists/starred
JavaScript (@octokit/core.js)
await octokit.request('GET /gists/starred')

Default response

Status: 200 OK
[
  {
    "url": "https://api.github.com/gists/aa5a315d61ae9438b18d",
    "forks_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/forks",
    "commits_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/commits",
    "id": "aa5a315d61ae9438b18d",
    "node_id": "MDQ6R2lzdGFhNWEzMTVkNjFhZTk0MzhiMThk",
    "git_pull_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
    "git_push_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
    "html_url": "https://gist.github.com/aa5a315d61ae9438b18d",
    "files": {
      "hello_world.rb": {
        "filename": "hello_world.rb",
        "type": "application/x-ruby",
        "language": "Ruby",
        "raw_url": "https://gist.githubusercontent.com/octocat/6cad326836d38bd3a7ae/raw/db9c55113504e46fa076e7df3a04ce592e2e86d8/hello_world.rb",
        "size": 167
      }
    },
    "public": true,
    "created_at": "2010-04-14T02:15:15Z",
    "updated_at": "2011-06-20T11:34:15Z",
    "description": "Hello World Examples",
    "comments": 0,
    "user": null,
    "comments_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/comments/",
    "owner": {
      "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
    },
    "truncated": false
  }
]

Not modified

Status: 304 Not Modified

Requires authentication

Status: 401 Unauthorized

Forbidden

Status: 403 Forbidden

get /gists/{gist_id}

Parámetros

Name Type In Description
accept string header

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

gist_id string path

gist_id parameter

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/gists/GIST_ID
JavaScript (@octokit/core.js)
await octokit.request('GET /gists/{gist_id}', {
  gist_id: 'gist_id'
})

Default response

Status: 200 OK
{
  "url": "https://api.github.com/gists/aa5a315d61ae9438b18d",
  "forks_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/forks",
  "commits_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/commits",
  "id": "aa5a315d61ae9438b18d",
  "node_id": "MDQ6R2lzdGFhNWEzMTVkNjFhZTk0MzhiMThk",
  "git_pull_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
  "git_push_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
  "html_url": "https://gist.github.com/aa5a315d61ae9438b18d",
  "created_at": "2010-04-14T02:15:15Z",
  "updated_at": "2011-06-20T11:34:15Z",
  "description": "Hello World Examples",
  "comments": 0,
  "comments_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/comments/"
}

Not modified

Status: 304 Not Modified

Forbidden gist

Status: 403 Forbidden

Resource not found

Status: 404 Not Found

Update a gist

Allows you to update or delete a gist file and rename gist files. Files from the previous version of the gist that aren't explicitly changed during an edit are unchanged.

patch /gists/{gist_id}

Parámetros

Name Type In Description
accept string header

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

gist_id string path

gist_id parameter

description string body

Description of the gist

files object body

Names of files to be updated

Ejemplos de código

Shell
curl \
  -X PATCH \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/gists/GIST_ID \
  -d '{"description":"description"}'
JavaScript (@octokit/core.js)
await octokit.request('PATCH /gists/{gist_id}', {
  gist_id: 'gist_id',
  description: 'description'
})

Default response

Status: 200 OK
{
  "url": "https://api.github.com/gists/aa5a315d61ae9438b18d",
  "forks_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/forks",
  "commits_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/commits",
  "id": "aa5a315d61ae9438b18d",
  "node_id": "MDQ6R2lzdGFhNWEzMTVkNjFhZTk0MzhiMThk",
  "git_pull_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
  "git_push_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
  "html_url": "https://gist.github.com/aa5a315d61ae9438b18d",
  "created_at": "2010-04-14T02:15:15Z",
  "updated_at": "2011-06-20T11:34:15Z",
  "description": "Hello World Examples",
  "comments": 0,
  "comments_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/comments/"
}

Resource not found

Status: 404 Not Found

Validation failed

Status: 422 Unprocessable Entity

delete /gists/{gist_id}

Parámetros

Name Type In Description
accept string header

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

gist_id string path

gist_id parameter

Ejemplos de código

Shell
curl \
  -X DELETE \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/gists/GIST_ID
JavaScript (@octokit/core.js)
await octokit.request('DELETE /gists/{gist_id}', {
  gist_id: 'gist_id'
})

Default Response

Status: 204 No Content

Not modified

Status: 304 Not Modified

Forbidden

Status: 403 Forbidden

Resource not found

Status: 404 Not Found

get /gists/{gist_id}/commits

Parámetros

Name Type In Description
accept string header

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

gist_id string path

gist_id parameter

per_page integer query

Results per page (max 100)

page integer query

Page number of the results to fetch.

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/gists/GIST_ID/commits
JavaScript (@octokit/core.js)
await octokit.request('GET /gists/{gist_id}/commits', {
  gist_id: 'gist_id'
})

Default response

Status: 200 OK
[
  {
    "url": "https://api.github.com/gists/aa5a315d61ae9438b18d/57a7f021a713b1c5a6a199b54cc514735d2d462f",
    "version": "57a7f021a713b1c5a6a199b54cc514735d2d462f",
    "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
    },
    "change_status": {
      "deletions": 0,
      "additions": 180,
      "total": 180
    },
    "committed_at": "2010-04-14T02:15:15Z"
  }
]

Not modified

Status: 304 Not Modified

Forbidden

Status: 403 Forbidden

Resource not found

Status: 404 Not Found

get /gists/{gist_id}/forks

Parámetros

Name Type In Description
accept string header

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

gist_id string path

gist_id parameter

per_page integer query

Results per page (max 100)

page integer query

Page number of the results to fetch.

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/gists/GIST_ID/forks
JavaScript (@octokit/core.js)
await octokit.request('GET /gists/{gist_id}/forks', {
  gist_id: 'gist_id'
})

Default response

Status: 200 OK
[
  {
    "url": "https://api.github.com/gists/dee9c42e4998ce2ea439",
    "id": "dee9c42e4998ce2ea439",
    "created_at": "2011-04-14T16:00:49Z",
    "updated_at": "2011-04-14T16:00:49Z"
  }
]

Not modified

Status: 304 Not Modified

Forbidden

Status: 403 Forbidden

Resource not found

Status: 404 Not Found

Fork a gist

Note: This was previously /gists/:gist_id/fork.

post /gists/{gist_id}/forks

Parámetros

Name Type In Description
accept string header

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

gist_id string path

gist_id parameter

Ejemplos de código

Shell
curl \
  -X POST \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/gists/GIST_ID/forks
JavaScript (@octokit/core.js)
await octokit.request('POST /gists/{gist_id}/forks', {
  gist_id: 'gist_id'
})

Default response

Status: 201 Created
{
  "url": "https://api.github.com/gists/aa5a315d61ae9438b18d",
  "forks_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/forks",
  "commits_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/commits",
  "id": "aa5a315d61ae9438b18d",
  "node_id": "MDQ6R2lzdGFhNWEzMTVkNjFhZTk0MzhiMThk",
  "git_pull_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
  "git_push_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
  "html_url": "https://gist.github.com/aa5a315d61ae9438b18d",
  "files": {
    "hello_world.rb": {
      "filename": "hello_world.rb",
      "type": "application/x-ruby",
      "language": "Ruby",
      "raw_url": "https://gist.githubusercontent.com/octocat/6cad326836d38bd3a7ae/raw/db9c55113504e46fa076e7df3a04ce592e2e86d8/hello_world.rb",
      "size": 167
    }
  },
  "public": true,
  "created_at": "2010-04-14T02:15:15Z",
  "updated_at": "2011-06-20T11:34:15Z",
  "description": "Hello World Examples",
  "comments": 0,
  "user": null,
  "comments_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/comments/",
  "owner": {
    "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
  },
  "truncated": false
}

Not modified

Status: 304 Not Modified

Forbidden

Status: 403 Forbidden

Resource not found

Status: 404 Not Found

Validation failed

Status: 422 Unprocessable Entity

get /gists/{gist_id}/star

Parámetros

Name Type In Description
accept string header

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

gist_id string path

gist_id parameter

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/gists/GIST_ID/star
JavaScript (@octokit/core.js)
await octokit.request('GET /gists/{gist_id}/star', {
  gist_id: 'gist_id'
})

Response if gist is starred

Status: 204 No Content

Not modified

Status: 304 Not Modified

Forbidden

Status: 403 Forbidden

Response if gist is not starred

Status: 404 Not Found

Star a gist

Note that you'll need to set Content-Length to zero when calling out to this endpoint. For more information, see "HTTP verbs."

put /gists/{gist_id}/star

Parámetros

Name Type In Description
accept string header

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

gist_id string path

gist_id parameter

Ejemplos de código

Shell
curl \
  -X PUT \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/gists/GIST_ID/star
JavaScript (@octokit/core.js)
await octokit.request('PUT /gists/{gist_id}/star', {
  gist_id: 'gist_id'
})

Default Response

Status: 204 No Content

Not modified

Status: 304 Not Modified

Forbidden

Status: 403 Forbidden

Resource not found

Status: 404 Not Found

delete /gists/{gist_id}/star

Parámetros

Name Type In Description
accept string header

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

gist_id string path

gist_id parameter

Ejemplos de código

Shell
curl \
  -X DELETE \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/gists/GIST_ID/star
JavaScript (@octokit/core.js)
await octokit.request('DELETE /gists/{gist_id}/star', {
  gist_id: 'gist_id'
})

Default Response

Status: 204 No Content

Not modified

Status: 304 Not Modified

Forbidden

Status: 403 Forbidden

Resource not found

Status: 404 Not Found

get /gists/{gist_id}/{sha}

Parámetros

Name Type In Description
accept string header

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

gist_id string path

gist_id parameter

sha string path

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/gists/GIST_ID/SHA
JavaScript (@octokit/core.js)
await octokit.request('GET /gists/{gist_id}/{sha}', {
  gist_id: 'gist_id',
  sha: 'sha'
})

Default response

Status: 200 OK
{
  "url": "https://api.github.com/gists/aa5a315d61ae9438b18d/57a7f021a713b1c5a6a199b54cc514735d2d462f",
  "forks_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/forks",
  "commits_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/commits",
  "id": "aa5a315d61ae9438b18d",
  "node_id": "MDQ6R2lzdGFhNWEzMTVkNjFhZTk0MzhiMThk",
  "git_pull_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
  "git_push_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
  "html_url": "https://gist.github.com/aa5a315d61ae9438b18d",
  "created_at": "2010-04-14T02:15:15Z",
  "updated_at": "2011-06-20T11:34:15Z",
  "description": "Hello World Examples",
  "comments": 0,
  "comments_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/comments/"
}

Forbidden

Status: 403 Forbidden

Resource not found

Status: 404 Not Found

Validation failed

Status: 422 Unprocessable Entity

List gists for a user

Lists public gists for the specified user:

get /users/{username}/gists

Parámetros

Name Type In Description
accept string header

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

username string path
since string query

Only show notifications updated after the given time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.

per_page integer query

Results per page (max 100)

page integer query

Page number of the results to fetch.

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/users/USERNAME/gists
JavaScript (@octokit/core.js)
await octokit.request('GET /users/{username}/gists', {
  username: 'username'
})

Default response

Status: 200 OK
[
  {
    "url": "https://api.github.com/gists/aa5a315d61ae9438b18d",
    "forks_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/forks",
    "commits_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/commits",
    "id": "aa5a315d61ae9438b18d",
    "node_id": "MDQ6R2lzdGFhNWEzMTVkNjFhZTk0MzhiMThk",
    "git_pull_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
    "git_push_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
    "html_url": "https://gist.github.com/aa5a315d61ae9438b18d",
    "files": {
      "hello_world.rb": {
        "filename": "hello_world.rb",
        "type": "application/x-ruby",
        "language": "Ruby",
        "raw_url": "https://gist.githubusercontent.com/octocat/6cad326836d38bd3a7ae/raw/db9c55113504e46fa076e7df3a04ce592e2e86d8/hello_world.rb",
        "size": 167
      }
    },
    "public": true,
    "created_at": "2010-04-14T02:15:15Z",
    "updated_at": "2011-06-20T11:34:15Z",
    "description": "Hello World Examples",
    "comments": 0,
    "user": null,
    "comments_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/comments/",
    "owner": {
      "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
    },
    "truncated": false
  }
]

Validation failed

Status: 422 Unprocessable Entity

Comentarios

Tipos de medios personalizados para los comentarios de los Gists

Estos son los tipos de medios compatibles para los comentarios de los gists.

application/vnd.github.VERSION.raw
application/vnd.github.VERSION.base64

Para obtener más información acerca de los tipos de medios, consulta la sección "Tipos de medios personalizados".

get /gists/{gist_id}/comments

Parámetros

Name Type In Description
accept string header

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

gist_id string path

gist_id parameter

per_page integer query

Results per page (max 100)

page integer query

Page number of the results to fetch.

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/gists/GIST_ID/comments
JavaScript (@octokit/core.js)
await octokit.request('GET /gists/{gist_id}/comments', {
  gist_id: 'gist_id'
})

Default response

Status: 200 OK
[
  {
    "id": 1,
    "node_id": "MDExOkdpc3RDb21tZW50MQ==",
    "url": "https://api.github.com/gists/a6db0bec360bb87e9418/comments/1",
    "body": "Just commenting for the sake of commenting",
    "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-18T23:23:56Z",
    "updated_at": "2011-04-18T23:23:56Z",
    "author_association": "collaborator"
  }
]

Not modified

Status: 304 Not Modified

Forbidden

Status: 403 Forbidden

Resource not found

Status: 404 Not Found

post /gists/{gist_id}/comments

Parámetros

Name Type In Description
accept string header

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

gist_id string path

gist_id parameter

body string body

Required. The comment text.

Ejemplos de código

Shell
curl \
  -X POST \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/gists/GIST_ID/comments \
  -d '{"body":"body"}'
JavaScript (@octokit/core.js)
await octokit.request('POST /gists/{gist_id}/comments', {
  gist_id: 'gist_id',
  body: 'body'
})

Default response

Status: 201 Created
{
  "id": 1,
  "node_id": "MDExOkdpc3RDb21tZW50MQ==",
  "url": "https://api.github.com/gists/a6db0bec360bb87e9418/comments/1",
  "body": "Just commenting for the sake of commenting",
  "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-18T23:23:56Z",
  "updated_at": "2011-04-18T23:23:56Z",
  "author_association": "collaborator"
}

Not modified

Status: 304 Not Modified

Forbidden

Status: 403 Forbidden

Resource not found

Status: 404 Not Found

get /gists/{gist_id}/comments/{comment_id}

Parámetros

Name Type In Description
accept string header

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

gist_id string path

gist_id parameter

comment_id integer path

comment_id parameter

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/gists/GIST_ID/comments/42
JavaScript (@octokit/core.js)
await octokit.request('GET /gists/{gist_id}/comments/{comment_id}', {
  gist_id: 'gist_id',
  comment_id: 42
})

Default response

Status: 200 OK
{
  "id": 1,
  "node_id": "MDExOkdpc3RDb21tZW50MQ==",
  "url": "https://api.github.com/gists/a6db0bec360bb87e9418/comments/1",
  "body": "Just commenting for the sake of commenting",
  "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-18T23:23:56Z",
  "updated_at": "2011-04-18T23:23:56Z",
  "author_association": "collaborator"
}

Not modified

Status: 304 Not Modified

Forbidden gist

Status: 403 Forbidden

Resource not found

Status: 404 Not Found

patch /gists/{gist_id}/comments/{comment_id}

Parámetros

Name Type In Description
accept string header

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

gist_id string path

gist_id parameter

comment_id integer path

comment_id parameter

body string body

Required. The comment text.

Ejemplos de código

Shell
curl \
  -X PATCH \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/gists/GIST_ID/comments/42 \
  -d '{"body":"body"}'
JavaScript (@octokit/core.js)
await octokit.request('PATCH /gists/{gist_id}/comments/{comment_id}', {
  gist_id: 'gist_id',
  comment_id: 42,
  body: 'body'
})

Default response

Status: 200 OK
{
  "id": 1,
  "node_id": "MDExOkdpc3RDb21tZW50MQ==",
  "url": "https://api.github.com/gists/a6db0bec360bb87e9418/comments/1",
  "body": "Just commenting for the sake of commenting",
  "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-18T23:23:56Z",
  "updated_at": "2011-04-18T23:23:56Z",
  "author_association": "collaborator"
}

Resource not found

Status: 404 Not Found

delete /gists/{gist_id}/comments/{comment_id}

Parámetros

Name Type In Description
accept string header

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

gist_id string path

gist_id parameter

comment_id integer path

comment_id parameter

Ejemplos de código

Shell
curl \
  -X DELETE \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/gists/GIST_ID/comments/42
JavaScript (@octokit/core.js)
await octokit.request('DELETE /gists/{gist_id}/comments/{comment_id}', {
  gist_id: 'gist_id',
  comment_id: 42
})

Default Response

Status: 204 No Content

Not modified

Status: 304 Not Modified

Forbidden

Status: 403 Forbidden

Resource not found

Status: 404 Not Found