小编5c0*_*0tt的帖子

如何使用jq从github api中提取信息字段

我正在尝试使用其 API 提取有关 github 存储库的一些信息,显然jq是要走的路。我可以使用此命令查看所有可用信息:

curl 'https://api.github.com/repos/tmux-plugins/tpm' | jq
Run Code Online (Sandbox Code Playgroud)

输出:

{
  "id": 19935788,
  "node_id": "MDEwOlJlcG9zaXRvcnkxOTkzNTc4OA==",
  "name": "tpm",
  "full_name": "tmux-plugins/tpm",
  "private": false,
  "owner": {
    "login": "tmux-plugins",
    "id": 8289877,
    "node_id": "MDEyOk9yZ2FuaXphdGlvbjgyODk4Nzc=",
    "avatar_url": "https://avatars.githubusercontent.com/u/8289877?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/tmux-plugins",
    "html_url": "https://github.com/tmux-plugins",
    "followers_url": "https://api.github.com/users/tmux-plugins/followers",
    "following_url": "https://api.github.com/users/tmux-plugins/following{/other_user}",
    "gists_url": "https://api.github.com/users/tmux-plugins/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/tmux-plugins/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/tmux-plugins/subscriptions",
    "organizations_url": "https://api.github.com/users/tmux-plugins/orgs",
    "repos_url": "https://api.github.com/users/tmux-plugins/repos",
    "events_url": "https://api.github.com/users/tmux-plugins/events{/privacy}",
    "received_events_url": "https://api.github.com/users/tmux-plugins/received_events",
    "type": "Organization",
    "site_admin": false
  },
  "html_url": "https://github.com/tmux-plugins/tpm",
  "description": "Tmux Plugin Manager",
  "fork": false,
  "url": "https://api.github.com/repos/tmux-plugins/tpm",
  "forks_url": "https://api.github.com/repos/tmux-plugins/tpm/forks",
  "keys_url": "https://api.github.com/repos/tmux-plugins/tpm/keys{/key_id}",
  "collaborators_url": "https://api.github.com/repos/tmux-plugins/tpm/collaborators{/collaborator}",
  "teams_url": "https://api.github.com/repos/tmux-plugins/tpm/teams", …
Run Code Online (Sandbox Code Playgroud)

shell api curl json jq

2
推荐指数
1
解决办法
304
查看次数

标签 统计

api ×1

curl ×1

jq ×1

json ×1

shell ×1