GitHub API
Tags: api, github, beginners
Published: 2022-04-18 11:10:56

## Table of Contents
1. [Overview](#overview)
2. [Available Libraries](#available-libraries)
3. [Useful Endpoints](#useful-endpoints)
4. [Project Ideas with GitHub API](#project-ideas)

### Overview

All requests to `https://api.github.com` receive the `v3` version of the REST API. It is encouraged that the v3 version is explicitly requested via the `Accept` header:

```
Accept: application/vnd.github.v3+json
```

#### Authentication
Note: Requests that require authentication will return `404 Not Found` instead of `403 Forbidden`, in some places.

Basic authentication:
```
$ curl -u "username" https://api.github.com
```

[OAuth2](https://docs.github.com/en/apps/building-oauth-apps) token:
```
$ curl -H "Authorization: token OAUTH-TOKEN" https://api.github.com
```

OAuth2 key/secret:
```
$ curl -u my_client_id:my_client_secret 'https://api.github.com/user/repos'
```

### Available Libraries
- [GitHub for Dart](https://github.com/SpinlockLabs/github.dart)
- [GitHub client library for Emacs](https://github.com/sigma/gh.el)
- [Go client library for accessing the GitHub API v3](https://github.com/google/go-github)
- [GitHub API for Java](https://github-api.kohsuke.org/)
- [NodeJS GitHub Library](https://github.com/pksunkara/octonode)
- [Julia interface to GitHub API](https://github.com/JuliaWeb/GitHub.jl)
- [PHP GitHub API](https://github.com/KnpLabs/php-github-api)
- [GitHub bridge for Laravel](https://github.com/GrahamCampbell/Laravel-GitHub)
- [Python library to access GitHub API](https://github.com/PyGithub/PyGithub)
- [GitHub Flask](https://github-flask.readthedocs.io/en/latest/)

### Useful Endpoints
- `GET /events`

Note: public event feeds are delayed by five minutes
![curl events](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ld5vv18wxn2lm855y6a3.png)
 

- `GET /notifications`

List all notifications for the current user, sorted by most recently updated.
![await notifs](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0etb3c9ferglxa22poa5.png)
 

- `POST /repos/{owner}/{repo}/statuses/{sha}`

Note: there is a limit of 1000 statuses per sha and context within a repository.
![post commits](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9tkxv0fjsmzcx8rce4gd.png)
 

- `GET /repos/{owner}/{repo}/languages`

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wpixzagtp42k97e3hte1.png)


- `PUT /repos/{owner}/{repo}/vulnerability-alerts`

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ctzbpgsdx0fb4pgfqlso.png)

### Project Ideas
1. Build a Dynamic Portfolio

I personally have used GitHub API in [my portfolio website](https://tmchuynh.me/). My site automatically displays:

- Each GitHub repository
- The date that each repo was last updated
- Symbols corresponding to the languages used in each repo
- Each repository is also linked back to the respective GitHub repo itself

Check out the article I posted here:
{% embed https://dev.to/tmchuynh/a-personal-website-w-everything-268k %}

2. [Build a GitHub Dashboard](https://www.appsmith.com/blog/build-a-github-dashboard-and-track-any-open-source-project)

You can build a dashboard to track **any** open source project! 

3. [Learn about ghapi](https://github.blog/2020-12-18-learn-about-ghapi-a-new-third-party-python-client-for-the-github-api/)

ghapi is a third-party Python library and CLI client for the GitHub API. ghapi automatically manages required headers, query strings, route parameters, post data, and much more! How interesting!


What are your favorite things to do with GitHub API?

Happy coding!