用于 Gist 评论的 REST API 端点
使用 REST API 查看和修改 Gist 上的评论。
关于 Gist 评论
您可以使用 REST API 查看和修改 Gist 上的评论。有关 Gist 的更多信息,请参阅 "使用 Gist 编辑和共享内容."
列出 Gist 评论
列出 Gist 上的评论。
此端点支持以下自定义媒体类型。有关更多信息,请参阅 "媒体类型."
application/vnd.github.raw+json
: 返回原始 Markdown。如果您没有传递任何特定媒体类型,则为默认值。application/vnd.github.base64+json
: 返回 Base64 编码的内容。如果您的 Gist 包含任何无效的 UTF-8 序列,这将很有用。
用于“列出 Gist 评论”的细粒度访问令牌
此端点支持以下细粒度令牌类型
细粒度令牌不需要任何权限。
“列出 gist 评论”的参数
名称,类型,描述 |
---|
accept string 建议设置为 |
名称,类型,描述 |
---|
gist_id string 必需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/comments
响应
状态:200
[ { "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" } ]
创建 Gist 评论
在 Gist 上创建评论。
此端点支持以下自定义媒体类型。有关更多信息,请参阅 "媒体类型."
application/vnd.github.raw+json
: 返回原始 Markdown。如果您没有传递任何特定媒体类型,则为默认值。application/vnd.github.base64+json
: 返回 Base64 编码的内容。如果您的 Gist 包含任何无效的 UTF-8 序列,这将很有用。
用于“创建 Gist 评论”的细粒度访问令牌
此端点支持以下细粒度令牌类型
细粒度令牌必须具有以下权限集
- “Gists”用户权限(写入)
“创建 Gist 评论”的参数
名称,类型,描述 |
---|
accept string 建议设置为 |
名称,类型,描述 |
---|
gist_id string 必需gist 的唯一标识符。 |
名称,类型,描述 |
---|
body 字符串 必需评论文本。 |
“创建 Gist 评论”的 HTTP 响应状态码
状态代码 | 描述 |
---|---|
201 | 已创建 |
304 | 未修改 |
403 | 禁止 |
404 | 资源未找到 |
“创建 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/comments \ -d '{"body":"This is a comment to a gist"}'
响应
状态:201
{ "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" }
获取 Gist 评论
获取 Gist 上的评论。
此端点支持以下自定义媒体类型。有关更多信息,请参阅 "媒体类型."
application/vnd.github.raw+json
: 返回原始 Markdown。如果您没有传递任何特定媒体类型,则为默认值。application/vnd.github.base64+json
: 返回 Base64 编码的内容。如果您的 Gist 包含任何无效的 UTF-8 序列,这将很有用。
获取 Gist 评论的细粒度访问令牌
此端点支持以下细粒度令牌类型
细粒度令牌不需要任何权限。
获取 Gist 评论的参数
名称,类型,描述 |
---|
accept string 建议设置为 |
名称,类型,描述 |
---|
gist_id string 必需gist 的唯一标识符。 |
comment_id 整数 必需评论的唯一标识符。 |
获取 Gist 评论的 HTTP 响应状态码
状态代码 | 描述 |
---|---|
200 | OK |
304 | 未修改 |
403 | 禁止 Gist |
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/comments/COMMENT_ID
响应
状态:200
{ "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" }
更新 Gist 评论
更新 Gist 上的评论。
此端点支持以下自定义媒体类型。有关更多信息,请参阅 "媒体类型."
application/vnd.github.raw+json
: 返回原始 Markdown。如果您没有传递任何特定媒体类型,则为默认值。application/vnd.github.base64+json
: 返回 Base64 编码的内容。如果您的 Gist 包含任何无效的 UTF-8 序列,这将很有用。
更新 Gist 评论的细粒度访问令牌
此端点支持以下细粒度令牌类型
细粒度令牌必须具有以下权限集
- “Gists”用户权限(写入)
更新 Gist 评论的参数
名称,类型,描述 |
---|
accept string 建议设置为 |
名称,类型,描述 |
---|
gist_id string 必需gist 的唯一标识符。 |
comment_id 整数 必需评论的唯一标识符。 |
名称,类型,描述 |
---|
body 字符串 必需评论文本。 |
更新 Gist 评论的 HTTP 响应状态码
状态代码 | 描述 |
---|---|
200 | OK |
404 | 资源未找到 |
更新 Gist 评论的代码示例
请求示例
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/comments/COMMENT_ID \ -d '{"body":"This is an update to a comment in a gist"}'
响应
状态:200
{ "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" }
删除 Gist 评论
删除 Gist 评论的细粒度访问令牌
此端点支持以下细粒度令牌类型
细粒度令牌必须具有以下权限集
- “Gists”用户权限(写入)
删除 Gist 评论的参数
名称,类型,描述 |
---|
accept string 建议设置为 |
名称,类型,描述 |
---|
gist_id string 必需gist 的唯一标识符。 |
comment_id 整数 必需评论的唯一标识符。 |
删除 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/comments/COMMENT_ID
响应
状态:204