Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get number of yearly GitHub user contributions

User profiles on GitHub display the number of contributions a user has made in the past year:

I'd like to display this information on my website, preferably without having to introduce any kind of backend. I've looked for it in several places. Nothing is listed in /users/(me)/. Short of scraping the page source, is there a way to retrieve this information? I don't see anything documented...

like image 743
Luke Taylor Avatar asked Dec 22 '25 20:12

Luke Taylor


1 Answers

Have you seen the GithubAPI? Using it, you could run the request from your js file, without implemeting any backend.

For your purpose, I think you could use the following request https://api.github.com/users/yourUserName/events. That gives you as result, a list of events related to youUserName.

e.g

    [
      {
        "id": "xxxxxxx",
        "type": "PushEvent",
        "actor": {.......},
        "repo": {......},
        "payload": {.......},
        "public": true,
        "created_at": "2016-11-17T21:33:15Z"
      },
      .....
    ]

You should go through the list and filter the type = PushEvent and created_at = lastYear.

I hope this can help you!


Update: that service is just giving the results for the last 3 months, so other possibility is to check (users/username/repos) and after that check the commits over them (repos/username/repoName/commits)

like image 119
Alan Avatar answered Dec 24 '25 09:12

Alan