SonyaCore / Github-search-cli

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Github-search-cli

python3 project-url version Contributors Forks Stargazers Issues

GitHub restful API search implementation on python3

About

github-search-cli provides a module called Github, that can be used to access all of GitHub's Search API functionality from your command-line

https://docs.github.com/en/rest/search

Installation

Installing gitub-search-cli using pip

pip3 install github-search-cli

OR

Installing through GitHub

pip3 install --upgrade git+https://github.com/SonyaCore/Github-search-cli.git

Usage

Show help and exit

python3 -m Github -h

Options

  --query , -q     Query for the searching method
  --sort , -s      Sorting method for request output
  --order , -o     Define the first search result returned is the highest or lowest number of matches.
  --perpage , -p   The number of results per page
  --page , -page   Page number of the results to fetch.
  --repoid , -i    Repository id for labels endpoint
  --save , -j      Save JSON output

all the search queries for https://docs.github.com/en/rest/search is implemented on this python module

list of available search queries code,commits,issues,labels,repository,topics,users

for fetching 100 results or 200 results per page use --perpage arugment ex :

python3 -m Github repository --query repo:username/repo --perpage 200 --save reg.json

Search examples

Search for users with a query

python3 -m Github users -q user  --save user.json

Search for repositories with defined arguments

python3 -m Github repository --query repo:username/repo --save reg.json

Using API

You can also use it like this:

from Github.Search import Search
from Github.Timer import Timer


# initial github class
github = Search()

# initial timer class
timer = Timer()

# intial a timer (optional)
timer.start()

# using github.user method to fetch users from GitHub rest API with a query
users = github.users("code")

# using github.repository method to fetch repositories based on their name and ...
repository = github.repository("test",sort="stars",order="desc")


# using github.commits method to search on commits
commits = github.commits("repo:octocat/Spoon-Knife+css",sort="committer-date")

# printing the fetched data
print(users)
print(repository)
print(commits)

# save the result to a JSON file
github.save("user.json", users)
github.save("repo.json",repository)
github.save("commits.json",commits)

timer.stop()

License

Licensed under the GPL-3 license.

About

License:GNU General Public License v3.0


Languages

Language:Python 100.0%