API to check if a PR is approved by a reviewer #24346
-
Hi, How do I check if a PR has been approved ? pr=repo.get_pull(1602)
I don’t see an ‘approved’ attribute. How do I check if a PR is approved? Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
Hey there @kalyan-nidumolu 👋 Indeed, there is a Pulls - GitHub DocsSyntax is:
…and note that in the default response, we have:
Let us know how you go! |
Beta Was this translation helpful? Give feedback.
-
nethgato:
Hi Nethgato, Thanks for the response. What do you mean by “default response” ? when I look at: I only see an Array of reviews. For for each review, I see a state. If there is no approval, the state is “COMMENTED”. If the review has an approval, its state is “APPROVED”. So I used: def is_pr_approved(pr): Instead of iterating reviews like this - I was hoping to see if the top level PR object has “approved” flag or something. But yeah… the current solution also works works for me. |
Beta Was this translation helpful? Give feedback.
-
Hey @kalyan-nidumolu The default response is simply what we display in our documentation that exposes the For the code you’re using, I feel less comfortable commenting and suggesting any changes as solving for your use case is not explicitly something that GitHub staff can assist with. I would say if you’re hoping for coding assistance, to post in our Software Development board. But for assistance with our APIs themselves, that’s what I’m kicking around this board for =) |
Beta Was this translation helpful? Give feedback.
-
Hi @nethgato, The code that I wrote was just for an example - to indicate that I currently don’t see that attribute in the response from https://api.github.com/repos/owner/repo/pulls/pr-num/reviews The response is just a List of reviews. I don’t see any default attributes other than that. Thanks, |
Beta Was this translation helpful? Give feedback.
-
Thanks for further explaining @kalyan-nidumolu 🙇 Do you happen to have an example PR in a public repository that you could share? |
Beta Was this translation helpful? Give feedback.
Hey there @kalyan-nidumolu 👋
Indeed, there is a
state
value returned from this endpoint:docs.github.com
Pulls - GitHub Docs
Syntax is:
…and note that in the default response, we have:
Let us know how you go!