7

I can see all events for a particular user, for example here are mine:

https://api.github.com/users/arasbm/events

But I am only interested in events of a particular type:

"type": "PushEvent",

How can I get this data without having to process the list of all events (which can be slow). I am trying to do this because I want to get a list of all my PRs that have been merged. If you can give me the curl command that would be awesome. I can not find this anywhere in the github api docs.

Aras
  • 5,878
  • 9
  • 49
  • 76

2 Answers2

3

As confirmed in "How do I get notifications for commits to the framework?", you would have to filter the JSON /users/username/events response.

$.each(data.data, function(key, val) {
  if (val.type == "PushEvent") {
    $.each(val.payload.commits, function(key2, val2) {
      list.append('<li id="' + val2.sha + '"><a href="https://github.com/UnionOfRAD/lithium/commit/' + val2.sha + '">' + val2.message + '</a> [' + val.actor.login + ' @ ' + val.created_at + ']</li>');
    });
  }
});

Or:

You can monitor the commit RSS feed (as in "Setting up an Github Commit RSS feed":

https://github.com/user/repo/commits/master.atom
# more general url:
https://github.com/user/repo/commits/branch_name.atom?login=login&token=token

But that would be for one repo of one user though, not for all the user repos.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    thanks! the first solution will work, I am a bit concerned about its performance, but looks like I have no other options – Aras Sep 11 '13 at 07:28
0

Take a look at this python script: https://github.com/jimzucker/githubutils/blob/master/githubreflog.py

I created it to pull events and make them readable, you can pipe it in to grep 'PushEvent' or you can modify it to throw away events other that PushEvent by modifying this line, to only contain the events you are interested in.

HANDLEDEVENTS=["CreateEvent","DeleteEvent","PushEvent","CommitCommentEvent"]

Jim Zucker
  • 850
  • 9
  • 10