This week marked the beginning of an exciting part of the course. Individual project. We were given a list of projects to choose from. I chose the one to create a command line app to give git recommendations.
In a broad sense, I need two types of data to give recommendations from github.
- User level
- Details of all repositories in Github
User level data from github:
Without much difficulties I was able to find a way to get data from github using github api /users url.
user_details = requests.get('https://api.github.com/user', auth=(username, password))
'user_details' variable will contain a json in dictionary format, from where, we can get every details of the user like, number of repositories etc. we can get each required detail using function like user_details.get('repos_url').
In addition to that, we need to get the details of the repositories of the user. For this we can use the above json to find the repos_url and fetch the details of each repository through another request.get() request. This will give a list of dictionaries, each dictionary being details of each repo.
Github api gives a search url for searching various data in github. For example,
will let us search through all the repositories in github.
This search api provides an option to query the list of repos with different conditions.
Supported format for the query is