It's been a while since I published my last blog. But I've been busy with learning new concepts and working on my individual project.

As part of our bootcamp we were given about eight different projects and our job was to pick any one project and work on it individually. I picked the above mentioned GitHub project.

Below mention are the new concepts I learned while working on my project.

  1. GitHub API documentation:

My first task was to read the GitHub documentation and understand what is an API and how to it works.

So what is an API? What is a REST API?

API stands for Application Programming Interface. An API is a set of routines, protocols, and tools for building software application. Simply put it's a messenger that takes the requests  and tells a system what you want to do and then return the response back to you. In a very layman term messenger is a waiter in a restaurant. He is a critical link between you and chef in the kitchen of the restaurant. Waiters job is to communicate your order to the kitchen and deliver your food back to your table. Just like a restaurant, GitHub has a menu. For e.g. you choose programming language, click on trending projects, etc. In order to get the data you want, you interact with GitHub's website to access GitHub's database to see which user committed repositories recently, and/or which projects are trending etc. But what if you don't want to search all these information manually but write a command and let your software do the search based on variables you enter. In that case your software interacts with GitHub's API. API is like that helpful waiter can be asked by your software program to get certain information from GitHub's database over the internet and deliver right back to your software program which then shows it you.

What is a REST API?

It stands for Representational State Transfer. It is a software architectural style. It uses HTTP requests to GET, PUT, POST and DELETE data.

Git sends and receives data as JSON.

What is JSON?

JSON stands for Java Script Object Notation. Simply put it is a format in which you can transfer data from client to server and server to client.


Back in the days we used to create website with static pages, so we could use html, css, javascript. But now we are making dynamic web pages/applications. Dynamic means the data which you'll get from the server will be on request. From example a client(your application) is a sent a request to a server, and in response the server is sending some data. This data can be in any format. Normally, when we talk about returning data, we are taking html format. But instead of returning html, we just need the data. Because our application already have the design(html,css,etc), but what the application don't have is the data. The data will come from the server. So how do we get only the data. We can get only in plain text format, but the plain text format will be difficult to parse it to client, especially some complex data. Moreover, most of the application use Object-oriented programming paradigm, where you don't send simple data but complex objects. So what if a server could send data as object itself (instead of plain text) which is readable by your application. So how do we do it, how do we just fetch the values of an object and put somewhere, and send that something to the client side and your client will be able to read/parse it. It is only possible if you send your data in JSON format. JSON format has key value pair. For e.g.: variable_language = {'language':'python'} now you can just call the 'variable_language' in Python function and display, etc. the data easily because Python understands data/object in dictionary.  

2. Curl:

As I was reading the GitHub documentation I came across following curl commands.

So what is curl?

The definition of the curl (cURL)program is a command line tool. It uses URL syntax to transfer data to and from servers. For APIs, that are HTTP-based, curl offers a simple way to test APIs. There are many options for curl commands. In the above example -u is for username.

3. Mock Test

What is mock test or mocking?

A mock object substitutes and imitates a real object within a testing environment.

What is it used for?

When you are writing a code which deals with external websites, there are two parts of the test/code. One is the making the request part and second is the logic of the application/function. Obstacles such as complex logic and unpredictable dependencies make writing valuable tests difficult. The Python mock test or mock object library can be useful and help you overcome these obstacles.

Why it is useful?

There are a few reason. But one of them is you have a little or no control over external (in this case GitHub api) services. For example, if your code makes HTTP requests to GitHub api, a temporary change in the behavior of this site can cause your test to fail. So the reason to use Python mock object is to control your code's behavior during testing.

4. command-line interface/argparse

What is argparse?

It is a parser for command-line options, arguments and sub-commands. The argparse module makes it easy to write user-friendly command-line interfaces.

For e.g to run the 'github_project_recommendation_tool' from command line, please enter:

It'll go to user's (repoZTrees in the above example) GitHub account. Check all the repositories, check user's language of choice or favorite language. Based on the favorite language, give a list of all the recent commits by: username/repositories names. For e.g.:

To view the code, please go to:

Thank you.