How to retrieve the list of all GitHub repositories of a person?

后端 未结 15 1100
一个人的身影
一个人的身影 2020-12-02 05:43

We are working on a project where we need to display all the projects of a person in his repository on GitHub account.

Can anyone suggest, how can I display the na

相关标签:
15条回答
  • 2020-12-02 06:22

    The NPM module repos grabs the JSON for all public repos for some user or group. You can run this directly from npx so you don't need to install anything just pick an org or user ("W3C" here):

    $ npx repos W3C W3Crepos.json
    

    This will create a file called W3Crepos.json. Grep is good enough to e.g. fetch the list of repos:

    $ grep full_name W3Crepos.json
    

    pros:

    • Works with more than 100 repos (many answers to this question don't).
    • Not much to type.

    cons:

    • Requires npx (or npm if you want to install it for real).
    0 讨论(0)
  • 2020-12-02 06:22

    If looking for repos of an organisation-

    api.github.com/orgs/$NAMEOFORG/repos

    Example:

    curl https://api.github.com/orgs/arduino-libraries/repos
    

    Also you can add the per_page parameter to get all names just in case there is a pagination problem-

    curl https://api.github.com/orgs/arduino-libraries/repos?per_page=100
    
    0 讨论(0)
  • 2020-12-02 06:27

    There's now an option to use the awesome GraphQL API Explorer.

    I wanted a list of all my org's active repos with their respective languages. This query does just that:

    {
      organization(login: "ORG_NAME") {
        repositories(isFork: false, first: 100, orderBy: {field: UPDATED_AT, direction: DESC}) {
          pageInfo {
            endCursor
          }
          nodes {
            name
            updatedAt
            languages(first: 5, orderBy: {field: SIZE, direction: DESC}) {
              nodes {
                name
              }
            }
            primaryLanguage {
              name
            }
          }
        }
      }
    }
    
    
    0 讨论(0)
提交回复
热议问题