闲来无事,使用github开放API打造一个属于自己的个性化github客户端,使用了部分API,在此进行一番归纳
获取用户基本信息
request:
fetch("https://api.github.com/users/lzq920").then(res=>res.json()).then(res=>console.log(res)).catch(err=>console.log(err));
responses:
{"login": "lzq920","id": 37999725,"node_id": "MDQ6VXNlcjM3OTk5NzI1","avatar_url": "https://avatars0.githubusercontent.com/u/37999725?v=4","gravatar_id": "","url": "https://api.github.com/users/lzq920","html_url": "https://github.com/lzq920","followers_url": "https://api.github.com/users/lzq920/followers","following_url": "https://api.github.com/users/lzq920/following{/other_user}","gists_url": "https://api.github.com/users/lzq920/gists{/gist_id}","starred_url": "https://api.github.com/users/lzq920/starred{/owner}{/repo}","subscriptions_url": "https://api.github.com/users/lzq920/subscriptions","organizations_url": "https://api.github.com/users/lzq920/orgs","repos_url": "https://api.github.com/users/lzq920/repos","events_url": "https://api.github.com/users/lzq920/events{/privacy}","received_events_url": "https://api.github.com/users/lzq920/received_events","type": "User","site_admin": false,"name": "朝闻道夕死可矣","company": "peach","blog": "lzq920.top","location": "中国四川成都","email": null,"hireable": null,"bio": "hello google!","public_repos": 8,"public_gists": 0,"followers": 0,"following": 11,"created_at": "2018-04-02T08:38:21Z","updated_at": "2018-11-20T08:41:17Z"}
获取用户的关注者
request:
fetch("https://api.github.com/users/lzq920/followers").then(res=>res.json()).then(res=>console.log(res)).catch(err=>console.log(err));
response:
[{"login": "mattn","id": 10111,"node_id": "MDQ6VXNlcjEwMTEx","avatar_url": "https://avatars0.githubusercontent.com/u/10111?v=4","gravatar_id": "","url": "https://api.github.com/users/mattn","html_url": "https://github.com/mattn","followers_url": "https://api.github.com/users/mattn/followers","following_url": "https://api.github.com/users/mattn/following{/other_user}","gists_url": "https://api.github.com/users/mattn/gists{/gist_id}","starred_url": "https://api.github.com/users/mattn/starred{/owner}{/repo}","subscriptions_url": "https://api.github.com/users/mattn/subscriptions","organizations_url": "https://api.github.com/users/mattn/orgs","repos_url": "https://api.github.com/users/mattn/repos","events_url": "https://api.github.com/users/mattn/events{/privacy}","received_events_url": "https://api.github.com/users/mattn/received_events","type": "User","site_admin": false},{"login": "fordream","id": 3693121,"node_id": "MDQ6VXNlcjM2OTMxMjE=","avatar_url": "https://avatars2.githubusercontent.com/u/3693121?v=4","gravatar_id": "","url": "https://api.github.com/users/fordream","html_url": "https://github.com/fordream","followers_url": "https://api.github.com/users/fordream/followers","following_url": "https://api.github.com/users/fordream/following{/other_user}","gists_url": "https://api.github.com/users/fordream/gists{/gist_id}","starred_url": "https://api.github.com/users/fordream/starred{/owner}{/repo}","subscriptions_url": "https://api.github.com/users/fordream/subscriptions","organizations_url": "https://api.github.com/users/fordream/orgs","repos_url": "https://api.github.com/users/fordream/repos","events_url": "https://api.github.com/users/fordream/events{/privacy}","received_events_url": "https://api.github.com/users/fordream/received_events","type": "User","site_admin": false}]
获取用户关注列表
request:
fetch("https://api.github.com/users/lzq920/following").then(res=>res.json()).then(res=>console.log(res)).catch(err=>console.log(err));
response:
[{"login": "fengmk2","id": 156269,"node_id": "MDQ6VXNlcjE1NjI2OQ==","avatar_url": "https://avatars0.githubusercontent.com/u/156269?v=4","gravatar_id": "","url": "https://api.github.com/users/fengmk2","html_url": "https://github.com/fengmk2","followers_url": "https://api.github.com/users/fengmk2/followers","following_url": "https://api.github.com/users/fengmk2/following{/other_user}","gists_url": "https://api.github.com/users/fengmk2/gists{/gist_id}","starred_url": "https://api.github.com/users/fengmk2/starred{/owner}{/repo}","subscriptions_url": "https://api.github.com/users/fengmk2/subscriptions","organizations_url": "https://api.github.com/users/fengmk2/orgs","repos_url": "https://api.github.com/users/fengmk2/repos","events_url": "https://api.github.com/users/fengmk2/events{/privacy}","received_events_url": "https://api.github.com/users/fengmk2/received_events","type": "User","site_admin": false},{"login": "atian25","id": 227713,"node_id": "MDQ6VXNlcjIyNzcxMw==","avatar_url": "https://avatars2.githubusercontent.com/u/227713?v=4","gravatar_id": "","url": "https://api.github.com/users/atian25","html_url": "https://github.com/atian25","followers_url": "https://api.github.com/users/atian25/followers","following_url": "https://api.github.com/users/atian25/following{/other_user}","gists_url": "https://api.github.com/users/atian25/gists{/gist_id}","starred_url": "https://api.github.com/users/atian25/starred{/owner}{/repo}","subscriptions_url": "https://api.github.com/users/atian25/subscriptions","organizations_url": "https://api.github.com/users/atian25/orgs","repos_url": "https://api.github.com/users/atian25/repos","events_url": "https://api.github.com/users/atian25/events{/privacy}","received_events_url": "https://api.github.com/users/atian25/received_events","type": "User","site_admin": false},{"login": "soimort","id": 342945,"node_id": "MDQ6VXNlcjM0Mjk0NQ==","avatar_url": "https://avatars0.githubusercontent.com/u/342945?v=4","gravatar_id": "","url": "https://api.github.com/users/soimort","html_url": "https://github.com/soimort","followers_url": "https://api.github.com/users/soimort/followers","following_url": "https://api.github.com/users/soimort/following{/other_user}","gists_url": "https://api.github.com/users/soimort/gists{/gist_id}","starred_url": "https://api.github.com/users/soimort/starred{/owner}{/repo}","subscriptions_url": "https://api.github.com/users/soimort/subscriptions","organizations_url": "https://api.github.com/users/soimort/orgs","repos_url": "https://api.github.com/users/soimort/repos","events_url": "https://api.github.com/users/soimort/events{/privacy}","received_events_url": "https://api.github.com/users/soimort/received_events","type": "User","site_admin": false}]
获取用户项目列表
request:
fetch("https://api.github.com/users/lzq920/repos").then(res=>res.json()).then(res=>console.log(res)).catch(err=>console.log(err));
response:
[{"id": 155649906,"node_id": "MDEwOlJlcG9zaXRvcnkxNTU2NDk5MDY=","name": "devices.css","full_name": "lzq920/devices.css","private": false,"owner": {"login": "lzq920","id": 37999725,"node_id": "MDQ6VXNlcjM3OTk5NzI1","avatar_url": "https://avatars0.githubusercontent.com/u/37999725?v=4","gravatar_id": "","url": "https://api.github.com/users/lzq920","html_url": "https://github.com/lzq920","followers_url": "https://api.github.com/users/lzq920/followers","following_url": "https://api.github.com/users/lzq920/following{/other_user}","gists_url": "https://api.github.com/users/lzq920/gists{/gist_id}","starred_url": "https://api.github.com/users/lzq920/starred{/owner}{/repo}","subscriptions_url": "https://api.github.com/users/lzq920/subscriptions","organizations_url": "https://api.github.com/users/lzq920/orgs","repos_url": "https://api.github.com/users/lzq920/repos","events_url": "https://api.github.com/users/lzq920/events{/privacy}","received_events_url": "https://api.github.com/users/lzq920/received_events","type": "User","site_admin": false},"html_url": "https://github.com/lzq920/devices.css","description": "Devices.css - Modern devices in pure CSS","fork": true,"url": "https://api.github.com/repos/lzq920/devices.css","forks_url": "https://api.github.com/repos/lzq920/devices.css/forks","keys_url": "https://api.github.com/repos/lzq920/devices.css/keys{/key_id}","collaborators_url": "https://api.github.com/repos/lzq920/devices.css/collaborators{/collaborator}","teams_url": "https://api.github.com/repos/lzq920/devices.css/teams","hooks_url": "https://api.github.com/repos/lzq920/devices.css/hooks","issue_events_url": "https://api.github.com/repos/lzq920/devices.css/issues/events{/number}","events_url": "https://api.github.com/repos/lzq920/devices.css/events","assignees_url": "https://api.github.com/repos/lzq920/devices.css/assignees{/user}","branches_url": "https://api.github.com/repos/lzq920/devices.css/branches{/branch}","tags_url": "https://api.github.com/repos/lzq920/devices.css/tags","blobs_url": "https://api.github.com/repos/lzq920/devices.css/git/blobs{/sha}","git_tags_url": "https://api.github.com/repos/lzq920/devices.css/git/tags{/sha}","git_refs_url": "https://api.github.com/repos/lzq920/devices.css/git/refs{/sha}","trees_url": "https://api.github.com/repos/lzq920/devices.css/git/trees{/sha}","statuses_url": "https://api.github.com/repos/lzq920/devices.css/statuses/{sha}","languages_url": "https://api.github.com/repos/lzq920/devices.css/languages","stargazers_url": "https://api.github.com/repos/lzq920/devices.css/stargazers","contributors_url": "https://api.github.com/repos/lzq920/devices.css/contributors","subscribers_url": "https://api.github.com/repos/lzq920/devices.css/subscribers","subscription_url": "https://api.github.com/repos/lzq920/devices.css/subscription","commits_url": "https://api.github.com/repos/lzq920/devices.css/commits{/sha}","git_commits_url": "https://api.github.com/repos/lzq920/devices.css/git/commits{/sha}","comments_url": "https://api.github.com/repos/lzq920/devices.css/comments{/number}","issue_comment_url": "https://api.github.com/repos/lzq920/devices.css/issues/comments{/number}","contents_url": "https://api.github.com/repos/lzq920/devices.css/contents/{+path}","compare_url": "https://api.github.com/repos/lzq920/devices.css/compare/{base}...{head}","merges_url": "https://api.github.com/repos/lzq920/devices.css/merges","archive_url": "https://api.github.com/repos/lzq920/devices.css/{archive_format}{/ref}","downloads_url": "https://api.github.com/repos/lzq920/devices.css/downloads","issues_url": "https://api.github.com/repos/lzq920/devices.css/issues{/number}","pulls_url": "https://api.github.com/repos/lzq920/devices.css/pulls{/number}","milestones_url": "https://api.github.com/repos/lzq920/devices.css/milestones{/number}","notifications_url": "https://api.github.com/repos/lzq920/devices.css/notifications{?since,all,participating}","labels_url": "https://api.github.com/repos/lzq920/devices.css/labels{/name}","releases_url": "https://api.github.com/repos/lzq920/devices.css/releases{/id}","deployments_url": "https://api.github.com/repos/lzq920/devices.css/deployments","created_at": "2018-11-01T02:20:30Z","updated_at": "2018-11-01T02:20:32Z","pushed_at": "2018-06-20T15:15:59Z","git_url": "git://github.com/lzq920/devices.css.git","ssh_url": "git@github.com:lzq920/devices.css.git","clone_url": "https://github.com/lzq920/devices.css.git","svn_url": "https://github.com/lzq920/devices.css","homepage": "https://picturepan2.github.io/devices.css/","size": 6406,"stargazers_count": 0,"watchers_count": 0,"language": "CSS","has_issues": false,"has_projects": true,"has_downloads": true,"has_wiki": false,"has_pages": false,"forks_count": 0,"mirror_url": null,"archived": false,"open_issues_count": 0,"license": {"key": "mit","name": "MIT License","spdx_id": "MIT","url": "https://api.github.com/licenses/mit","node_id": "MDc6TGljZW5zZTEz"},"forks": 0,"open_issues": 0,"watchers": 0,"default_branch": "master"}]
获取用户start事件
request:
fetch("https://api.github.com/users/lzq920/starred").then(res=>res.json()).then(res=>console.log(res)).catch(err=>console.log(err));
response:
[{"id": 148766823,"node_id": "MDEwOlJlcG9zaXRvcnkxNDg3NjY4MjM=","name": "markdown-builder","full_name": "30-seconds/markdown-builder","private": false,"owner": {"login": "30-seconds","id": 43479428,"node_id": "MDEyOk9yZ2FuaXphdGlvbjQzNDc5NDI4","avatar_url": "https://avatars3.githubusercontent.com/u/43479428?v=4","gravatar_id": "","url": "https://api.github.com/users/30-seconds","html_url": "https://github.com/30-seconds","followers_url": "https://api.github.com/users/30-seconds/followers","following_url": "https://api.github.com/users/30-seconds/following{/other_user}","gists_url": "https://api.github.com/users/30-seconds/gists{/gist_id}","starred_url": "https://api.github.com/users/30-seconds/starred{/owner}{/repo}","subscriptions_url": "https://api.github.com/users/30-seconds/subscriptions","organizations_url": "https://api.github.com/users/30-seconds/orgs","repos_url": "https://api.github.com/users/30-seconds/repos","events_url": "https://api.github.com/users/30-seconds/events{/privacy}","received_events_url": "https://api.github.com/users/30-seconds/received_events","type": "Organization","site_admin": false},"html_url": "https://github.com/30-seconds/markdown-builder","description": "1kb Markdown builder for Node.js","fork": false,"url": "https://api.github.com/repos/30-seconds/markdown-builder","forks_url": "https://api.github.com/repos/30-seconds/markdown-builder/forks","keys_url": "https://api.github.com/repos/30-seconds/markdown-builder/keys{/key_id}","collaborators_url": "https://api.github.com/repos/30-seconds/markdown-builder/collaborators{/collaborator}","teams_url": "https://api.github.com/repos/30-seconds/markdown-builder/teams","hooks_url": "https://api.github.com/repos/30-seconds/markdown-builder/hooks","issue_events_url": "https://api.github.com/repos/30-seconds/markdown-builder/issues/events{/number}","events_url": "https://api.github.com/repos/30-seconds/markdown-builder/events","assignees_url": "https://api.github.com/repos/30-seconds/markdown-builder/assignees{/user}","branches_url": "https://api.github.com/repos/30-seconds/markdown-builder/branches{/branch}","tags_url": "https://api.github.com/repos/30-seconds/markdown-builder/tags","blobs_url": "https://api.github.com/repos/30-seconds/markdown-builder/git/blobs{/sha}","git_tags_url": "https://api.github.com/repos/30-seconds/markdown-builder/git/tags{/sha}","git_refs_url": "https://api.github.com/repos/30-seconds/markdown-builder/git/refs{/sha}","trees_url": "https://api.github.com/repos/30-seconds/markdown-builder/git/trees{/sha}","statuses_url": "https://api.github.com/repos/30-seconds/markdown-builder/statuses/{sha}","languages_url": "https://api.github.com/repos/30-seconds/markdown-builder/languages","stargazers_url": "https://api.github.com/repos/30-seconds/markdown-builder/stargazers","contributors_url": "https://api.github.com/repos/30-seconds/markdown-builder/contributors","subscribers_url": "https://api.github.com/repos/30-seconds/markdown-builder/subscribers","subscription_url": "https://api.github.com/repos/30-seconds/markdown-builder/subscription","commits_url": "https://api.github.com/repos/30-seconds/markdown-builder/commits{/sha}","git_commits_url": "https://api.github.com/repos/30-seconds/markdown-builder/git/commits{/sha}","comments_url": "https://api.github.com/repos/30-seconds/markdown-builder/comments{/number}","issue_comment_url": "https://api.github.com/repos/30-seconds/markdown-builder/issues/comments{/number}","contents_url": "https://api.github.com/repos/30-seconds/markdown-builder/contents/{+path}","compare_url": "https://api.github.com/repos/30-seconds/markdown-builder/compare/{base}...{head}","merges_url": "https://api.github.com/repos/30-seconds/markdown-builder/merges","archive_url": "https://api.github.com/repos/30-seconds/markdown-builder/{archive_format}{/ref}","downloads_url": "https://api.github.com/repos/30-seconds/markdown-builder/downloads","issues_url": "https://api.github.com/repos/30-seconds/markdown-builder/issues{/number}","pulls_url": "https://api.github.com/repos/30-seconds/markdown-builder/pulls{/number}","milestones_url": "https://api.github.com/repos/30-seconds/markdown-builder/milestones{/number}","notifications_url": "https://api.github.com/repos/30-seconds/markdown-builder/notifications{?since,all,participating}","labels_url": "https://api.github.com/repos/30-seconds/markdown-builder/labels{/name}","releases_url": "https://api.github.com/repos/30-seconds/markdown-builder/releases{/id}","deployments_url": "https://api.github.com/repos/30-seconds/markdown-builder/deployments","created_at": "2018-09-14T09:28:20Z","updated_at": "2018-12-13T08:59:39Z","pushed_at": "2018-10-08T18:39:44Z","git_url": "git://github.com/30-seconds/markdown-builder.git","ssh_url": "git@github.com:30-seconds/markdown-builder.git","clone_url": "https://github.com/30-seconds/markdown-builder.git","svn_url": "https://github.com/30-seconds/markdown-builder","homepage": "","size": 181,"stargazers_count": 19,"watchers_count": 19,"language": "JavaScript","has_issues": true,"has_projects": true,"has_downloads": true,"has_wiki": true,"has_pages": false,"forks_count": 3,"mirror_url": null,"archived": false,"open_issues_count": 0,"license": null,"forks": 3,"open_issues": 0,"watchers": 19,"default_branch": "master"}]
获取用户正在watch的库
request:
fetch("https://api.github.com/users/lzq920/subscriptions").then(res=>res.json()).then(res=>console.log(res)).catch(err=>console.log(err));
response:
[{"id": 1627744,"node_id": "MDEwOlJlcG9zaXRvcnkxNjI3NzQ0","name": "toolchain4","full_name": "javacom/toolchain4","private": false,"owner": {"login": "javacom","id": 417020,"node_id": "MDQ6VXNlcjQxNzAyMA==","avatar_url": "https://avatars0.githubusercontent.com/u/417020?v=4","gravatar_id": "","url": "https://api.github.com/users/javacom","html_url": "https://github.com/javacom","followers_url": "https://api.github.com/users/javacom/followers","following_url": "https://api.github.com/users/javacom/following{/other_user}","gists_url": "https://api.github.com/users/javacom/gists{/gist_id}","starred_url": "https://api.github.com/users/javacom/starred{/owner}{/repo}","subscriptions_url": "https://api.github.com/users/javacom/subscriptions","organizations_url": "https://api.github.com/users/javacom/orgs","repos_url": "https://api.github.com/users/javacom/repos","events_url": "https://api.github.com/users/javacom/events{/privacy}","received_events_url": "https://api.github.com/users/javacom/received_events","type": "User","site_admin": false},"html_url": "https://github.com/javacom/toolchain4","description": "iPhone toolchain 4 for Ubuntu 10.10","fork": false,"url": "https://api.github.com/repos/javacom/toolchain4","forks_url": "https://api.github.com/repos/javacom/toolchain4/forks","keys_url": "https://api.github.com/repos/javacom/toolchain4/keys{/key_id}","collaborators_url": "https://api.github.com/repos/javacom/toolchain4/collaborators{/collaborator}","teams_url": "https://api.github.com/repos/javacom/toolchain4/teams","hooks_url": "https://api.github.com/repos/javacom/toolchain4/hooks","issue_events_url": "https://api.github.com/repos/javacom/toolchain4/issues/events{/number}","events_url": "https://api.github.com/repos/javacom/toolchain4/events","assignees_url": "https://api.github.com/repos/javacom/toolchain4/assignees{/user}","branches_url": "https://api.github.com/repos/javacom/toolchain4/branches{/branch}","tags_url": "https://api.github.com/repos/javacom/toolchain4/tags","blobs_url": "https://api.github.com/repos/javacom/toolchain4/git/blobs{/sha}","git_tags_url": "https://api.github.com/repos/javacom/toolchain4/git/tags{/sha}","git_refs_url": "https://api.github.com/repos/javacom/toolchain4/git/refs{/sha}","trees_url": "https://api.github.com/repos/javacom/toolchain4/git/trees{/sha}","statuses_url": "https://api.github.com/repos/javacom/toolchain4/statuses/{sha}","languages_url": "https://api.github.com/repos/javacom/toolchain4/languages","stargazers_url": "https://api.github.com/repos/javacom/toolchain4/stargazers","contributors_url": "https://api.github.com/repos/javacom/toolchain4/contributors","subscribers_url": "https://api.github.com/repos/javacom/toolchain4/subscribers","subscription_url": "https://api.github.com/repos/javacom/toolchain4/subscription","commits_url": "https://api.github.com/repos/javacom/toolchain4/commits{/sha}","git_commits_url": "https://api.github.com/repos/javacom/toolchain4/git/commits{/sha}","comments_url": "https://api.github.com/repos/javacom/toolchain4/comments{/number}","issue_comment_url": "https://api.github.com/repos/javacom/toolchain4/issues/comments{/number}","contents_url": "https://api.github.com/repos/javacom/toolchain4/contents/{+path}","compare_url": "https://api.github.com/repos/javacom/toolchain4/compare/{base}...{head}","merges_url": "https://api.github.com/repos/javacom/toolchain4/merges","archive_url": "https://api.github.com/repos/javacom/toolchain4/{archive_format}{/ref}","downloads_url": "https://api.github.com/repos/javacom/toolchain4/downloads","issues_url": "https://api.github.com/repos/javacom/toolchain4/issues{/number}","pulls_url": "https://api.github.com/repos/javacom/toolchain4/pulls{/number}","milestones_url": "https://api.github.com/repos/javacom/toolchain4/milestones{/number}","notifications_url": "https://api.github.com/repos/javacom/toolchain4/notifications{?since,all,participating}","labels_url": "https://api.github.com/repos/javacom/toolchain4/labels{/name}","releases_url": "https://api.github.com/repos/javacom/toolchain4/releases{/id}","deployments_url": "https://api.github.com/repos/javacom/toolchain4/deployments","created_at": "2011-04-17T21:00:02Z","updated_at": "2018-10-08T14:32:04Z","pushed_at": "2012-02-02T03:26:37Z","git_url": "git://github.com/javacom/toolchain4.git","ssh_url": "git@github.com:javacom/toolchain4.git","clone_url": "https://github.com/javacom/toolchain4.git","svn_url": "https://github.com/javacom/toolchain4","homepage": "","size": 7643,"stargazers_count": 96,"watchers_count": 96,"language": "C","has_issues": true,"has_projects": true,"has_downloads": true,"has_wiki": true,"has_pages": false,"forks_count": 33,"mirror_url": null,"archived": false,"open_issues_count": 2,"license": null,"forks": 33,"open_issues": 2,"watchers": 96,"default_branch": "master"}]
