Do github provides any api to get all the codeowners?

I am working on a project and want to know is there any way GitHub provides the API for the code owners.
Pls, let me know, I would be grateful.
Thanks :slight_smile:

Yes! I need this. My org is trying to get a grip on ownership, and I thought the CODEOWNER file is perfect - really put it to use! @nethgato - you had some experience in another thread, mentioning that the graphql library offered some functionality here, but not the API? Is that still the case?

Using ruby…

require 'octokit'

client = Octokit::Client.new
client.contents('dudo/create_kustomized_namespace', path: 'manifest.rb')

I’m thinking you could expose codeowners here? I make heavy use of this visually when looking at a file, so it feels like a reasonably sane place…

Hi, hi @chirag7145 and @dudo :wave:

I believe you’re referring to this thread:

…and this thread might even be merge-able into that existing conversation.

I did a check on our open internal issues and best I can tell, there’s been no traction for REST to include CODEOWNERS specific endpoints.

As mentioned in the thread above, submitting your feedback, here:

https://support.github.com/contact/feedback

…which gets reviewed for consideration by our PM teams.

Though I will say that these two threads here in our Community forum are not the only places this conversation is happening. So it’s definitely sought after functionality!

Thank you for raising the conversation again.

So, that thread was specific to PRs - seems as though checking the reviewers would satisfy that need. I’m hoping to get access to codeowners on a per file basis, ad hoc.

Stupid question… but can I just call graphQL? Do you know the incantation to grab that value?

Oh, and feedback submitted =)

Thanks!

Hey again @dudo

Not at all a stupid question! Though, not one I have an answer to, unfortunately =(

Since you’re looking not at PR data as it relates to codeowners, but hoping to identify on a per-file basis across a repo, I think there is a significant functionality gap.

Your feedback submission is greatly appreciated!

Edit: actually, did I misunderstand? Were you hoping for a GraphQL example for pulling the data we do have available for codeowners in PRs?

Seems as though the logic is already figured out to make this info easily accessible… would LOVE a new endpoint

GET /repos/{owner}/{repo}/codeowners/{path}

that returned something like

[
  {
    "id": 1,
    "node_id": "MDQ6VGVhbTE=",
    "url": "https://api.github.com/teams/1",
    "html_url": "https://github.com/orgs/github/teams/justice-league",
    "name": "Justice League",
    "slug": "justice-league",
    "type": "Team",
    "description": "from CODEOWNERS line 1",
  },
  {
    "id": 1,
    "node_id": "MDQ6VXNlcjE=",
    "url": "https://api.github.com/users/octocat",
    "html_url": "https://github.com/octocat",
    "name": "Octocat",
    "slug": "octocat",
    "type": "User",
    "description": "from CODEOWNERS line 1",
  }
]
2 Likes