Skip to content

Instantly share code, notes, and snippets.

@ngs
Created December 12, 2012 09:32
Show Gist options
  • Save ngs/4266399 to your computer and use it in GitHub Desktop.
Save ngs/4266399 to your computer and use it in GitHub Desktop.
GitHub API Step by Step
{
"created_at": "2012-12-12T09:30:56Z",
"homepage": null,
"comments_url": "https://api.github.com/repos/ngs/testrepos0001/comments{/number}",
"subscribers_url": "https://api.github.com/repos/ngs/testrepos0001/subscribers",
"contributors_url": "https://api.github.com/repos/ngs/testrepos0001/contributors",
"collaborators_url": "https://api.github.com/repos/ngs/testrepos0001/collaborators{/collaborator}",
"network_count": 0,
"open_issues": 0,
"watchers": 0,
"pulls_url": "https://api.github.com/repos/ngs/testrepos0001/pulls{/number}",
"issue_comment_url": "https://api.github.com/repos/ngs/testrepos0001/issues/comments/{number}",
"blobs_url": "https://api.github.com/repos/ngs/testrepos0001/git/blobs{/sha}",
"owner": {
"type": "User",
"gravatar_id": "53bc8fa21f71dd8e63f3c94275c56191",
"organizations_url": "https://api.github.com/users/ngs/orgs",
"url": "https://api.github.com/users/ngs",
"repos_url": "https://api.github.com/users/ngs/repos",
"gists_url": "https://api.github.com/users/ngs/gists{/gist_id}",
"followers_url": "https://api.github.com/users/ngs/followers",
"events_url": "https://api.github.com/users/ngs/events{/privacy}",
"following_url": "https://api.github.com/users/ngs/following",
"received_events_url": "https://api.github.com/users/ngs/received_events",
"subscriptions_url": "https://api.github.com/users/ngs/subscriptions",
"starred_url": "https://api.github.com/users/ngs/starred{/owner}{/repo}",
"id": 18631,
"login": "ngs",
"avatar_url": "https://secure.gravatar.com/avatar/53bc8fa21f71dd8e63f3c94275c56191?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png"
},
"permissions": {
"push": true,
"admin": true,
"pull": true
},
"ssh_url": "[email protected]:ngs/testrepos0001.git",
"subscription_url": "https://api.github.com/repos/ngs/testrepos0001/subscription",
"teams_url": "https://api.github.com/repos/ngs/testrepos0001/teams",
"git_url": "git://github.com/ngs/testrepos0001.git",
"clone_url": "https://github.com/ngs/testrepos0001.git",
"labels_url": "https://api.github.com/repos/ngs/testrepos0001/labels{/name}",
"git_tags_url": "https://api.github.com/repos/ngs/testrepos0001/git/tags{/sha}",
"url": "https://api.github.com/repos/ngs/testrepos0001",
"description": null,
"issues_url": "https://api.github.com/repos/ngs/testrepos0001/issues{/number}",
"git_commits_url": "https://api.github.com/repos/ngs/testrepos0001/git/commits{/sha}",
"commits_url": "https://api.github.com/repos/ngs/testrepos0001/commits{/sha}",
"hooks_url": "https://api.github.com/repos/ngs/testrepos0001/hooks",
"updated_at": "2012-12-12T09:30:57Z",
"pushed_at": "2012-12-12T09:30:57Z",
"watchers_count": 0,
"language": null,
"open_issues_count": 0,
"milestones_url": "https://api.github.com/repos/ngs/testrepos0001/milestones{/number}",
"downloads_url": "https://api.github.com/repos/ngs/testrepos0001/downloads",
"git_refs_url": "https://api.github.com/repos/ngs/testrepos0001/git/refs{/sha}",
"tags_url": "https://api.github.com/repos/ngs/testrepos0001/tags{/tag}",
"events_url": "https://api.github.com/repos/ngs/testrepos0001/events",
"forks": 0,
"has_downloads": true,
"compare_url": "https://api.github.com/repos/ngs/testrepos0001/compare/{base}...{head}",
"contents_url": "https://api.github.com/repos/ngs/testrepos0001/contents/{+path}",
"issue_events_url": "https://api.github.com/repos/ngs/testrepos0001/issues/events{/number}",
"size": 0,
"has_issues": true,
"mirror_url": null,
"languages_url": "https://api.github.com/repos/ngs/testrepos0001/languages",
"trees_url": "https://api.github.com/repos/ngs/testrepos0001/git/trees{/sha}",
"forks_url": "https://api.github.com/repos/ngs/testrepos0001/forks",
"fork": false,
"master_branch": "master",
"merges_url": "https://api.github.com/repos/ngs/testrepos0001/merges",
"assignees_url": "https://api.github.com/repos/ngs/testrepos0001/assignees{/user}",
"name": "testrepos0001",
"svn_url": "https://github.com/ngs/testrepos0001",
"statuses_url": "https://api.github.com/repos/ngs/testrepos0001/statuses/{sha}",
"keys_url": "https://api.github.com/repos/ngs/testrepos0001/keys{/key_id}",
"html_url": "https://github.com/ngs/testrepos0001",
"private": false,
"full_name": "ngs/testrepos0001",
"id": 7127478,
"has_wiki": true,
"forks_count": 0,
"notifications_url": "https://api.github.com/repos/ngs/testrepos0001/notifications{?since,all,participating}",
"archive_url": "https://api.github.com/repos/ngs/testrepos0001/{archive_format}{/ref}",
"stargazers_url": "https://api.github.com/repos/ngs/testrepos0001/stargazers",
"branches_url": "https://api.github.com/repos/ngs/testrepos0001/branches{/branch}"
}
curl -H "Authorization: bearer $TOKEN" -X POST -d '{"name":"testrepos0001","auto_init":true}' https://api.github.com/user/repos
{
"url": "https://api.github.com/repos/ngs/testrepos0001/git/blobs/f2ba8f84ab5c1bce84a7b441cb1959cfc7093b7f",
"sha": "f2ba8f84ab5c1bce84a7b441cb1959cfc7093b7f"
}
curl -H "Authorization: bearer $TOKEN" -X POST -d '{"content":"abc","encoding":"utf-8"}' https://api.github.com/repos/ngs/testrepos0001/git/blobs
{
"url": "https://api.github.com/repos/ngs/testrepos0001/git/blobs/0c003832e7bfa9ca8b5c2035c9bd684a5f2623bc",
"sha": "0c003832e7bfa9ca8b5c2035c9bd684a5f2623bc"
}
curl -H "Authorization: bearer $TOKEN" -X POST -d '{"content":"def","encoding":"utf-8"}' https://api.github.com/repos/ngs/testrepos0001/git/blobs
{
"tree": [
{
"type": "tree",
"path": "test",
"mode": "040000",
"url": "https://api.github.com/repos/ngs/testrepos0001/git/trees/6e9184c6cb07e12634ee5a7ab3fedb46b2d19d48",
"sha": "6e9184c6cb07e12634ee5a7ab3fedb46b2d19d48"
}
],
"url": "https://api.github.com/repos/ngs/testrepos0001/git/trees/0fce3142caf1c872747a0a5efd9aa7894680f4a4",
"sha": "0fce3142caf1c872747a0a5efd9aa7894680f4a4"
}
curl -H "Authorization: bearer $TOKEN" -X POST -d '{"tree":[{"path":"test/abc.txt","mode":"100644","type":"blob","sha":"f2ba8f84ab5c1bce84a7b441cb1959cfc7093b7f"},{"path":"test/def.txt","mode":"100644","type":"blob","sha":"0c003832e7bfa9ca8b5c2035c9bd684a5f2623bc"}]}' https://api.github.com/repos/ngs/testrepos0001/git/trees
{
"_links": {
"html": "https://github.com/ngs/testrepos0001/tree/master",
"self": "https://api.github.com/repos/ngs/testrepos0001/branches/master"
},
"commit": {
"parents": [
],
"comments_url": "https://api.github.com/repos/ngs/testrepos0001/commits/fccaef61ed3528794727656e59824e35a84e2a1a/comments",
"url": "https://api.github.com/repos/ngs/testrepos0001/commits/fccaef61ed3528794727656e59824e35a84e2a1a",
"sha": "fccaef61ed3528794727656e59824e35a84e2a1a",
"author": {
"type": "User",
"events_url": "https://api.github.com/users/ngs/events{/privacy}",
"gravatar_id": "53bc8fa21f71dd8e63f3c94275c56191",
"repos_url": "https://api.github.com/users/ngs/repos",
"organizations_url": "https://api.github.com/users/ngs/orgs",
"starred_url": "https://api.github.com/users/ngs/starred{/owner}{/repo}",
"url": "https://api.github.com/users/ngs",
"gists_url": "https://api.github.com/users/ngs/gists{/gist_id}",
"followers_url": "https://api.github.com/users/ngs/followers",
"received_events_url": "https://api.github.com/users/ngs/received_events",
"following_url": "https://api.github.com/users/ngs/following",
"avatar_url": "https://secure.gravatar.com/avatar/53bc8fa21f71dd8e63f3c94275c56191?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png",
"subscriptions_url": "https://api.github.com/users/ngs/subscriptions",
"id": 18631,
"login": "ngs"
},
"commit": {
"tree": {
"url": "https://api.github.com/repos/ngs/testrepos0001/git/trees/edf0f28690a23346d96c0ef4aecab32e02f280d9",
"sha": "edf0f28690a23346d96c0ef4aecab32e02f280d9"
},
"url": "https://api.github.com/repos/ngs/testrepos0001/git/commits/fccaef61ed3528794727656e59824e35a84e2a1a",
"message": "Initial commit",
"author": {
"date": "2012-12-12T09:30:57Z",
"email": "[email protected]",
"name": "Atsushi NAGASE"
},
"comment_count": 0,
"committer": {
"date": "2012-12-12T09:30:57Z",
"email": "[email protected]",
"name": "Atsushi NAGASE"
}
},
"committer": {
"type": "User",
"events_url": "https://api.github.com/users/ngs/events{/privacy}",
"gravatar_id": "53bc8fa21f71dd8e63f3c94275c56191",
"repos_url": "https://api.github.com/users/ngs/repos",
"organizations_url": "https://api.github.com/users/ngs/orgs",
"starred_url": "https://api.github.com/users/ngs/starred{/owner}{/repo}",
"url": "https://api.github.com/users/ngs",
"gists_url": "https://api.github.com/users/ngs/gists{/gist_id}",
"followers_url": "https://api.github.com/users/ngs/followers",
"received_events_url": "https://api.github.com/users/ngs/received_events",
"following_url": "https://api.github.com/users/ngs/following",
"avatar_url": "https://secure.gravatar.com/avatar/53bc8fa21f71dd8e63f3c94275c56191?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png",
"subscriptions_url": "https://api.github.com/users/ngs/subscriptions",
"id": 18631,
"login": "ngs"
}
},
"name": "master"
}
curl -H "Authorization: bearer $TOKEN" https://api.github.com/repos/ngs/testrepos0001/branches/master
{
"tree": {
"url": "https://api.github.com/repos/ngs/testrepos0001/git/trees/0fce3142caf1c872747a0a5efd9aa7894680f4a4",
"sha": "0fce3142caf1c872747a0a5efd9aa7894680f4a4"
},
"parents": [
{
"url": "https://api.github.com/repos/ngs/testrepos0001/git/commits/fccaef61ed3528794727656e59824e35a84e2a1a",
"sha": "fccaef61ed3528794727656e59824e35a84e2a1a"
}
],
"url": "https://api.github.com/repos/ngs/testrepos0001/git/commits/81d98eb3a8ec06189e455c8e308d602815f85dbb",
"sha": "81d98eb3a8ec06189e455c8e308d602815f85dbb",
"message": "test commit 1",
"author": {
"date": "2012-12-12T10:01:57Z",
"email": "[email protected]",
"name": "Atsushi NAGASE"
},
"committer": {
"date": "2012-12-12T10:01:57Z",
"email": "[email protected]",
"name": "Atsushi NAGASE"
}
}
curl -H "Authorization: bearer $TOKEN" -X POST -d '{"message":"test commit 1","parents":["fccaef61ed3528794727656e59824e35a84e2a1a"],"tree":"0fce3142caf1c872747a0a5efd9aa7894680f4a4"}' https://api.github.com/repos/ngs/testrepos0001/git/commits
{
"ref": "refs/heads/master",
"object": {
"type": "commit",
"url": "https://api.github.com/repos/ngs/testrepos0001/git/commits/81d98eb3a8ec06189e455c8e308d602815f85dbb",
"sha": "81d98eb3a8ec06189e455c8e308d602815f85dbb"
},
"url": "https://api.github.com/repos/ngs/testrepos0001/git/refs/heads/master"
}
curl -H "Authorization: bearer $TOKEN" -X PATCH -d '{"force":false,"sha":"81d98eb3a8ec06189e455c8e308d602815f85dbb"}' https://api.github.com/repos/ngs/testrepos0001/git/refs/heads/master
{
"tree": [
{
"type": "tree",
"path": "test",
"mode": "040000",
"url": "https://api.github.com/repos/ngs/testrepos0001/git/trees/6e9184c6cb07e12634ee5a7ab3fedb46b2d19d48",
"sha": "6e9184c6cb07e12634ee5a7ab3fedb46b2d19d48"
},
{
"type": "blob",
"path": "test/abc.txt",
"mode": "100644",
"url": "https://api.github.com/repos/ngs/testrepos0001/git/blobs/f2ba8f84ab5c1bce84a7b441cb1959cfc7093b7f",
"sha": "f2ba8f84ab5c1bce84a7b441cb1959cfc7093b7f",
"size": 3
},
{
"type": "blob",
"path": "test/def.txt",
"mode": "100644",
"url": "https://api.github.com/repos/ngs/testrepos0001/git/blobs/0c003832e7bfa9ca8b5c2035c9bd684a5f2623bc",
"sha": "0c003832e7bfa9ca8b5c2035c9bd684a5f2623bc",
"size": 3
}
],
"url": "https://api.github.com/repos/ngs/testrepos0001/git/trees/81d98eb3a8ec06189e455c8e308d602815f85dbb",
"sha": "81d98eb3a8ec06189e455c8e308d602815f85dbb"
}
curl -H "Authorization: bearer $TOKEN" https://api.github.com/repos/ngs/testrepos0001/git/trees/81d98eb3a8ec06189e455c8e308d602815f85dbb?recursive=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment