Pontos de extremidade da API REST para Gists
Use a API REST para listar, criar, atualizar e excluir os gists públicos no GitHub.
Sobre gists
Você pode usar a API REST para exibir e modificar gists. Para obter mais informações sobre gists, confira "Editar e compartilhar conteúdo com gists".
Autenticação
Você pode ler gists públicos De modo anônimo, mas você precisa estar conectado no GitHub para criar gists. Para ler ou gravar gists em nome de um usuário, você precisa ter o escopo OAuth do gist e um token. Para obter mais informações, confira "Escopos para aplicativos OAuth".
Truncation
A API fornece até um megabyte de conteúdo para cada arquivo no gist. Cada arquivo retornado para um gist por meio da API tem uma chave chamada truncated
. Se truncated
é true
, o arquivo é muito grande e apenas uma parte do conteúdo foi retornada em content
.
Se precisar do conteúdo completo do arquivo, faça uma solicitação GET
à URL especificada por raw_url
. Lembre-se de que, para arquivos com mais de dez megabytes, você precisará clonar a gist por meio da URL fornecida por git_pull_url
.
Além do conteúdo de um arquivo específico ser truncado, toda a lista de arquivos pode ser truncada se o número total exceder 300 arquivos. Se a chave truncated
de nível superior for true
, somente os primeiros 300 arquivos serão retornados na lista de arquivos. Se você precisar buscar todos os arquivos do gist, precisará clonar o gist por meio da URL fornecida por git_pull_url
.
List gists for the authenticated user
Lists the authenticated user's gists or if called anonymously, this endpoint returns all public gists:
Tokens de acesso refinados para "List gists for the authenticated user"
Esse ponto de extremidade funciona com os seguintes tipos de token refinados:
O token refinaado não requer permissões.
Parâmetros para "List gists for the authenticated user"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
since string Only show results that were last updated after the given time. This is a timestamp in ISO 8601 format: |
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Padrão: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Padrão: |
Códigos de status de resposta HTTP para "List gists for the authenticated user"
Código de status | Descrição |
---|---|
200 | OK |
304 | Not modified |
403 | Forbidden |
Exemplos de código para "List gists for the authenticated user"
Exemplo de solicitação
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/gists
Response
Status: 200
[
{
"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
}
]
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.
Tokens de acesso refinados para "Create a gist"
Esse ponto de extremidade funciona com os seguintes tipos de token refinados:
O token refinado deve ter os seguintes conjuntos de permissões:
- "Gists" user permissions (write)
Parâmetros para "Create a gist"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição | |||||
---|---|---|---|---|---|
description string Description of the gist | |||||
files object ObrigatórioNames and content for the files that make up the gist | |||||
Properties of |
Nome, Tipo, Descrição | ||
---|---|---|
key object A user-defined key to represent an item in | ||
Properties of |
Nome, Tipo, Descrição |
---|
content string ObrigatórioContent of the file |
public
boolean or string Flag indicating whether the gist is public
Códigos de status de resposta HTTP para "Create a gist"
Código de status | Descrição |
---|---|
201 | Created |
304 | Not modified |
403 | Forbidden |
404 | Resource not found |
422 | Validation failed, or the endpoint has been spammed. |
Exemplos de código para "Create a gist"
Exemplo de solicitação
curl -L \
-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/gists \
-d '{"description":"Example of a gist","public":false,"files":{"README.md":{"content":"Hello World"}}}'
Response
Status: 201
{
"url": "https://api.github.com/gists/2decf6c462d9b4418f2",
"forks_url": "https://api.github.com/gists/2decf6c462d9b4418f2/forks",
"commits_url": "https://api.github.com/gists/2decf6c462d9b4418f2/commits",
"id": "2decf6c462d9b4418f2",
"node_id": "G_kwDOBhHyLdZDliNDQxOGYy",
"git_pull_url": "https://gist.github.com/2decf6c462d9b4418f2.git",
"git_push_url": "https://gist.github.com/2decf6c462d9b4418f2.git",
"html_url": "https://gist.github.com/2decf6c462d9b4418f2",
"files": {
"README.md": {
"filename": "README.md",
"type": "text/markdown",
"language": "Markdown",
"raw_url": "https://gist.githubusercontent.com/monalisa/2decf6c462d9b4418f2/raw/ac3e6daf176fafe73609fd000cd188e4472010fb/README.md",
"size": 23,
"truncated": false,
"content": "Hello world from GitHub"
}
},
"public": true,
"created_at": "2022-09-20T12:11:58Z",
"updated_at": "2022-09-21T10:28:06Z",
"description": "An updated gist description.",
"comments": 0,
"user": null,
"comments_url": "https://api.github.com/gists/2decf6c462d9b4418f2/comments",
"owner": {
"login": "monalisa",
"id": 104456405,
"node_id": "U_kgDOBhHyLQ",
"avatar_url": "https://avatars.githubusercontent.com/u/104456405?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/monalisa",
"html_url": "https://github.com/monalisa",
"followers_url": "https://api.github.com/users/monalisa/followers",
"following_url": "https://api.github.com/users/monalisa/following{/other_user}",
"gists_url": "https://api.github.com/users/monalisa/gists{/gist_id}",
"starred_url": "https://api.github.com/users/monalisa/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/monalisa/subscriptions",
"organizations_url": "https://api.github.com/users/monalisa/orgs",
"repos_url": "https://api.github.com/users/monalisa/repos",
"events_url": "https://api.github.com/users/monalisa/events{/privacy}",
"received_events_url": "https://api.github.com/users/monalisa/received_events",
"type": "User",
"site_admin": true
},
"forks": [],
"history": [
{
"user": {
"login": "monalisa",
"id": 104456405,
"node_id": "U_kgyLQ",
"avatar_url": "https://avatars.githubusercontent.com/u/104456405?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/monalisa",
"html_url": "https://github.com/monalisa",
"followers_url": "https://api.github.com/users/monalisa/followers",
"following_url": "https://api.github.com/users/monalisa/following{/other_user}",
"gists_url": "https://api.github.com/users/monalisa/gists{/gist_id}",
"starred_url": "https://api.github.com/users/monalisa/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/monalisa/subscriptions",
"organizations_url": "https://api.github.com/users/monalisa/orgs",
"repos_url": "https://api.github.com/users/monalisa/repos",
"events_url": "https://api.github.com/users/monalisa/events{/privacy}",
"received_events_url": "https://api.github.com/users/monalisa/received_events",
"type": "User",
"site_admin": true
},
"version": "468aac8caed5f0c3b859b8286968",
"committed_at": "2022-09-21T10:28:06Z",
"change_status": {
"total": 2,
"additions": 1,
"deletions": 1
},
"url": "https://api.github.com/gists/8481a81af6b7a2d418f2/468aac8caed5f0c3b859b8286968"
}
],
"truncated": false
}
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.
Tokens de acesso refinados para "List public gists"
Esse ponto de extremidade funciona com os seguintes tipos de token refinados:
O token refinaado não requer permissões.
Parâmetros para "List public gists"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
since string Only show results that were last updated after the given time. This is a timestamp in ISO 8601 format: |
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Padrão: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Padrão: |
Códigos de status de resposta HTTP para "List public gists"
Código de status | Descrição |
---|---|
200 | OK |
304 | Not modified |
403 | Forbidden |
422 | Validation failed, or the endpoint has been spammed. |
Exemplos de código para "List public gists"
Exemplo de solicitação
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/gists/public
Response
Status: 200
[
{
"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
}
]
List starred gists
List the authenticated user's starred gists:
Tokens de acesso refinados para "List starred gists"
Esse ponto de extremidade funciona com os seguintes tipos de token refinados:
O token refinaado não requer permissões.
Parâmetros para "List starred gists"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
since string Only show results that were last updated after the given time. This is a timestamp in ISO 8601 format: |
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Padrão: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Padrão: |
Códigos de status de resposta HTTP para "List starred gists"
Código de status | Descrição |
---|---|
200 | OK |
304 | Not modified |
401 | Requires authentication |
403 | Forbidden |
Exemplos de código para "List starred gists"
Exemplo de solicitação
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/gists/starred
Response
Status: 200
[
{
"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
}
]
Get a gist
Gets a specified gist.
This endpoint supports the following custom media types. For more information, see "Media types."
application/vnd.github.raw+json
: Returns the raw markdown. This is the default if you do not pass any specific media type.application/vnd.github.base64+json
: Returns the base64-encoded contents. This can be useful if your gist contains any invalid UTF-8 sequences.
Tokens de acesso refinados para "Get a gist"
Esse ponto de extremidade funciona com os seguintes tipos de token refinados:
O token refinaado não requer permissões.
Parâmetros para "Get a gist"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
gist_id string ObrigatórioThe unique identifier of the gist. |
Códigos de status de resposta HTTP para "Get a gist"
Código de status | Descrição |
---|---|
200 | OK |
304 | Not modified |
403 | Forbidden Gist |
404 | Resource not found |
Exemplos de código para "Get a gist"
Exemplo de solicitação
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/gists/GIST_ID
Response
Status: 200
{
"url": "https://api.github.com/gists/2decf6c462d9b4418f2",
"forks_url": "https://api.github.com/gists/2decf6c462d9b4418f2/forks",
"commits_url": "https://api.github.com/gists/2decf6c462d9b4418f2/commits",
"id": "2decf6c462d9b4418f2",
"node_id": "G_kwDOBhHyLdZDliNDQxOGYy",
"git_pull_url": "https://gist.github.com/2decf6c462d9b4418f2.git",
"git_push_url": "https://gist.github.com/2decf6c462d9b4418f2.git",
"html_url": "https://gist.github.com/2decf6c462d9b4418f2",
"files": {
"README.md": {
"filename": "README.md",
"type": "text/markdown",
"language": "Markdown",
"raw_url": "https://gist.githubusercontent.com/monalisa/2decf6c462d9b4418f2/raw/ac3e6daf176fafe73609fd000cd188e4472010fb/README.md",
"size": 23,
"truncated": false,
"content": "Hello world from GitHub"
}
},
"public": true,
"created_at": "2022-09-20T12:11:58Z",
"updated_at": "2022-09-21T10:28:06Z",
"description": "An updated gist description.",
"comments": 0,
"user": null,
"comments_url": "https://api.github.com/gists/2decf6c462d9b4418f2/comments",
"owner": {
"login": "monalisa",
"id": 104456405,
"node_id": "U_kgDOBhHyLQ",
"avatar_url": "https://avatars.githubusercontent.com/u/104456405?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/monalisa",
"html_url": "https://github.com/monalisa",
"followers_url": "https://api.github.com/users/monalisa/followers",
"following_url": "https://api.github.com/users/monalisa/following{/other_user}",
"gists_url": "https://api.github.com/users/monalisa/gists{/gist_id}",
"starred_url": "https://api.github.com/users/monalisa/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/monalisa/subscriptions",
"organizations_url": "https://api.github.com/users/monalisa/orgs",
"repos_url": "https://api.github.com/users/monalisa/repos",
"events_url": "https://api.github.com/users/monalisa/events{/privacy}",
"received_events_url": "https://api.github.com/users/monalisa/received_events",
"type": "User",
"site_admin": true
},
"forks": [],
"history": [
{
"user": {
"login": "monalisa",
"id": 104456405,
"node_id": "U_kgyLQ",
"avatar_url": "https://avatars.githubusercontent.com/u/104456405?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/monalisa",
"html_url": "https://github.com/monalisa",
"followers_url": "https://api.github.com/users/monalisa/followers",
"following_url": "https://api.github.com/users/monalisa/following{/other_user}",
"gists_url": "https://api.github.com/users/monalisa/gists{/gist_id}",
"starred_url": "https://api.github.com/users/monalisa/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/monalisa/subscriptions",
"organizations_url": "https://api.github.com/users/monalisa/orgs",
"repos_url": "https://api.github.com/users/monalisa/repos",
"events_url": "https://api.github.com/users/monalisa/events{/privacy}",
"received_events_url": "https://api.github.com/users/monalisa/received_events",
"type": "User",
"site_admin": true
},
"version": "468aac8caed5f0c3b859b8286968",
"committed_at": "2022-09-21T10:28:06Z",
"change_status": {
"total": 2,
"additions": 1,
"deletions": 1
},
"url": "https://api.github.com/gists/8481a81af6b7a2d418f2/468aac8caed5f0c3b859b8286968"
}
],
"truncated": false
}
Update a gist
Allows you to update a gist's description and to update, delete, or rename gist files. Files from the previous version of the gist that aren't explicitly changed during an edit are unchanged.
At least one of description
or files
is required.
This endpoint supports the following custom media types. For more information, see "Media types."
application/vnd.github.raw+json
: Returns the raw markdown. This is the default if you do not pass any specific media type.application/vnd.github.base64+json
: Returns the base64-encoded contents. This can be useful if your gist contains any invalid UTF-8 sequences.
Tokens de acesso refinados para "Update a gist"
Esse ponto de extremidade funciona com os seguintes tipos de token refinados:
O token refinado deve ter os seguintes conjuntos de permissões:
- "Gists" user permissions (write)
Parâmetros para "Update a gist"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
gist_id string ObrigatórioThe unique identifier of the gist. |
Nome, Tipo, Descrição | ||||||
---|---|---|---|---|---|---|
description string The description of the gist. | ||||||
files object The gist files to be updated, renamed, or deleted. Each To delete a file, set the whole file to null. For example: | ||||||
Properties of |
Nome, Tipo, Descrição | |||
---|---|---|---|
key object A user-defined key to represent an item in | |||
Properties of |
Nome, Tipo, Descrição |
---|
content string The new content of the file. |
filename string or null The new filename for the file. |
Códigos de status de resposta HTTP para "Update a gist"
Código de status | Descrição |
---|---|
200 | OK |
404 | Resource not found |
422 | Validation failed, or the endpoint has been spammed. |
Exemplos de código para "Update a gist"
Exemplos de solicitação
curl -L \
-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/gists/GIST_ID \
-d '{"description":"An updated gist description","files":{"README.md":{"content":"Hello World from GitHub"}}}'
Response
Status: 200
{
"url": "https://api.github.com/gists/2decf6c462d9b4418f2",
"forks_url": "https://api.github.com/gists/2decf6c462d9b4418f2/forks",
"commits_url": "https://api.github.com/gists/2decf6c462d9b4418f2/commits",
"id": "2decf6c462d9b4418f2",
"node_id": "G_kwDOBhHyLdZDliNDQxOGYy",
"git_pull_url": "https://gist.github.com/2decf6c462d9b4418f2.git",
"git_push_url": "https://gist.github.com/2decf6c462d9b4418f2.git",
"html_url": "https://gist.github.com/2decf6c462d9b4418f2",
"files": {
"README.md": {
"filename": "README.md",
"type": "text/markdown",
"language": "Markdown",
"raw_url": "https://gist.githubusercontent.com/monalisa/2decf6c462d9b4418f2/raw/ac3e6daf176fafe73609fd000cd188e4472010fb/README.md",
"size": 23,
"truncated": false,
"content": "Hello world from GitHub"
}
},
"public": true,
"created_at": "2022-09-20T12:11:58Z",
"updated_at": "2022-09-21T10:28:06Z",
"description": "An updated gist description.",
"comments": 0,
"user": null,
"comments_url": "https://api.github.com/gists/2decf6c462d9b4418f2/comments",
"owner": {
"login": "monalisa",
"id": 104456405,
"node_id": "U_kgDOBhHyLQ",
"avatar_url": "https://avatars.githubusercontent.com/u/104456405?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/monalisa",
"html_url": "https://github.com/monalisa",
"followers_url": "https://api.github.com/users/monalisa/followers",
"following_url": "https://api.github.com/users/monalisa/following{/other_user}",
"gists_url": "https://api.github.com/users/monalisa/gists{/gist_id}",
"starred_url": "https://api.github.com/users/monalisa/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/monalisa/subscriptions",
"organizations_url": "https://api.github.com/users/monalisa/orgs",
"repos_url": "https://api.github.com/users/monalisa/repos",
"events_url": "https://api.github.com/users/monalisa/events{/privacy}",
"received_events_url": "https://api.github.com/users/monalisa/received_events",
"type": "User",
"site_admin": true
},
"forks": [],
"history": [
{
"user": {
"login": "monalisa",
"id": 104456405,
"node_id": "U_kgyLQ",
"avatar_url": "https://avatars.githubusercontent.com/u/104456405?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/monalisa",
"html_url": "https://github.com/monalisa",
"followers_url": "https://api.github.com/users/monalisa/followers",
"following_url": "https://api.github.com/users/monalisa/following{/other_user}",
"gists_url": "https://api.github.com/users/monalisa/gists{/gist_id}",
"starred_url": "https://api.github.com/users/monalisa/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/monalisa/subscriptions",
"organizations_url": "https://api.github.com/users/monalisa/orgs",
"repos_url": "https://api.github.com/users/monalisa/repos",
"events_url": "https://api.github.com/users/monalisa/events{/privacy}",
"received_events_url": "https://api.github.com/users/monalisa/received_events",
"type": "User",
"site_admin": true
},
"version": "468aac8caed5f0c3b859b8286968",
"committed_at": "2022-09-21T10:28:06Z",
"change_status": {
"total": 2,
"additions": 1,
"deletions": 1
},
"url": "https://api.github.com/gists/8481a81af6b7a2d418f2/468aac8caed5f0c3b859b8286968"
}
],
"truncated": false
}
Delete a gist
Tokens de acesso refinados para "Delete a gist"
Esse ponto de extremidade funciona com os seguintes tipos de token refinados:
O token refinado deve ter os seguintes conjuntos de permissões:
- "Gists" user permissions (write)
Parâmetros para "Delete a gist"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
gist_id string ObrigatórioThe unique identifier of the gist. |
Códigos de status de resposta HTTP para "Delete a gist"
Código de status | Descrição |
---|---|
204 | No Content |
304 | Not modified |
403 | Forbidden |
404 | Resource not found |
Exemplos de código para "Delete a gist"
Exemplo de solicitação
curl -L \
-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/gists/GIST_ID
Response
Status: 204
List gist commits
Tokens de acesso refinados para "List gist commits"
Esse ponto de extremidade funciona com os seguintes tipos de token refinados:
O token refinaado não requer permissões.
Parâmetros para "List gist commits"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
gist_id string ObrigatórioThe unique identifier of the gist. |
Nome, Tipo, Descrição |
---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Padrão: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Padrão: |
Códigos de status de resposta HTTP para "List gist commits"
Código de status | Descrição |
---|---|
200 | OK |
304 | Not modified |
403 | Forbidden |
404 | Resource not found |
Exemplos de código para "List gist commits"
Exemplo de solicitação
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/gists/GIST_ID/commits
Response
Status: 200
[
{
"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"
}
]
List gist forks
Tokens de acesso refinados para "List gist forks"
Esse ponto de extremidade funciona com os seguintes tipos de token refinados:
O token refinaado não requer permissões.
Parâmetros para "List gist forks"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
gist_id string ObrigatórioThe unique identifier of the gist. |
Nome, Tipo, Descrição |
---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Padrão: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Padrão: |
Códigos de status de resposta HTTP para "List gist forks"
Código de status | Descrição |
---|---|
200 | OK |
304 | Not modified |
403 | Forbidden |
404 | Resource not found |
Exemplos de código para "List gist forks"
Exemplo de solicitação
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/gists/GIST_ID/forks
Response
Status: 200
[
{
"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": 1,
"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
}
}
]
Fork a gist
Tokens de acesso refinados para "Fork a gist"
Esse ponto de extremidade funciona com os seguintes tipos de token refinados:
O token refinado deve ter os seguintes conjuntos de permissões:
- "Gists" user permissions (write)
Parâmetros para "Fork a gist"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
gist_id string ObrigatórioThe unique identifier of the gist. |
Códigos de status de resposta HTTP para "Fork a gist"
Código de status | Descrição |
---|---|
201 | Created |
304 | Not modified |
403 | Forbidden |
404 | Resource not found |
422 | Validation failed, or the endpoint has been spammed. |
Exemplos de código para "Fork a gist"
Exemplo de solicitação
curl -L \
-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/gists/GIST_ID/forks
Response
Status: 201
{
"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
}
Check if a gist is starred
Tokens de acesso refinados para "Check if a gist is starred"
Esse ponto de extremidade funciona com os seguintes tipos de token refinados:
O token refinaado não requer permissões.
Parâmetros para "Check if a gist is starred"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
gist_id string ObrigatórioThe unique identifier of the gist. |
Códigos de status de resposta HTTP para "Check if a gist is starred"
Código de status | Descrição |
---|---|
204 | Response if gist is starred |
304 | Not modified |
403 | Forbidden |
404 | Not Found if gist is not starred |
Exemplos de código para "Check if a gist is starred"
Exemplo de solicitação
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/gists/GIST_ID/star
Response if gist is starred
Status: 204
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 method."
Tokens de acesso refinados para "Star a gist"
Esse ponto de extremidade funciona com os seguintes tipos de token refinados:
O token refinado deve ter os seguintes conjuntos de permissões:
- "Gists" user permissions (write)
Parâmetros para "Star a gist"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
gist_id string ObrigatórioThe unique identifier of the gist. |
Códigos de status de resposta HTTP para "Star a gist"
Código de status | Descrição |
---|---|
204 | No Content |
304 | Not modified |
403 | Forbidden |
404 | Resource not found |
Exemplos de código para "Star a gist"
Exemplo de solicitação
curl -L \
-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/gists/GIST_ID/star
Response
Status: 204
Unstar a gist
Tokens de acesso refinados para "Unstar a gist"
Esse ponto de extremidade funciona com os seguintes tipos de token refinados:
O token refinado deve ter os seguintes conjuntos de permissões:
- "Gists" user permissions (write)
Parâmetros para "Unstar a gist"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
gist_id string ObrigatórioThe unique identifier of the gist. |
Códigos de status de resposta HTTP para "Unstar a gist"
Código de status | Descrição |
---|---|
204 | No Content |
304 | Not modified |
403 | Forbidden |
404 | Resource not found |
Exemplos de código para "Unstar a gist"
Exemplo de solicitação
curl -L \
-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/gists/GIST_ID/star
Response
Status: 204
Get a gist revision
Gets a specified gist revision.
This endpoint supports the following custom media types. For more information, see "Media types."
application/vnd.github.raw+json
: Returns the raw markdown. This is the default if you do not pass any specific media type.application/vnd.github.base64+json
: Returns the base64-encoded contents. This can be useful if your gist contains any invalid UTF-8 sequences.
Tokens de acesso refinados para "Get a gist revision"
Esse ponto de extremidade funciona com os seguintes tipos de token refinados:
O token refinaado não requer permissões.
Parâmetros para "Get a gist revision"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
gist_id string ObrigatórioThe unique identifier of the gist. |
sha string Obrigatório |
Códigos de status de resposta HTTP para "Get a gist revision"
Código de status | Descrição |
---|---|
200 | OK |
403 | Forbidden |
404 | Resource not found |
422 | Validation failed, or the endpoint has been spammed. |
Exemplos de código para "Get a gist revision"
Exemplo de solicitação
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/gists/GIST_ID/SHA
Response
Status: 200
{
"url": "https://api.github.com/gists/2decf6c462d9b4418f2",
"forks_url": "https://api.github.com/gists/2decf6c462d9b4418f2/forks",
"commits_url": "https://api.github.com/gists/2decf6c462d9b4418f2/commits",
"id": "2decf6c462d9b4418f2",
"node_id": "G_kwDOBhHyLdZDliNDQxOGYy",
"git_pull_url": "https://gist.github.com/2decf6c462d9b4418f2.git",
"git_push_url": "https://gist.github.com/2decf6c462d9b4418f2.git",
"html_url": "https://gist.github.com/2decf6c462d9b4418f2",
"files": {
"README.md": {
"filename": "README.md",
"type": "text/markdown",
"language": "Markdown",
"raw_url": "https://gist.githubusercontent.com/monalisa/2decf6c462d9b4418f2/raw/ac3e6daf176fafe73609fd000cd188e4472010fb/README.md",
"size": 23,
"truncated": false,
"content": "Hello world from GitHub"
}
},
"public": true,
"created_at": "2022-09-20T12:11:58Z",
"updated_at": "2022-09-21T10:28:06Z",
"description": "An updated gist description.",
"comments": 0,
"user": null,
"comments_url": "https://api.github.com/gists/2decf6c462d9b4418f2/comments",
"owner": {
"login": "monalisa",
"id": 104456405,
"node_id": "U_kgDOBhHyLQ",
"avatar_url": "https://avatars.githubusercontent.com/u/104456405?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/monalisa",
"html_url": "https://github.com/monalisa",
"followers_url": "https://api.github.com/users/monalisa/followers",
"following_url": "https://api.github.com/users/monalisa/following{/other_user}",
"gists_url": "https://api.github.com/users/monalisa/gists{/gist_id}",
"starred_url": "https://api.github.com/users/monalisa/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/monalisa/subscriptions",
"organizations_url": "https://api.github.com/users/monalisa/orgs",
"repos_url": "https://api.github.com/users/monalisa/repos",
"events_url": "https://api.github.com/users/monalisa/events{/privacy}",
"received_events_url": "https://api.github.com/users/monalisa/received_events",
"type": "User",
"site_admin": true
},
"forks": [],
"history": [
{
"user": {
"login": "monalisa",
"id": 104456405,
"node_id": "U_kgyLQ",
"avatar_url": "https://avatars.githubusercontent.com/u/104456405?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/monalisa",
"html_url": "https://github.com/monalisa",
"followers_url": "https://api.github.com/users/monalisa/followers",
"following_url": "https://api.github.com/users/monalisa/following{/other_user}",
"gists_url": "https://api.github.com/users/monalisa/gists{/gist_id}",
"starred_url": "https://api.github.com/users/monalisa/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/monalisa/subscriptions",
"organizations_url": "https://api.github.com/users/monalisa/orgs",
"repos_url": "https://api.github.com/users/monalisa/repos",
"events_url": "https://api.github.com/users/monalisa/events{/privacy}",
"received_events_url": "https://api.github.com/users/monalisa/received_events",
"type": "User",
"site_admin": true
},
"version": "468aac8caed5f0c3b859b8286968",
"committed_at": "2022-09-21T10:28:06Z",
"change_status": {
"total": 2,
"additions": 1,
"deletions": 1
},
"url": "https://api.github.com/gists/8481a81af6b7a2d418f2/468aac8caed5f0c3b859b8286968"
}
],
"truncated": false
}
List gists for a user
Lists public gists for the specified user:
Tokens de acesso refinados para "List gists for a user"
Esse ponto de extremidade funciona com os seguintes tipos de token refinados:
O token refinaado não requer permissões.
Parâmetros para "List gists for a user"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
username string ObrigatórioThe handle for the GitHub user account. |
Nome, Tipo, Descrição |
---|
since string Only show results that were last updated after the given time. This is a timestamp in ISO 8601 format: |
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Padrão: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Padrão: |
Códigos de status de resposta HTTP para "List gists for a user"
Código de status | Descrição |
---|---|
200 | OK |
422 | Validation failed, or the endpoint has been spammed. |
Exemplos de código para "List gists for a user"
Exemplo de solicitação
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/users/USERNAME/gists
Response
Status: 200
[
{
"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
}
]