In-depth: GitHub Public API Structure and Fields (Part-2)

In the last part(Part-01) I have done the tedious work of installation, setting variables and downloading library, which are required to make GitHub API application using Python. In this part, I am going to discuss about the structure of GitHub API’s JSON and its components. The best companion of us in this part would be the browser. I am going to use Chrome.

Now let us dive into the theoretical portion of GitHub API.

GitHub PUBLIC API’s JSON Structure of Users

In order to get the public information of any user on GitHub, just type-in the following URL in your browser:

https://api.github.com/users/{user-name}

Here {user-name} is the field that you need to replace with the person’s GitHub account name so as to get the JSON data of that particular user.

I am going to use “Facebook” GitHub page as an example.

Example

Go to the following link:

https://api.github.com/users/facebook

You would see the result shown below:

Let us discuss few important fields!

Login field

The login field is actually the login name/username of the GitHub account. In the case of Facebook, the login name is actually facebook.

Below is the image showing the account login fields in the live GitHub page:

ID field

The id field of GitHub API represents the number in the database of GitHub. Facebook account of GitHub has been assigned the id of 69631.

Did you know?

If you go to the following URL:

https://api.github.com/users?since=0

You would get the results of each and every GitHub account in the order of ID. The “since” field in the URL specifies that from which ID you want to look at. GitHub API usually gives 30 results back. If you let us say, use the following URL:

https://api.github.com/users?since=69630

You would get the Facebook account details at the top since the id of the Facebook account is 69631(as shown below):

You must notice that the value of the “since” tag in the URL gives you the first result having ID incremented by 1 in original value of that tag. For example, in the above picture, you can see that the since tag has the value 69630, and the first result we got has the ID 69631.

avatar_url field

This field will return you the profile picture of the channel. In Facebook case, the image that would be returned will be (shown below):

url field

This field would return you the URL of the channel.

Bio field

It would return you the bio of the GitHub Channel. In Facebook’s case, the description is "We work hard to contribute our work back to the web, mobile, big data, & infrastructure communities. NB: members must have two-factor auth.”

Repos_url field

It would return you the GitHub channel’s repositories. But keep in mind that the returned repositories would be:

  • In alphabetical order.
  • First 20 repositories would be returned. For more, you have to use pagination.
  • Only the public repositories would be returned

Summary

In this part, I have discussed few of the important, public fields that you would get back using GitHub API. In the next part, we will code together using the above knowledge in Python.
That’s it for this part.

Next Part

Coding: GitHub Public API Application using Python (Part-3)

Related article

AUTHOR

READ NEXT

Boostlog is an online community for developers
who want to share ideas and grow each other.

Delete an article

Deleted articles are gone forever. Are you sure?