DEV Community

Cover image for GitHub API
Tina Huynh
Tina Huynh

Posted on

GitHub API

Table of Contents

  1. Overview
  2. Available Libraries
  3. Useful Endpoints
  4. Project Ideas with GitHub API

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

OAuth2 token:

$ curl -H "Authorization: token OAUTH-TOKEN" https://api.github.com
Enter fullscreen mode Exit fullscreen mode

OAuth2 key/secret:

$ curl -u my_client_id:my_client_secret 'https://api.github.com/user/repos'
Enter fullscreen mode Exit fullscreen mode

Available Libraries

Useful Endpoints

  • GET /events

Note: public event feeds are delayed by five minutes
curl events

  • GET /notifications

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

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

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

  • GET /repos/{owner}/{repo}/languages

Image description

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

Image description

Project Ideas

  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:

  1. Build a GitHub Dashboard

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

  1. 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!

Top comments (2)

Collapse
 
vulcanwm profile image
Medea

Nice explanation!

Collapse
 
tmchuynh profile image
Tina Huynh

Thanks