Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get GitHub API notifications that match the notifications site

I'm trying to get the same information out of GitHub that's shown on the https://github.com/notifications page. Unfortunately, the standard notifications API doesn't really match that view.

If I get the notifications from that API (even with participating=false), I don't see all the items visible on the website. On the other hand, the API seems to be based on the last_read_at idea, and things I've seen on the website don't disappear automatically from the notifications list.

Is there a way (without scraping the website) to obtain the same /notifications view?

like image 984
viraptor Avatar asked Mar 20 '17 11:03

viraptor


People also ask

How do I get notifications from GitHub?

In the left sidebar, under the list of repositories, use the "Manage notifications" drop-down to click Notification settings. On the notifications settings page, choose how you receive notifications when: There are updates in repositories or team discussions you're watching or in a conversation you're participating in.

How do I fetch API in GitHub?

To get the list of random users, you have to make a request to the /user endpoint, and to get the details of a specific user, you make a request to the /user/{username} endpoint. You can try out the following commands quickly in your terminal with curl to see the results.

How do I get GitHub notifications on my desktop?

### Notifications permission If you want to receive desktop notifications, you can enable them on extension options page. You will then be asked for the notifications permission.

How do I send notifications on GitHub?

On GitHub.com, navigate to the main page of the repository. Under your repository name, click Settings. In the "Integrations" section of the sidebar, click Email notifications. Type up to two email addresses, separated by whitespace, where you'd like notifications to be sent.


1 Answers

So GitHub's API supports pagination for requests returning lists, so the API will return default of 30 notifications per page. What I suggest is setting the default size to 100 and then start from page 1 and call the next page till there is no results e.g. :

<https://api.github.com/notifications?page=1&per_page=100>; rel="next"
<https://api.github.com/notifications?page=2&per_page=100>; rel="next"
...and so on till you get an empty list then you stop

The rel="next" is a Link Header which is explained here: https://developer.github.com/v3/#pagination

Hope this helps

like image 166
Chester Cobus Avatar answered Oct 04 '22 06:10

Chester Cobus