Git Product home page Git Product logo

github4api's Introduction

github4api

Version 1.1.5

Written with Python 3.11.3



Ready To Use

Developed by Shervin Badanara (shervinbdndev) on Github




Language and technologies used in This Project


WorkSpace





! Warning !

  • This package uses ExceptionGroup to handle exceptions.

  • You have to use python 3.11 or above to be able to use this package.




Update Your Interpreter

Windows / CMD

py -m pip install --upgrade pip

Linux / Terminal

python -m pip install --upgrade pip





Installation

Windows / CMD , Linux / Terminal

pip install github4api

or

py -m pip install github4api




Update Library

Windows / CMD , Linux / Terminal

pip install -U github4api

or

py -m pip install --upgrade github4api





Usage


from github4api.scraper import Scrape # Scraper Class
from github4api.handlers.user_handler import UserHandler # User Handler Class
from github4api.handlers.request_handler import RequestHandler # Request Handler Class


def main():

    # UserHandler serializes the value you given to the username param
    # RequestHandler gets the Serialized data then sends a GET request to github servers and saves the page content in request variable

    request: RequestHandler = RequestHandler(
        url=UserHandler(username='shervinbdndev').serialize(),
    ).sendGetRequest(content=True)
    

    # Scrape gets the variable as an arg

    scraper: Scrape = Scrape(data=request)

    # then we start using API by calling the startApi method
    
    scraper.startApi(log=False) # log param is for safety, the default value is True but you can change it
    

    # After all of these steps now you're free to use the API

    print(scraper.followers)
    print(scraper.followings)
    print(scraper.biography)
    
    print(scraper.json_data) # get full json data of user



if (__name__ == "__main__"):
    main()




New Changes on Version 1.1.3

  • Now you can Access User's Repositories Names

from github4api.scraper import Scrape
from github4api.handlers.user_handler import UserHandler
from github4api.handlers.request_handler import RequestHandler




def main():
    request: RequestHandler = RequestHandler(
        url=UserHandler(username='shervinbdndev').serialize(),
    ).sendGetRequest(content=True)
    
    scraper: Scrape = Scrape(data=request)
    
    scraper.startApi(log=False)

    # Then your free to use the new method to get User's Repositories names
    
    print(scraper.repositoriesNames(username='shervinbdndev'))

    # ftl (first to last) is a new option that you can use to show the repositories from the first created to the last one

    print(scraper.repositoriesNames(username='shervinbdndev', ftl=True)) # default value is False

    # Also you can select the repository by index like below

    print(scraper.repositoriesNames(username='shervinbdndev')[3]) # for example I want the 4th repository (It starts from 0 btw)



if (__name__ == "__main__"):
    main()




New Changes on Version 1.1.4

Now you can Access

  • User's Total Stars Given

  • User's Profile Picture Url

  • Check Repository Star Count

from github4api.scraper import Scrape
from github4api.handlers.user_handler import UserHandler
from github4api.handlers.request_handler import RequestHandler



def main():
    request: RequestHandler = RequestHandler(
        url=UserHandler(username='shervinbdndev').serialize()
    ).sendGetRequest(content=True)
    
    scraper: Scrape = Scrape(data=request)
    
    scraper.startApi(log=False)
    
    print(scraper.totalStarsGiven) # total stars given
    
    print(scraper.profilePictureUrl) # profile picture url

    # now using this new method you lets you check users repository's star count

    print(scraper.checkRepositoryStars(
        username='shervinbdndev', # user's username
        repo_name='Quizino', # repository's name
    ))




if (__name__ == "__main__"):
    main()




New Changes on Version 1.1.5

Now you can Access

  • User's Last Year Contributions

  • Check if User's Repository is Public Archive

  • Check if User has README.md

  • Get Repository's Used Languages

  • Get User's Unlocked Achievements

from github4api.scraper import Scrape
from github4api.handlers.user_handler import UserHandler
from github4api.handlers.request_handler import RequestHandler




def main():
    user: UserHandler = UserHandler(username='shervinbdndev').serialize() # user instance
    
    request: RequestHandler = RequestHandler(url=user).sendGetRequest(content=True) # send request by RequestHandler
    
    scraper: Scrape = Scrape(data=request)
    
    scraper.startApi(log=False)
    
    print(scraper.lastYearContributions) # last year contributions
    
    print(scraper.isRepositoryPublicArchive(username='shervinbdndev', repo_name='Quizino')) # check if repository is public archive => returns True or False
    
    print(scraper.userHasReadMe(username='shervinbdndev')) # check if user has README.md

    print(scraper.repositoryUsedLanguages(username='shervinbdndev', repo_name='github4api')) # get repository's used languages (also you can select by index)

    print(scraper.userAchievements(username='shervinbdndev')) # get user's achievements (also you can select by index)
    



if (__name__ == "__main__"):
    main()

Enjoy :)


Package Uploaded in PYPI :Here

github4api's People

Contributors

shervinbdndev avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.