Bootstrap FreeKB - GitHub - Lists Repos using the REST API
GitHub - Lists Repos using the REST API

Updated:   |  GitHub articles

In the following examples, the authentication to GitHub is being done using a token, meaning the authentication is being done using a classic token or a fine grained token. For example, if using a classic Personal Access Token, the token will need the repo permission.

 

Here is an example of how to list the Rulesets using curl.

curl \
--location \
--request GET \
--header "Accept: application/vnd.github+json" \
--header "Authorization: Bearer <your token>" \
--header "X-GitHub-Api-Version: 2022-11-28" \
--url https://api.github.com/orgs/<your organization>/repos

 

For example.

curl \
--location \
--request GET \
--header "Accept: application/vnd.github+json" \
--header "Authorization: Bearer abc123" \
--header "X-GitHub-Api-Version: 2022-11-28" \
--url https://api.github.com/orgs/acme/repos

 

You can specify a specific repo.

curl \
--location \
--request GET \
--header "Accept: application/vnd.github+json" \
--header "Authorization: Bearer <your token>" \
--header "X-GitHub-Api-Version: 2022-11-28" \
--url https://api.github.com/orgs/<your organization>/repos/foo.git

 

Something like this should be returned.

[
  {
    "id": 1256230923,
    "node_id": "abc123",
    "name": "my-repo",
    "full_name": "acme/my-repo",
    "private": true,
    "owner": {
      "login": "acme",
      "id": 1256230923,
      "node_id": "O_kgsdf4Flw",
      "avatar_url": "https://avatars.githubusercontent.com/u/9849856631?v=4",
      "gravatar_id": "",
      "url": "https://api.github.com/users/acme",
      "html_url": "https://github.com/acme",
      "followers_url": "https://api.github.com/users/acme/followers",
      "following_url": "https://api.github.com/users/acme/following{/other_user}",
      "gists_url": "https://api.github.com/users/acme/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/acme/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/acme/subscriptions",
      "organizations_url": "https://api.github.com/users/acme/orgs",
      "repos_url": "https://api.github.com/users/acme/repos",
      "events_url": "https://api.github.com/users/acme/events{/privacy}",
      "received_events_url": "https://api.github.com/users/acme/received_events",
      "type": "Organization",
      "user_view_type": "public",
      "site_admin": false
    },
    "html_url": "https://github.com/acme/my-repo",
    "description": "my repo",
    "fork": false,
    "url": "https://api.github.com/repos/acme/my-repo",
    "forks_url": "https://api.github.com/repos/acme/my-repo/forks",
    "keys_url": "https://api.github.com/repos/acme/my-repo/keys{/key_id}",
    "collaborators_url": "https://api.github.com/repos/acme/my-repo/collaborators{/collaborator}",
    "teams_url": "https://api.github.com/repos/acme/my-repo/teams",
    "hooks_url": "https://api.github.com/repos/acme/my-repo/hooks",
    "issue_events_url": "https://api.github.com/repos/acme/my-repo/issues/events{/number}",
    "events_url": "https://api.github.com/repos/acme/my-repo/events",
    "assignees_url": "https://api.github.com/repos/acme/my-repo/assignees{/user}",
    "branches_url": "https://api.github.com/repos/acme/my-repo/branches{/branch}",
    "tags_url": "https://api.github.com/repos/acme/my-repo/tags",
    "blobs_url": "https://api.github.com/repos/acme/my-repo/git/blobs{/sha}",
    "git_tags_url": "https://api.github.com/repos/acme/my-repo/git/tags{/sha}",
    "git_refs_url": "https://api.github.com/repos/acme/my-repo/git/refs{/sha}",
    "trees_url": "https://api.github.com/repos/acme/my-repo/git/trees{/sha}",
    "statuses_url": "https://api.github.com/repos/acme/my-repo/statuses/{sha}",
    "languages_url": "https://api.github.com/repos/acme/my-repo/languages",
    "stargazers_url": "https://api.github.com/repos/acme/my-repo/stargazers",
    "contributors_url": "https://api.github.com/repos/acme/my-repo/contributors",
    "subscribers_url": "https://api.github.com/repos/acme/my-repo/subscribers",
    "subscription_url": "https://api.github.com/repos/acme/my-repo/subscription",
    "commits_url": "https://api.github.com/repos/acme/my-repo/commits{/sha}",
    "git_commits_url": "https://api.github.com/repos/acme/my-repo/git/commits{/sha}",
    "comments_url": "https://api.github.com/repos/acme/my-repo/comments{/number}",
    "issue_comment_url": "https://api.github.com/repos/acme/my-repo/issues/comments{/number}",
    "contents_url": "https://api.github.com/repos/acme/my-repo/contents/{+path}",
    "compare_url": "https://api.github.com/repos/acme/my-repo/compare/{base}...{head}",
    "merges_url": "https://api.github.com/repos/acme/my-repo/merges",
    "archive_url": "https://api.github.com/repos/acme/my-repo/{archive_format}{/ref}",
    "downloads_url": "https://api.github.com/repos/acme/my-repo/downloads",
    "issues_url": "https://api.github.com/repos/acme/my-repo/issues{/number}",
    "pulls_url": "https://api.github.com/repos/acme/my-repo/pulls{/number}",
    "milestones_url": "https://api.github.com/repos/acme/my-repo/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/acme/my-repo/notifications{?since,all,participating}",
    "labels_url": "https://api.github.com/repos/acme/my-repo/labels{/name}",
    "releases_url": "https://api.github.com/repos/acme/my-repo/releases{/id}",
    "deployments_url": "https://api.github.com/repos/acme/my-repo/deployments",
    "created_at": "2023-07-08T01:54:32Z",
    "updated_at": "2023-07-28T19:17:14Z",
    "pushed_at": "2025-01-06T19:43:20Z",
    "git_url": "git://github.com/acme/my-repo.git",
    "ssh_url": "git@github.com:acme/my-repo.git",
    "clone_url": "https://github.com/acme/my-repo.git",
    "svn_url": "https://github.com/acme/my-repo",
    "homepage": null,
    "size": 6,
    "stargazers_count": 0,
    "watchers_count": 0,
    "language": null,
    "has_issues": true,
    "has_projects": true,
    "has_downloads": false,
    "has_wiki": false,
    "has_pages": false,
    "has_discussions": false,
    "forks_count": 0,
    "mirror_url": null,
    "archived": false,
    "disabled": false,
    "open_issues_count": 1,
    "license": null,
    "allow_forking": false,
    "is_template": false,
    "web_commit_signoff_required": false,
    "topics": [
      "tfc-managed"
    ],
    "visibility": "internal",
    "forks": 0,
    "open_issues": 1,
    "watchers": 0,
    "default_branch": "main",
    "permissions": {
      "admin": false,
      "maintain": false,
      "push": true,
      "triage": true,
      "pull": true
    }
  }

]

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 30957e in the box below so that we can be sure you are a human.