4
votes

I use the Github API to get my open pull requests. Now I also want to add the labels attached to my view. How can I get them?

Thats the URL I use got GET the data so far:

url = 'https://api.github.com/repos/' + name_repository + '/pulls?access_token=' + TOKEN;

1

1 Answers

7
votes

To fetch the labels for a pull request, you need to fetch the associated issue (pull requests are basically issues with code attached). So, if you have pull request 324 in repository foo/bar, then fetch this issue to get the labels for that pull request:

https://api.github.com/repos/foo/bar/issues/324

See https://developer.github.com/v3/pulls/#labels-assignees-and-milestones

The same thing is true if you want to fetch a list of pull request -- you need to fetch the list of issues and use the labels from that.