用于 Gist 的 REST API 端点
使用 REST API 列出、创建、更新和删除 GitHub 上的公共 Gist。
关于 Gist
您可以使用 REST API 查看和修改 Gist。有关 Gist 的更多信息,请参阅“使用 Gist 编辑和共享内容”。
身份验证
您可以匿名读取公共 Gist,但必须登录 GitHub 才能创建 Gist。要代表用户读取或写入 Gist,您需要 Gist OAuth 范围和令牌。有关更多信息,请参阅“OAuth 应用的范围”。
截断
API 为 Gist 中的每个文件提供最多 1 MB 的内容。通过 API 返回的每个 Gist 文件都有一个名为 truncated
的键。如果 truncated
为 true
,则文件太大,并且仅在 content
中返回了部分内容。
如果您需要文件的完整内容,您可以对 raw_url
指定的 URL 发出 GET
请求。请注意,对于大于 10 MB 的文件,您需要通过 git_pull_url
提供的 URL 克隆 Gist。
除了特定文件的內容被截斷外,如果總數超過 300 個文件,整個文件列表也可能會被截斷。如果頂級 truncated
鍵為 true
,則僅在文件列表中返回了前 300 個文件。如果您需要获取所有 Gist 文件,您需要通过 git_pull_url
提供的 URL 克隆 Gist。
列出经过身份验证用户的 Gist
列出经过身份验证用户的 Gist,或者如果匿名调用,则此端点将返回所有公共 Gist
用于“列出经过身份验证用户的 Gist”的细粒度访问令牌
此端点适用于以下细粒度令牌类型
细粒度令牌不需要任何权限。
用于“列出经过身份验证用户的 Gist”的参数
名称、类型、描述 |
---|
accept string 建议设置为 |
名称、类型、描述 |
---|
since string 仅显示最后更新时间在给定时间之后的結果。这是一个 ISO 8601 格式的时间戳: |
per_page integer 每页结果数(最大 100)。有关更多信息,请参阅“在 REST API 中使用分页”。 默认: |
page integer 要获取的结果页码。有关更多信息,请参阅“在 REST API 中使用分页”。 默认: |
“列出经过身份验证用户的 Gist”的 HTTP 响应状态代码
状态代码 | 描述 |
---|---|
200 | OK |
304 | 未修改 |
403 | 禁止 |
“列出经过身份验证用户的 Gist”的代码示例
请求示例
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
响应
状态: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 } ]
创建 Gist
允许您添加一个或多个文件的新 Gist。
注意: 不要将您的文件命名为带有数字后缀的“gistfile”。这是 Gist 在内部使用的自动命名方案的格式。
“创建 Gist”的细粒度访问令牌
此端点适用于以下细粒度令牌类型
细粒度令牌必须具有以下权限集
- “Gists”用户权限(写入)
“创建 Gist”的参数
名称、类型、描述 |
---|
accept string 建议设置为 |
名称、类型、描述 | |||||
---|---|---|---|---|---|
description 字符串 Gist 的描述 | |||||
files 对象 必需构成 Gist 的文件的名称和内容 | |||||
|
名称、类型、描述 | ||
---|---|---|
key 对象 一个用户定义的键,用于表示 | ||
|
名称、类型、描述 |
---|
content 字符串 必需文件的内容 |
public
布尔值或字符串 指示 Gist 是否公开的标志
“创建 Gist”的 HTTP 响应状态码
状态代码 | 描述 |
---|---|
201 | 已创建 |
304 | 未修改 |
403 | 禁止 |
404 | 资源未找到 |
422 | 验证失败,或端点已被垃圾邮件。 |
“创建 Gist”的代码示例
请求示例
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"}}}'
响应
状态: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
}
列出公共 Gist
列出按最近更新到最旧更新排序的公共 Gist。
注意:使用 分页,您可以获取最多 3000 个 Gist。例如,您可以获取 100 页,每页 30 个 Gist,或者 30 页,每页 100 个 Gist。
“列出公共 Gist”的细粒度访问令牌
此端点适用于以下细粒度令牌类型
细粒度令牌不需要任何权限。
“列出公共 Gist”的参数
名称、类型、描述 |
---|
accept string 建议设置为 |
名称、类型、描述 |
---|
since string 仅显示最后更新时间在给定时间之后的結果。这是一个 ISO 8601 格式的时间戳: |
per_page integer 每页结果数(最大 100)。有关更多信息,请参阅“在 REST API 中使用分页”。 默认: |
page integer 要获取的结果页码。有关更多信息,请参阅“在 REST API 中使用分页”。 默认: |
“列出公共 Gist”的 HTTP 响应状态码
状态代码 | 描述 |
---|---|
200 | OK |
304 | 未修改 |
403 | 禁止 |
422 | 验证失败,或端点已被垃圾邮件。 |
“列出公共 Gist”的代码示例
请求示例
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
响应
状态: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 } ]
列出公开的 Gist
列出所有公开的 Gist。
用于“列出公开的 Gist”的细粒度访问令牌
此端点适用于以下细粒度令牌类型
细粒度令牌不需要任何权限。
“列出公开的 Gist”的参数
名称、类型、描述 |
---|
accept string 建议设置为 |
名称、类型、描述 |
---|
since string 仅显示最后更新时间在给定时间之后的結果。这是一个 ISO 8601 格式的时间戳: |
per_page integer 每页结果数(最大 100)。有关更多信息,请参阅“在 REST API 中使用分页”。 默认: |
page integer 要获取的结果页码。有关更多信息,请参阅“在 REST API 中使用分页”。 默认: |
“列出公开的 Gist”的 HTTP 响应状态码
状态代码 | 描述 |
---|---|
200 | OK |
304 | 未修改 |
401 | 需要身份验证 |
403 | 禁止 |
“列出公开的 Gist”的代码示例
请求示例
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
响应
状态: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 } ]
列出加星标的 Gist
列出已认证用户的加星标 Gist。
用于“列出加星标的 Gist”的细粒度访问令牌
- “列出加星标的 Gist”的参数
- “列出加星标的 Gist”的 HTTP 响应状态码
需要身份验证
此端点适用于以下细粒度令牌类型
细粒度令牌不需要任何权限。
“列出加星标的 Gist”的代码示例
名称、类型、描述 |
---|
accept string 建议设置为 |
名称、类型、描述 |
---|
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 获取 Gist |
获取指定的 Gist。
状态代码 | 描述 |
---|---|
200 | OK |
304 | 未修改 |
403 | 此端点支持以下自定义媒体类型。有关更多信息,请参阅“媒体类型”。 |
404 | 资源未找到 |
application/vnd.github.raw+json
: 返回原始 Markdown。如果您没有传递任何特定媒体类型,则这是默认值。
请求示例
application/vnd.github.base64+json
: 返回 Base64 编码的内容。如果您的 Gist 包含任何无效的 UTF-8 序列,这将很有用。用于“获取 Gist”的细粒度访问令牌
响应
状态: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
}
“获取 Gist”的参数
路径参数
gist_id
string 必填
用于“列出加星标的 Gist”的细粒度访问令牌
- “列出加星标的 Gist”的参数
- “列出加星标的 Gist”的 HTTP 响应状态码
Gist 的唯一标识符。
此端点适用于以下细粒度令牌类型
细粒度令牌必须具有以下权限集
- “Gists”用户权限(写入)
“获取 Gist”的 HTTP 响应状态码
名称、类型、描述 |
---|
accept string 建议设置为 |
名称、类型、描述 |
---|
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 获取 Gist |
名称、类型、描述 | ||||||
---|---|---|---|---|---|---|
description 字符串 摘要的描述。 | ||||||
files 对象 要更新、重命名或删除的摘要文件。每个 要删除文件,请将整个文件设置为 null。例如: | ||||||
|
名称、类型、描述 | |||
---|---|---|---|
key 对象 一个用户定义的键,用于表示 | |||
|
名称、类型、描述 |
---|
content 字符串 文件的新的内容。 |
filename 字符串或 null 文件的新的文件名。 |
“更新摘要”的 HTTP 响应状态代码
状态代码 | 描述 |
---|---|
200 | OK |
404 | 资源未找到 |
422 | 验证失败,或端点已被垃圾邮件。 |
“更新摘要”的代码示例
请求示例
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"}}}'
响应
状态: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
}
删除摘要
“删除摘要”的细粒度访问令牌
此端点适用于以下细粒度令牌类型
细粒度令牌必须具有以下权限集
- “Gists”用户权限(写入)
“删除摘要”的参数
名称、类型、描述 |
---|
accept string 建议设置为 |
名称、类型、描述 |
---|
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 获取 Gist |
“删除摘要”的 HTTP 响应状态代码
状态代码 | 描述 |
---|---|
204 | 无内容 |
304 | 未修改 |
403 | 禁止 |
404 | 资源未找到 |
“删除摘要”的代码示例
请求示例
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
响应
状态:204
列出摘要提交
“列出 gist 提交”的细粒度访问令牌
此端点适用于以下细粒度令牌类型
细粒度令牌不需要任何权限。
“列出 gist 提交”的参数
名称、类型、描述 |
---|
accept string 建议设置为 |
名称、类型、描述 |
---|
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 获取 Gist |
名称、类型、描述 |
---|
per_page integer 每页结果数(最大 100)。有关更多信息,请参阅“在 REST API 中使用分页”。 默认: |
page integer 要获取的结果页码。有关更多信息,请参阅“在 REST API 中使用分页”。 默认: |
“列出 gist 提交”的 HTTP 响应状态码
状态代码 | 描述 |
---|---|
200 | OK |
304 | 未修改 |
403 | 禁止 |
404 | 资源未找到 |
“列出 gist 提交”的代码示例
请求示例
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
响应
状态: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" } ]
列出 gist 分支
“列出 gist 分支”的细粒度访问令牌
此端点适用于以下细粒度令牌类型
细粒度令牌不需要任何权限。
“列出 gist 分支”的参数
名称、类型、描述 |
---|
accept string 建议设置为 |
名称、类型、描述 |
---|
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 获取 Gist |
名称、类型、描述 |
---|
per_page integer 每页结果数(最大 100)。有关更多信息,请参阅“在 REST API 中使用分页”。 默认: |
page integer 要获取的结果页码。有关更多信息,请参阅“在 REST API 中使用分页”。 默认: |
“列出 gist 分支”的 HTTP 响应状态码
状态代码 | 描述 |
---|---|
200 | OK |
304 | 未修改 |
403 | 禁止 |
404 | 资源未找到 |
“列出 gist 分支”的代码示例
请求示例
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
响应
状态: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 gist
用于“Fork gist”的细粒度访问令牌
此端点适用于以下细粒度令牌类型
细粒度令牌必须具有以下权限集
- “Gists”用户权限(写入)
“Fork gist”的参数
名称、类型、描述 |
---|
accept string 建议设置为 |
名称、类型、描述 |
---|
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 获取 Gist |
“Fork gist”的 HTTP 响应状态码
状态代码 | 描述 |
---|---|
201 | 已创建 |
304 | 未修改 |
403 | 禁止 |
404 | 资源未找到 |
422 | 验证失败,或端点已被垃圾邮件。 |
“Fork gist”的代码示例
请求示例
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
响应
状态: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 }
检查是否收藏了 Gist
用于“检查是否收藏了 Gist”的细粒度访问令牌
此端点适用于以下细粒度令牌类型
细粒度令牌不需要任何权限。
用于“检查是否收藏了 Gist”的参数
名称、类型、描述 |
---|
accept string 建议设置为 |
名称、类型、描述 |
---|
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 获取 Gist |
用于“检查是否收藏了 Gist”的 HTTP 响应状态码
状态代码 | 描述 |
---|---|
204 | 如果收藏了 Gist,则返回响应 |
304 | 未修改 |
403 | 禁止 |
404 | 如果未收藏 Gist,则返回“未找到” |
用于“检查是否收藏了 Gist”的代码示例
请求示例
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
如果收藏了 Gist,则返回响应
状态:204
收藏 Gist
请注意,调用此端点时,您需要将 Content-Length
设置为零。有关更多信息,请参阅“HTTP 方法”。
用于“收藏 Gist”的细粒度访问令牌
此端点适用于以下细粒度令牌类型
细粒度令牌必须具有以下权限集
- “Gists”用户权限(写入)
用于“收藏 Gist”的参数
名称、类型、描述 |
---|
accept string 建议设置为 |
名称、类型、描述 |
---|
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 获取 Gist |
用于“收藏 Gist”的 HTTP 响应状态码
状态代码 | 描述 |
---|---|
204 | 无内容 |
304 | 未修改 |
403 | 禁止 |
404 | 资源未找到 |
用于“收藏 Gist”的代码示例
请求示例
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
响应
状态:204
取消收藏 Gist
取消收藏 Gist 的细粒度访问令牌
此端点适用于以下细粒度令牌类型
细粒度令牌必须具有以下权限集
- “Gists”用户权限(写入)
取消收藏 Gist 的参数
名称、类型、描述 |
---|
accept string 建议设置为 |
名称、类型、描述 |
---|
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 获取 Gist |
取消收藏 Gist 的 HTTP 响应状态码
状态代码 | 描述 |
---|---|
204 | 无内容 |
304 | 未修改 |
403 | 禁止 |
404 | 资源未找到 |
取消收藏 Gist 的代码示例
请求示例
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
响应
状态:204
获取 Gist 版本
获取指定的 Gist 版本。
用于“列出加星标的 Gist”的细粒度访问令牌
- “列出加星标的 Gist”的参数
- “列出加星标的 Gist”的 HTTP 响应状态码
获取 Gist 版本的细粒度访问令牌
此端点适用于以下细粒度令牌类型
细粒度令牌不需要任何权限。
获取 Gist 版本的参数
名称、类型、描述 |
---|
accept string 建议设置为 |
名称、类型、描述 |
---|
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 获取 Gist |
sha string 必填 |
获取 Gist 版本的 HTTP 响应状态码
状态代码 | 描述 |
---|---|
200 | OK |
403 | 禁止 |
404 | 资源未找到 |
422 | 验证失败,或端点已被垃圾邮件。 |
获取 Gist 版本的代码示例
请求示例
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
响应
状态: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
}
列出用户的 Gist
列出指定用户的公开 Gist
列出用户的 Gist 的细粒度访问令牌
此端点适用于以下细粒度令牌类型
细粒度令牌不需要任何权限。
列出用户的 Gist 的参数
名称、类型、描述 |
---|
accept string 建议设置为 |
名称、类型、描述 |
---|
username string 必填GitHub 用户帐户的句柄。 |
名称、类型、描述 |
---|
since string 仅显示最后更新时间在给定时间之后的結果。这是一个 ISO 8601 格式的时间戳: |
per_page integer 每页结果数(最大 100)。有关更多信息,请参阅“在 REST API 中使用分页”。 默认: |
page integer 要获取的结果页码。有关更多信息,请参阅“在 REST API 中使用分页”。 默认: |
列出用户的 Gist 的 HTTP 响应状态码
状态代码 | 描述 |
---|---|
200 | OK |
422 | 验证失败,或端点已被垃圾邮件。 |
列出用户的 Gist 的代码示例
请求示例
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
响应
状态: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 } ]