GitHub Public API
This is just a quick self documentation for some GitHub API (Application Programming Interface) endpoints with which I have recently experimented.
GitHub provides APIs for accessing its data. GitHub developer documentation hints that some of those can be accessed without credentials. This is handy when you want to quickly test some ideas using GitHub data. Sure, there are more restrictions applied to unauthenticated services e.g. it is only allowable to request 60 API calls an hour. For my case this figure is acceptable.
For a comprehensive usage information, please refer to the official documentations:
- GitHub API v3 | GitHub Developer Guide
- Users Endpoints
- Organizations Endpoints
- Repositories Endpoints
All API access is over HTTPS, and accessed from https://api.github.com. All data is sent and received as JSON.
Users Endpoints
Example Request: curl -i https://api.github.com/users/eueung
Response:
HTTP/1.1 200 OK
Date: Sun, 22 Mar 2020 06:12:39 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 1296
Server: GitHub.com
Status: 200 OK
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 57
X-RateLimit-Reset: 1584857815
Cache-Control: public, max-age=60, s-maxage=60
Vary: Accept
ETag: "23977877a871e3d68730b97b5f8b8ed9"
Last-Modified: Wed, 18 Mar 2020 06:58:43 GMT
X-GitHub-Media-Type: github.v3; format=json
Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset
Access-Control-Allow-Origin: *
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Frame-Options: deny
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
Content-Security-Policy: default-src 'none'
Vary: Accept-Encoding, Accept, X-Requested-With
X-GitHub-Request-Id: DD56:7AD2:1E9BAD9:25FED00:5E7701D7
{
"login": "eueung",
"id": 4231611,
"node_id": "MDQ6VXNlcjQyMzE2MTE=",
"avatar_url": "https://avatars0.githubusercontent.com/u/4231611?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/eueung",
"html_url": "https://github.com/eueung",
"followers_url": "https://api.github.com/users/eueung/followers",
"following_url": "https://api.github.com/users/eueung/following{/other_user}",
"gists_url": "https://api.github.com/users/eueung/gists{/gist_id}",
"starred_url": "https://api.github.com/users/eueung/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/eueung/subscriptions",
"organizations_url": "https://api.github.com/users/eueung/orgs",
"repos_url": "https://api.github.com/users/eueung/repos",
"events_url": "https://api.github.com/users/eueung/events{/privacy}",
"received_events_url": "https://api.github.com/users/eueung/received_events",
"type": "User",
"site_admin": false,
"name": "Eueung Mulyana",
"company": "Institut Teknologi Bandung (ITB)",
"blog": "",
"location": "Bandung, Indonesia",
"email": null,
"hireable": null,
"bio": null,
"public_repos": 45,
"public_gists": 4,
"followers": 106,
"following": 8,
"created_at": "2013-04-23T05:34:18Z",
"updated_at": "2020-03-18T06:58:43Z"
}
This response gives the following list of other users endpoints.
https://api.github.com/users/eueung
https://api.github.com/users/eueung/repos
https://api.github.com/users/eueung/events{/privacy}
https://api.github.com/users/eueung/followers
https://api.github.com/users/eueung/following{/other_user}
https://api.github.com/users/eueung/gists{/gist_id}
https://api.github.com/users/eueung/starred{/owner}{/repo}
https://api.github.com/users/eueung/subscriptions
https://api.github.com/users/eueung/orgs
https://api.github.com/users/eueung/received_events
Orgs Endpoints
Example Request: curl https://api.github.com/orgs/google
Response:
{
"login": "google",
"id": 1342004,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjEzNDIwMDQ=",
"url": "https://api.github.com/orgs/google",
"repos_url": "https://api.github.com/orgs/google/repos",
"events_url": "https://api.github.com/orgs/google/events",
"hooks_url": "https://api.github.com/orgs/google/hooks",
"issues_url": "https://api.github.com/orgs/google/issues",
"members_url": "https://api.github.com/orgs/google/members{/member}",
"public_members_url": "https://api.github.com/orgs/google/public_members{/member}",
"avatar_url": "https://avatars1.githubusercontent.com/u/1342004?v=4",
"description": "Google ❤️ Open Source",
"name": "Google",
"company": null,
"blog": "https://opensource.google/",
"location": null,
"email": "opensource@google.com",
"is_verified": true,
"has_organization_projects": true,
"has_repository_projects": true,
"public_repos": 1697,
"public_gists": 0,
"followers": 0,
"following": 0,
"html_url": "https://github.com/google",
"created_at": "2012-01-18T01:30:18Z",
"updated_at": "2019-12-19T21:09:14Z",
"type": "Organization"
}
This response gives the following list of other orgs endpoints.
https://api.github.com/orgs/google
https://api.github.com/orgs/google/repos
https://api.github.com/orgs/google/events
https://api.github.com/orgs/google/hooks
https://api.github.com/orgs/google/issues
https://api.github.com/orgs/google/members{/member}
https://api.github.com/orgs/google/public_members{/member}
Repos Endpoints
Example Request: curl https://api.github.com/repos/flutter/flutter
Response:
{
"id": 31792824,
"node_id": "MDEwOlJlcG9zaXRvcnkzMTc5MjgyNA==",
"name": "flutter",
"full_name": "flutter/flutter",
"private": false,
"owner": {
"login": "flutter",
"id": 14101776,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE0MTAxNzc2",
"avatar_url": "https://avatars3.githubusercontent.com/u/14101776?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/flutter",
"html_url": "https://github.com/flutter",
"followers_url": "https://api.github.com/users/flutter/followers",
"following_url": "https://api.github.com/users/flutter/following{/other_user}",
"gists_url": "https://api.github.com/users/flutter/gists{/gist_id}",
"starred_url": "https://api.github.com/users/flutter/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/flutter/subscriptions",
"organizations_url": "https://api.github.com/users/flutter/orgs",
"repos_url": "https://api.github.com/users/flutter/repos",
"events_url": "https://api.github.com/users/flutter/events{/privacy}",
"received_events_url": "https://api.github.com/users/flutter/received_events",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/flutter/flutter",
"description": "Flutter makes it easy and fast to build beautiful mobile apps.",
"fork": false,
"url": "https://api.github.com/repos/flutter/flutter",
"forks_url": "https://api.github.com/repos/flutter/flutter/forks",
"keys_url": "https://api.github.com/repos/flutter/flutter/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/flutter/flutter/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/flutter/flutter/teams",
"hooks_url": "https://api.github.com/repos/flutter/flutter/hooks",
"issue_events_url": "https://api.github.com/repos/flutter/flutter/issues/events{/number}",
"events_url": "https://api.github.com/repos/flutter/flutter/events",
"assignees_url": "https://api.github.com/repos/flutter/flutter/assignees{/user}",
"branches_url": "https://api.github.com/repos/flutter/flutter/branches{/branch}",
"tags_url": "https://api.github.com/repos/flutter/flutter/tags",
"blobs_url": "https://api.github.com/repos/flutter/flutter/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/flutter/flutter/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/flutter/flutter/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/flutter/flutter/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/flutter/flutter/statuses/{sha}",
"languages_url": "https://api.github.com/repos/flutter/flutter/languages",
"stargazers_url": "https://api.github.com/repos/flutter/flutter/stargazers",
"contributors_url": "https://api.github.com/repos/flutter/flutter/contributors",
"subscribers_url": "https://api.github.com/repos/flutter/flutter/subscribers",
"subscription_url": "https://api.github.com/repos/flutter/flutter/subscription",
"commits_url": "https://api.github.com/repos/flutter/flutter/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/flutter/flutter/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/flutter/flutter/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/flutter/flutter/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/flutter/flutter/contents/{+path}",
"compare_url": "https://api.github.com/repos/flutter/flutter/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/flutter/flutter/merges",
"archive_url": "https://api.github.com/repos/flutter/flutter/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/flutter/flutter/downloads",
"issues_url": "https://api.github.com/repos/flutter/flutter/issues{/number}",
"pulls_url": "https://api.github.com/repos/flutter/flutter/pulls{/number}",
"milestones_url": "https://api.github.com/repos/flutter/flutter/milestones{/number}",
"notifications_url": "https://api.github.com/repos/flutter/flutter/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/flutter/flutter/labels{/name}",
"releases_url": "https://api.github.com/repos/flutter/flutter/releases{/id}",
"deployments_url": "https://api.github.com/repos/flutter/flutter/deployments",
"created_at": "2015-03-06T22:54:58Z",
"updated_at": "2020-03-22T04:11:43Z",
"pushed_at": "2020-03-22T00:07:49Z",
"git_url": "git://github.com/flutter/flutter.git",
"ssh_url": "git@github.com:flutter/flutter.git",
"clone_url": "https://github.com/flutter/flutter.git",
"svn_url": "https://github.com/flutter/flutter",
"homepage": "https://flutter.dev",
"size": 95886,
"stargazers_count": 88732,
"watchers_count": 88732,
"language": "Dart",
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": false,
"forks_count": 11758,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 7366,
"license": {
"key": "bsd-3-clause",
"name": "BSD 3-Clause \"New\" or \"Revised\" License",
"spdx_id": "BSD-3-Clause",
"url": "https://api.github.com/licenses/bsd-3-clause",
"node_id": "MDc6TGljZW5zZTU="
},
"forks": 11758,
"open_issues": 7366,
"watchers": 88732,
"default_branch": "master",
"temp_clone_token": null,
"organization": {
"login": "flutter",
"id": 14101776,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE0MTAxNzc2",
"avatar_url": "https://avatars3.githubusercontent.com/u/14101776?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/flutter",
"html_url": "https://github.com/flutter",
"followers_url": "https://api.github.com/users/flutter/followers",
"following_url": "https://api.github.com/users/flutter/following{/other_user}",
"gists_url": "https://api.github.com/users/flutter/gists{/gist_id}",
"starred_url": "https://api.github.com/users/flutter/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/flutter/subscriptions",
"organizations_url": "https://api.github.com/users/flutter/orgs",
"repos_url": "https://api.github.com/users/flutter/repos",
"events_url": "https://api.github.com/users/flutter/events{/privacy}",
"received_events_url": "https://api.github.com/users/flutter/received_events",
"type": "Organization",
"site_admin": false
},
"network_count": 11758,
"subscribers_count": 2732
}
This response gives the following list of other repos endpoints.
https://api.github.com/repos/flutter/flutter
https://api.github.com/repos/flutter/flutter/forks
https://api.github.com/repos/flutter/flutter/keys{/key_id}
https://api.github.com/repos/flutter/flutter/collaborators{/collaborator}
https://api.github.com/repos/flutter/flutter/teams
https://api.github.com/repos/flutter/flutter/hooks
https://api.github.com/repos/flutter/flutter/issues/events{/number}
https://api.github.com/repos/flutter/flutter/events
https://api.github.com/repos/flutter/flutter/assignees{/user}
https://api.github.com/repos/flutter/flutter/branches{/branch}
https://api.github.com/repos/flutter/flutter/tags
https://api.github.com/repos/flutter/flutter/git/blobs{/sha}
https://api.github.com/repos/flutter/flutter/git/tags{/sha}
https://api.github.com/repos/flutter/flutter/git/refs{/sha}
https://api.github.com/repos/flutter/flutter/git/trees{/sha}
https://api.github.com/repos/flutter/flutter/statuses/{sha}
https://api.github.com/repos/flutter/flutter/languages
https://api.github.com/repos/flutter/flutter/stargazers
https://api.github.com/repos/flutter/flutter/contributors
https://api.github.com/repos/flutter/flutter/subscribers
https://api.github.com/repos/flutter/flutter/subscription
https://api.github.com/repos/flutter/flutter/commits{/sha}
https://api.github.com/repos/flutter/flutter/git/commits{/sha}
https://api.github.com/repos/flutter/flutter/comments{/number}
https://api.github.com/repos/flutter/flutter/issues/comments{/number}
https://api.github.com/repos/flutter/flutter/contents/{+path}
https://api.github.com/repos/flutter/flutter/compare/{base}...{head}
https://api.github.com/repos/flutter/flutter/merges
https://api.github.com/repos/flutter/flutter/{archive_format}{/ref}
https://api.github.com/repos/flutter/flutter/downloads
https://api.github.com/repos/flutter/flutter/issues{/number}
https://api.github.com/repos/flutter/flutter/pulls{/number}
https://api.github.com/repos/flutter/flutter/milestones{/number}
https://api.github.com/repos/flutter/flutter/notifications{?since,all,participating}
https://api.github.com/repos/flutter/flutter/labels{/name}
https://api.github.com/repos/flutter/flutter/releases{/id}
https://api.github.com/repos/flutter/flutter/deployments
Miscellaneous
The following snippet shows request and the corresponding response for starred repositories.
curl https://api.github.com/users/eueung/starred?per_page=1&page=1
[
{
"id": 247289496,
"node_id": "MDEwOlJlcG9zaXRvcnkyNDcyODk0OTY=",
"name": "cv19index",
"full_name": "closedloop-ai/cv19index",
"private": false,
"owner": {
"login": "closedloop-ai",
"id": 48066451,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjQ4MDY2NDUx",
"avatar_url": "https://avatars3.githubusercontent.com/u/48066451?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/closedloop-ai",
"html_url": "https://github.com/closedloop-ai",
"followers_url": "https://api.github.com/users/closedloop-ai/followers",
"following_url": "https://api.github.com/users/closedloop-ai/following{/other_user}",
"gists_url": "https://api.github.com/users/closedloop-ai/gists{/gist_id}",
"starred_url": "https://api.github.com/users/closedloop-ai/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/closedloop-ai/subscriptions",
"organizations_url": "https://api.github.com/users/closedloop-ai/orgs",
"repos_url": "https://api.github.com/users/closedloop-ai/repos",
"events_url": "https://api.github.com/users/closedloop-ai/events{/privacy}",
"received_events_url": "https://api.github.com/users/closedloop-ai/received_events",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/closedloop-ai/cv19index",
"description": "COVID-19 Vulnerability Index",
"fork": false,
"url": "https://api.github.com/repos/closedloop-ai/cv19index",
"forks_url": "https://api.github.com/repos/closedloop-ai/cv19index/forks",
"keys_url": "https://api.github.com/repos/closedloop-ai/cv19index/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/closedloop-ai/cv19index/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/closedloop-ai/cv19index/teams",
"hooks_url": "https://api.github.com/repos/closedloop-ai/cv19index/hooks",
"issue_events_url": "https://api.github.com/repos/closedloop-ai/cv19index/issues/events{/number}",
"events_url": "https://api.github.com/repos/closedloop-ai/cv19index/events",
"assignees_url": "https://api.github.com/repos/closedloop-ai/cv19index/assignees{/user}",
"branches_url": "https://api.github.com/repos/closedloop-ai/cv19index/branches{/branch}",
"tags_url": "https://api.github.com/repos/closedloop-ai/cv19index/tags",
"blobs_url": "https://api.github.com/repos/closedloop-ai/cv19index/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/closedloop-ai/cv19index/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/closedloop-ai/cv19index/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/closedloop-ai/cv19index/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/closedloop-ai/cv19index/statuses/{sha}",
"languages_url": "https://api.github.com/repos/closedloop-ai/cv19index/languages",
"stargazers_url": "https://api.github.com/repos/closedloop-ai/cv19index/stargazers",
"contributors_url": "https://api.github.com/repos/closedloop-ai/cv19index/contributors",
"subscribers_url": "https://api.github.com/repos/closedloop-ai/cv19index/subscribers",
"subscription_url": "https://api.github.com/repos/closedloop-ai/cv19index/subscription",
"commits_url": "https://api.github.com/repos/closedloop-ai/cv19index/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/closedloop-ai/cv19index/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/closedloop-ai/cv19index/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/closedloop-ai/cv19index/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/closedloop-ai/cv19index/contents/{+path}",
"compare_url": "https://api.github.com/repos/closedloop-ai/cv19index/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/closedloop-ai/cv19index/merges",
"archive_url": "https://api.github.com/repos/closedloop-ai/cv19index/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/closedloop-ai/cv19index/downloads",
"issues_url": "https://api.github.com/repos/closedloop-ai/cv19index/issues{/number}",
"pulls_url": "https://api.github.com/repos/closedloop-ai/cv19index/pulls{/number}",
"milestones_url": "https://api.github.com/repos/closedloop-ai/cv19index/milestones{/number}",
"notifications_url": "https://api.github.com/repos/closedloop-ai/cv19index/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/closedloop-ai/cv19index/labels{/name}",
"releases_url": "https://api.github.com/repos/closedloop-ai/cv19index/releases{/id}",
"deployments_url": "https://api.github.com/repos/closedloop-ai/cv19index/deployments",
"created_at": "2020-03-14T14:15:02Z",
"updated_at": "2020-03-22T00:13:14Z",
"pushed_at": "2020-03-20T18:04:11Z",
"git_url": "git://github.com/closedloop-ai/cv19index.git",
"ssh_url": "git@github.com:closedloop-ai/cv19index.git",
"clone_url": "https://github.com/closedloop-ai/cv19index.git",
"svn_url": "https://github.com/closedloop-ai/cv19index",
"homepage": "https://cv19index.com",
"size": 3160,
"stargazers_count": 33,
"watchers_count": 33,
"language": "Python",
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": false,
"forks_count": 12,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 3,
"license": {
"key": "other",
"name": "Other",
"spdx_id": "NOASSERTION",
"url": null,
"node_id": "MDc6TGljZW5zZTA="
},
"forks": 12,
"open_issues": 3,
"watchers": 33,
"default_branch": "master"
}
]
The following snippet shows request and the corresponding response for repositories content (partially truncated).
curl https://api.github.com/repos/flutter/flutter/contents
[
...,
{
"name": "AUTHORS",
"path": "AUTHORS",
"sha": "aa9535c024323cdbf65cd43a3ec45dd0504337a8",
"size": 2029,
"url": "https://api.github.com/repos/flutter/flutter/contents/AUTHORS?ref=master",
"html_url": "https://github.com/flutter/flutter/blob/master/AUTHORS",
"git_url": "https://api.github.com/repos/flutter/flutter/git/blobs/aa9535c024323cdbf65cd43a3ec45dd0504337a8",
"download_url": "https://raw.githubusercontent.com/flutter/flutter/master/AUTHORS",
"type": "file",
"_links": {
"self": "https://api.github.com/repos/flutter/flutter/contents/AUTHORS?ref=master",
"git": "https://api.github.com/repos/flutter/flutter/git/blobs/aa9535c024323cdbf65cd43a3ec45dd0504337a8",
"html": "https://github.com/flutter/flutter/blob/master/AUTHORS"
}
},
...,
{
"name": "README.md",
"path": "README.md",
"sha": "23f7be70124e62518fa5d3ebaeaf81fd16d08e04",
"size": 4597,
"url": "https://api.github.com/repos/flutter/flutter/contents/README.md?ref=master",
"html_url": "https://github.com/flutter/flutter/blob/master/README.md",
"git_url": "https://api.github.com/repos/flutter/flutter/git/blobs/23f7be70124e62518fa5d3ebaeaf81fd16d08e04",
"download_url": "https://raw.githubusercontent.com/flutter/flutter/master/README.md",
"type": "file",
"_links": {
"self": "https://api.github.com/repos/flutter/flutter/contents/README.md?ref=master",
"git": "https://api.github.com/repos/flutter/flutter/git/blobs/23f7be70124e62518fa5d3ebaeaf81fd16d08e04",
"html": "https://github.com/flutter/flutter/blob/master/README.md"
}
},
...,
{
"name": "examples",
"path": "examples",
"sha": "c2cbfa5dc7c98c4f5684e9250aaad75401d95083",
"size": 0,
"url": "https://api.github.com/repos/flutter/flutter/contents/examples?ref=master",
"html_url": "https://github.com/flutter/flutter/tree/master/examples",
"git_url": "https://api.github.com/repos/flutter/flutter/git/trees/c2cbfa5dc7c98c4f5684e9250aaad75401d95083",
"download_url": null,
"type": "dir",
"_links": {
"self": "https://api.github.com/repos/flutter/flutter/contents/examples?ref=master",
"git": "https://api.github.com/repos/flutter/flutter/git/trees/c2cbfa5dc7c98c4f5684e9250aaad75401d95083",
"html": "https://github.com/flutter/flutter/tree/master/examples"
}
},
...
]