In github, when I click on a commit, I can see the pull request that introduced it.

You can see this commit was introduced by PR 15.
How can I get the associated pull request for a particular commit from the Github API?
the #15 indicates the issue/PR number. If you have a commit sha it is possible to find the associated PR# using the GitHub search API (v3).
For example, suppose you have a commit sha - 7dd1bcf5f2f5eeed34cc2ec63053098fba302b6c. To find the PR# from this sha, your query using the GitHub APi can look something like this- https://api.github.com/search/issues?q=sha:7dd1bcf5f2f5eeed34cc2ec63053098fba302b6c. From JSON response, the field 'number' represents the PR# (in this case 16).
Ref. Search Issues
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With