I'd like to fetch the code owners associated with a pull request or at least the repository.
Is this possible through existing APIs or does this feature not exist? My backup plan is to write code owner evaluation logic myself, but that seems like it shouldn't be necessary.
Through the existing API, you can fetch pull request author, repo owner of the source of the pull request, assignees, users that merges the pull request, and get commits with committers and authors. What are you looking for specifically?
While it's not possible to do this with a single API, you can create a script that allows you to crossreference the requested reviewers with the content of the CODEOWNERS file using the Get Contents API endpoint. Since the CODEOWNERS file has a limited number of locations that it can be located, it should be easy to find with a couple of calls.
Hope that helps!
@chdsbd, that's very true. You'd probably have to do some advanced checking of the files in the PR and how they compare to the CODEOWNERS file as well to be sure.