GitHub API

Tina Huynh
3 min readMay 3, 2022

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 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

Useful Endpoints

  • GET /events

Note: public event feeds are delayed by five minutes

  • GET /notifications

List all notifications for the current user, sorted by most recently updated.

  • POST /repos/{owner}/{repo}/statuses/{sha}

Note: there is a limit of 1000 statuses per sha and context within a repository.

  • GET /repos/{owner}/{repo}/languages
  • PUT /repos/{owner}/{repo}/vulnerability-alerts

Project Ideas

Idea #1: Build a Dynamic Portfolio

I personally have used GitHub API in my portfolio website. 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:

A Personal Website w/ EVERYTHING

Idea #2: Build a GitHub Dashboard

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

Idea #3: Learn about ghapi

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!

--

--