最近发现通过 GitHub API 可以获取到很多有用的数据,它返回一个 json 格式数据,可以后期解析得到需要的内容。

主链接:https://api.github.com/

返回内容如下:

{
  "current_user_url": "https://api.github.com/user",
  "current_user_authorizations_html_url": "https://github.com/settings/connections/applications{/client_id}",
  "authorizations_url": "https://api.github.com/authorizations",
  "code_search_url": "https://api.github.com/search/code?q={query}{&page,per_page,sort,order}",
  "commit_search_url": "https://api.github.com/search/commits?q={query}{&page,per_page,sort,order}",
  "emails_url": "https://api.github.com/user/emails",
  "emojis_url": "https://api.github.com/emojis",
  "events_url": "https://api.github.com/events",
  "feeds_url": "https://api.github.com/feeds",
  "followers_url": "https://api.github.com/user/followers",
  "following_url": "https://api.github.com/user/following{/target}",
  "gists_url": "https://api.github.com/gists{/gist_id}",
  "hub_url": "https://api.github.com/hub",
  "issue_search_url": "https://api.github.com/search/issues?q={query}{&page,per_page,sort,order}",
  "issues_url": "https://api.github.com/issues",
  "keys_url": "https://api.github.com/user/keys",
  "label_search_url": "https://api.github.com/search/labels?q={query}&repository_id={repository_id}{&page,per_page}",
  "notifications_url": "https://api.github.com/notifications",
  "organization_url": "https://api.github.com/orgs/{org}",
  "organization_repositories_url": "https://api.github.com/orgs/{org}/repos{?type,page,per_page,sort}",
  "organization_teams_url": "https://api.github.com/orgs/{org}/teams",
  "public_gists_url": "https://api.github.com/gists/public",
  "rate_limit_url": "https://api.github.com/rate_limit",
  "repository_url": "https://api.github.com/repos/{owner}/{repo}",
  "repository_search_url": "https://api.github.com/search/repositories?q={query}{&page,per_page,sort,order}",
  "current_user_repositories_url": "https://api.github.com/user/repos{?type,page,per_page,sort}",
  "starred_url": "https://api.github.com/user/starred{/owner}{/repo}",
  "starred_gists_url": "https://api.github.com/gists/starred",
  "user_url": "https://api.github.com/users/{user}",
  "user_organizations_url": "https://api.github.com/user/orgs",
  "user_repositories_url": "https://api.github.com/users/{user}/repos{?type,page,per_page,sort}",
  "user_search_url": "https://api.github.com/search/users?q={query}{&page,per_page,sort,order}"
}

可以通过它里面给的使用方法来获取到相应的内容,例如可以通过:https://api.github.com/users/{user} 获取到某个用户相关数据,如下是我的个人相关数据:

{
  "login": "nie11kun",
  "id": 11830603,
  "node_id": "MDQ6VXNlcjExODMwNjAz",
  "avatar_url": "https://avatars.githubusercontent.com/u/11830603?v=4",
  "gravatar_id": "",
  "url": "https://api.github.com/users/nie11kun",
  "html_url": "https://github.com/nie11kun",
  "followers_url": "https://api.github.com/users/nie11kun/followers",
  "following_url": "https://api.github.com/users/nie11kun/following{/other_user}",
  "gists_url": "https://api.github.com/users/nie11kun/gists{/gist_id}",
  "starred_url": "https://api.github.com/users/nie11kun/starred{/owner}{/repo}",
  "subscriptions_url": "https://api.github.com/users/nie11kun/subscriptions",
  "organizations_url": "https://api.github.com/users/nie11kun/orgs",
  "repos_url": "https://api.github.com/users/nie11kun/repos",
  "events_url": "https://api.github.com/users/nie11kun/events{/privacy}",
  "received_events_url": "https://api.github.com/users/nie11kun/received_events",
  "type": "User",
  "site_admin": false,
  "name": "Marco Nie",
  "company": "HJMT",
  "blog": "https://niekun.net",
  "location": "China",
  "email": null,
  "hireable": null,
  "bio": "You are the company you keep.",
  "twitter_username": null,
  "public_repos": 88,
  "public_gists": 2,
  "followers": 4,
  "following": 15,
  "created_at": "2015-04-07T06:53:16Z",
  "updated_at": "2021-03-15T08:45:12Z"
}

更多使用方法可以自己研究下。

标签: none

添加新评论