If you look at: http://developer.github.com/v3/pulls/ it shows you how to get pull requests for a given repository.
How do we get "my pull requests" from the GitHub API similar to the data displayed on the GitHub dashboard?
I asked Github directly. A rep told me to use the search endpoint. Search for issues owned by you that are open and of type pr.
https://api.github.com/search/issues?q=state%3Aopen+author%3Adavidxia+type%3Apr
If you're using a python client lib like Pygithub you can do
issues = gh.search_issues('', state='open', author='davidxia', type='pr')
You can also use GraphQL API v4 to get all your pull requests :
{
user(login: "bertrandmartel") {
pullRequests(first: 100, states: OPEN) {
totalCount
nodes {
createdAt
number
title
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
Try it in the explorer
or using viewer :
{
viewer {
pullRequests(first: 100, states: OPEN) {
totalCount
nodes {
createdAt
number
title
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
First you have to realize that you must authenticate using either Basic Authentication or a token. Next you have to realize that there is no simple way to do this so you will have to be clever.
To be specific, if you probe https://api.github.com/issues, you'll notice that the issues there have a hash called pull_request which should have 3 URLs: html, diff, and patch. All three will be non-null if the issue is also a Pull Request. (Pro-tip: They're the same thing as far as GitHub is concerned…sort of.)
If you iterate over your issues and filter for ones where those attributes are not null, then you'll have your pull requests.
Related
I'm using Contentful API to get the details of all the entries in a Space, is there a way to fetch the name of 'linked entry/entries' to a particular entry? In this case, i'm fetching all the entries with the content_type = HorizontalImageCard and then that each entry has link to other entries(could be a link to an Asset or link to different Contentul entry), and i would like to get the name of such entries, attaching the screenshot of what i'm looking for, in the screenshot there's a Linked Entry called 'Jennifer Test', how do i fetch that name?
let fetchRes = fetch("https://preview.contentful.com/spaces/{space_id}/environments/ca/entries/{entry_id}?access_token=vOKxCDyhU8gLUsU4FR5tgdwQVe3arwfJzFTCloi2sjM&content_type=HorizontalImageCard");
Did you try with the GraphQL API? I didn't get a chance to try it out with the REST API, but I was able to get the result with the GraphQL API. Here's an example query:
{
userCollection(preview:true) {
items {
name
linkedFrom {
blogArticleCollection {
items {
title
}
}
}
}
}
}
The User content type is linked in the Blog Article content type. This method allows me to list all those references. Hope this helps :)
I want to use the gitlab API for issues with the soring manual like on the issue list UI on gitlab.com.
I have used the attribute / parameter
API: Order by relative_position
I tryied that {{base_url}}/groups/{{my_group_id}}/issues?order_by=relative_position
base_url: https://gitlab.com/api/v4
my_group_id: a group id (number) from my project / company
The order_by=relative_position parameter does not produce the same order as “manual” ordering in the UI, more or less the parameter seems to be ignored totally. Other parameters I have tried worked.
I found that here, from ~ 2019, on GitLab Forum. Also there is no answer ...
I also found API attribute/call to get Issues by sort order in Boards
If the REST-API do not work, I am also happy about an solution / idea with GRAPHQL of gitlab.
I was NOT able to fix it with REST API but with GRAPH QL.
The command below uses {MY_COMPANY} and {MY_GROUP}, just replace it with your group.
{
group(fullPath: "{MY_COMPANY}/{MY_GROUP}") {
issues(sort: RELATIVE_POSITION_ASC, state: opened) {
nodes {
title
id
iid
weight
labels { nodes {title} }
}
}
}
}
Here an example for the gitlab project, not group
{
project(fullPath: "gitlab-org/gitlab") {
issues(sort: RELATIVE_POSITION_ASC, state: opened) {
nodes {
title
id
iid
weight
labels { nodes {title} }
}
}
}
}
Gitlab GraphQL Docu
Gitlab GraphQL Explorer
I'm implementing an API integration for DocuSign, and I'm currently hitting the following endpoint: /v2/organizations/{organizationId}/users
The documentaton for this: https://developers.docusign.com/docs/admin-api/reference/users/users/getusers/#response200_docusign.api.organizations.web.models.restapi.v2.response.organizationuserresponse
The documentation is showing a response field, user_status. However, when I call the API, I get a response as follows:
{
"users":[
{
"id":"xxx-xxx-xxx-xxx-xxx",
"user_name":"Xxxx",
"first_name":"",
"last_name":"Xxxx",
"membership_status":"active",
"email":"xxxx#gmail.com",
"membership_created_on":"2021-07-30T02:24:20.243",
"membership_id":"xxxx-xxxx-xxxx-xxxx-xxxx"
},
{
"id":"yyy-yyy-yyy-yyy-yyy",
"user_name":"Yyyyy",
"first_name":"Yyyyy",
"last_name":"2",
"membership_status":"active",
"email":"yyyyyyy#yyy.yyy",
"membership_created_on":"2021-07-30T02:26:59.313",
"membership_id":"yyy-yyy-yyy-yyy-yyy"
},
{
"id":"zzz-zzz-zzz-zzz-zzz",
"user_name":"Zzzzz",
"first_name":"Zzzz",
"last_name":"Zzzz",
"membership_status":"active",
"email":"zzz#zzz-zzz.net",
"membership_created_on":"2021-07-15T04:05:18.803",
"membership_id":"zzz-zzz-zzz-zzz-zzz"
}
],
"paging":{
"result_set_size":3,
"result_set_start_position":0,
"result_set_end_position":2,
"total_set_size":3
}
}
As you can see, we have no user_status. Do we need to send any request parameters, to expand the response, or has this field been removed from the API response without being updated on the API documentation?
Or, could I assume that the user is active, if it appears in the API response, with a membership_status of active?
Thank you very much!
membership_status is probably what you're looking for.
there's no such thing as user_status because a user can be a member of multiple accounts and each membership can have a different status.
Here is a useful diagram:
I am trying to get the comments on a pull request using GitHub API, for example:
https://api.github.com/repos/mapra99/members-only/pulls/1/comments
But it returns an empty array.
The same if I try to use the review comments endpoint:
https://api.github.com/repos/mapra99/members-only/issues/1/comments
Although there is a comment on that pull request:
https://github.com/mapra99/members-only/pull/1
How can I get the comment that is on that pull request using GitHub API? Why is it not possible to get if from any of those endpoints?
In fact, this is not a comment but a review :
Pull Request Reviews are groups of Pull Request Review Comments on the
Pull Request, grouped together with a state and optional body comment.
You can get the reviews using :
https://api.github.com/repos/mapra99/members-only/pulls/1/reviews
Or using GraphQL v4 to get reviews & comments :
{
repository(owner: "mapra99", name: "members-only") {
pullRequest(number: 1) {
reviews(first: 100) {
nodes {
body
}
}
comments(first: 100) {
nodes {
body
}
}
}
}
}
I'm trying to get the GitHub user picture (avatar) from users of GitHub.
I've found these API:
https://avatars.githubusercontent.com/<username>
https://avatars.githubusercontent.com/u/<userid>
But I can't find a way to get the avatar from the user email or the user display name.
I can't find documentation about that.
Is there some similar URL API to get what I'm looking for?
You can append .png to the URL for the User's profile to get redirected to their avatar. You can add the query param size to specify a size smaller than the default of 460px wide (i.e. it won't allow larger than 460).
Examples:
https://github.com/twbs.png
https://github.com/npm.png?size=200
https://github.com/github.png?size=40
https://developer.github.com/v3/users/#get-a-single-user
Use the /users/:user endpoint. Should be under avatar_url in the returned json.
For example, my avatar_url can be found by hitting this url.
Edit
There is another way I can think of that is kind of roundabout. Since GitHub uses Gravatar, if you know the email associated with the account, do an md5 hash of the lowercase, stripped email address and construct a url like http://www.gravatar.com/avatar/[md5_here].
This is an old post but nobody has proposed Github Search Users API with scope field :
using in:email : https://api.github.com/search/users?q=bmartel+in%3Aemail
using in:username : https://api.github.com/search/users?q=Bertrand+Martel+in%3Ausername
Or using new Graphql API v4 :
{
search(type: USER, query: "in:email bmartel", first: 1) {
userCount
edges {
node {
... on User {
avatarUrl
}
}
}
}
}
Using GraphQL API v4, this will work too
Query (for username)-
{
user(login: "username") {
avatarUrl
}
}
Response -
{
"data": {
"user": {
"avatarUrl": "https://avatars1.githubusercontent.com/u/..."
}
}
}
GitHub avatar can be accessed through https://avatars.githubusercontent.com/u/YOUR_USER_ID
Optionally, you can modify the size at the end like so https://avatars.githubusercontent.com/u/YOUR_USER_ID?s=460