Skip to content

Instantly share code, notes, and snippets.

@KondaReddyR
Created April 7, 2019 15:42
Show Gist options
  • Save KondaReddyR/203e013005fbd9cb43fb5f12dc09c71a to your computer and use it in GitHub Desktop.
Save KondaReddyR/203e013005fbd9cb43fb5f12dc09c71a to your computer and use it in GitHub Desktop.
Github Api V4 Graphql Fetch Orgs
orgs=`curl -H "Authorization: bearer $GH_TOKEN" -X POST -d "  { \"query\": \"query { user(login: "KondaReddyR") { organizations(first: 10) { edges { node {  login} } } } }\"  }  " https://api.github.com/graphql | jq -c  .`


for org in $(echo "${orgs}" | jq -r '.data.user.organizations.edges[] | .node.login '); do
  echo $org
done
@KondaReddyR
Copy link
Author

List of Orgs and Repos

curl -H "Authorization: bearer $GH_TOKEN" -X POST -d " { \"query\": \"query { user(login: "KondaReddyR") { organizations(first: 10) { edges { node { login \n repositories(first: 100) { edges { node { name } } } } } } } }\"  }  " https://api.github.com/graphql | jq '.data.user.organizations.edges[]'| jq '{org: .node.login, repo:.node.repositories.edges[].node.name}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment