├── .github ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PROJECTS.md ├── PULL_REQUEST_TEMPLATE │ └── PULL_REQUEST_TEMPLATE.md └── dependabot.yml ├── .gitignore ├── .replit ├── README.md └── src ├── LICENSE ├── README.md ├── git_api ├── __init__.py └── main.py └── setup.py /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | aspirin#5634. 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | To contribute, you can either go to the [GitHub page](https://github.com/JBYT27/GitAPI/pulls) and leave a PR or leave a comment on the [Replit Spotlight page](https://replit.com/@JBloves27/GitAPI?v=1). 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/PROJECTS.md: -------------------------------------------------------------------------------- 1 | - [GitHub User Search -> GitHub-User-Search.jbloves27.repl.co](https://GitHub-User-Search.jbloves27.repl.co) 2 | - [GitHub User Search v1 -> https://replit.com/@JBloves27/GitHub-User-Search-v1](https://replit.com/@JBloves27/GitHub-User-Search-v1) 3 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "github-actions" 9 | directory: "/" 10 | schedule: 11 | interval: "daily" 12 | - package-ecosystem: "pip" 13 | directory: "/" 14 | schedule: 15 | interval: "daily" 16 | allow: 17 | - dependency-name: "json*" 18 | dependency-type: "direct" 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | 131 | # Custom 132 | .replit 133 | -------------------------------------------------------------------------------- /.replit: -------------------------------------------------------------------------------- 1 | language = "python" 2 | run = "python src/git_api/main.py" 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | > **Version: 1.7.5 3 | 4 | [![Contributors](https://img.shields.io/github/contributors/JBYT27/GitAPI?style=for-the-badge)](https://github.com/JBYT27/GitAPI/graphs/contributors) 5 | [![Forks](https://img.shields.io/github/forks/JBYT27/GitAPI?style=for-the-badge)](https://github.com/JBYT27/GitAPI/network/members) 6 | [![Stargazers](https://img.shields.io/github/stars/JBYT27/GitAPI?style=for-the-badge)](https://github.com/JBYT27/GitAPI/stargazers) 7 | [![Issues](https://img.shields.io/github/issues/JBYT27/GitAPI?style=for-the-badge)](https://github.com/JBYT27/GitAPI/issues) 8 | [![License](https://img.shields.io/github/license/JBYT27/GitAPI?style=for-the-badge)](https://github.com/JBYT27/GitAPI/blob/master/LICENSE) 9 | [![Downloads on PyPI](https://img.shields.io/pypi/dw/git_api?style=for-the-badge)](https://pypi.org/project/git-api/) 10 | 11 | # GitAPI: An API made for GitHub Stats! 12 | > Coded in [Python3](https://python.org), uploaded to [PyPi](https://pypi.org/project/git-api), and coded by [JBYT27](https://github.com/JBYT27) 13 | 14 | ## About 15 | ### About 16 | GitAPI is an API made with python - styled with json - to make the data preferably easier to use. It is made up of posting `json` requests, and retrieving that data from a function, and transfering that data into an output, in which you can use. 17 | 18 | This API is designed to show GitHub stats for certain users, or viewing GitHub itself, in data form. 19 | 20 | > To learn how to use it, you can read the Usage header below. 21 | 22 | ### Languages used 23 | Languages used to program this package were: [Python3](https://python.org) 24 | 25 | ### Queries 26 | Not all of the GitHub queries are in here, but if you wish to see all of them, go to [this](https://docs.github.com/en/graphql/reference/queries) GitHub docs. 27 | 28 | ### Contributers 29 | - [darkdarcool](https://github.com/darkdarcool): More professionalized file-ing and helping with more GitHub Queries. 30 | - [Isaiah08-D](https://github.com/Isaiah08-D): Adding comments, and letting us know of [bug](https://github.com/JBYT27/GitAPI/issues/11). 31 | - [jwodder](https://github.com/jwodder): Finding the solution to the [bug](https://github.com/JBYT27/GitAPI/issues/11). 32 | 33 | ## Usage 34 | ### Installation 35 | 36 | To install and use the package, you must first: 37 | 38 | ```shell 39 | pip install git_api 40 | ``` 41 | 42 | This will install the package - `git_api`(GitAPI) - and then you will be able to use it. 43 | 44 | To then import it, you must put the following code: 45 | 46 | ```py 47 | import git_api 48 | ``` 49 | **OR** 50 | ```py 51 | import git_api as gitapi 52 | ``` 53 | **OR** 54 | ```py 55 | from git_api import * 56 | ``` 57 | For more information, go [here](https://pypi.org/project/git-api/). 58 | 59 | > Note that all of these methods work. 60 | 61 | ### Usage 62 | To use this package, first import it as shown above. Then create a python file - name it whatever you want, it doesn't matter. 63 | 64 | Once you're done with that, open the file, and add the following example code: 65 | 66 | ```py 67 | import git_api 68 | 69 | git_api.Token() # We'll place the personal access token here later on. For now, it'll be empty. 70 | user_info = git_api.User("Username here").User() # Insert your username in the argument shown here. 71 | 72 | print(user_info) 73 | ``` 74 | 75 | You've done it! But wait - it doesn't work, it only gives an error! The reason for this is that - 76 | 77 | **NUMBER 1**: You need a personal access token which we'll discuss in a moment. 78 | 79 | **NUMBER 2**: You need to have a GitHub username in mind and place it in the assigned space. 80 | 81 | Let's start with number 1, creating the token. 82 | 83 | #### 1: The Token 84 | To first create a token, you must create or use an existing GitHub account. If you already have a GitHub account, you can move on to the next section. However, if you are *creating* a new GitHub account, follow the instructions below: 85 | 86 | #1: Go to [`https://github.com`](https://github.com) and click `sign up`. 87 | 88 | #2: Once you've clicked that, just follow the instructions shown on the page. 89 | 90 | #3: Then after that, you can either get used to GitHub and do this later, or do this immediately; Go to [this](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token) document and read it thoroughly, as it holds the information to creating a personal token. Choose the categories you think will best fit for your project and finish up with the token. 91 | 92 | #4: Note that this token should be kept private and not shared. If you are positive that this token will be private, then you can just copy and paste the token into a string (inside parentheses), and insert it into the token argument space. However, if you know that this will be shown to the public, create a `.env` file, and paste the token inside there. Make sure you make it a variable, for example, like this: 93 | 94 | ``` 95 | token=blahblahblah 96 | ``` 97 | Also note that you can only copy the token once, so check that you actually copied down the token. Go back into your python file and copy/paste down the following code into the assigned space; 98 | 99 | ```py 100 | os.environ["token"] # Insert your .env variable here 101 | ``` 102 | 103 | > **NOTE: All GitAPI functions must have a token in order for it to work.** 104 | 105 | #5: Then you're pretty much done! Your final code example should look something like this: 106 | 107 | #### 2: Finale 108 | 109 | ```py 110 | import git_api 111 | 112 | git_api.Token(os.environ["token"]) 113 | user_info = git_api.User("JBYT27").User() 114 | 115 | print(user_info) 116 | ``` 117 | 118 | > This will print some of the user's information. 119 | 120 | #### Another cool thing you can do with this package is print a GitHub User's followers! Wanna try? Here we go! 121 | 122 | #### 1. Import the package 123 | First, import the package as shown above. All you need to do is `import git_api`. Or you can install from `pip` and then do that. Let's go onto the next step. 124 | 125 | #### 2. Get the token 126 | Remember how I said the token was important? Yeah, it really is. So it's step 2 ;) 127 | If you don't know how to create a token, it's written right above. So far, you should have something like this: 128 | 129 | ```py 130 | import git_api 131 | import os 132 | 133 | git_api.Token(os.environ["token"]) 134 | ``` 135 | 136 | #### 3. The function 137 | Now we write the function. So to get a GitHub user's followers, it's a bit wonky. So the syntax for the function is `git_api.UserFollower("USERNAME", "INTEGER").Followers()`. You replace the `"USERNAME"` with a GitHub username and replace the `"INTEGER"` with a string that has a integer number inside it to show how many followers should be shown. Note that this is **returning** the value, not *printing* it. So what you have to remember is that you have to print this variable or value in order for it to show. 138 | 139 | *Kinda confusing, right? Let me show you an example :)* 140 | 141 | ```py 142 | import git_api # importing the package. Note that you can use `pip` as well 143 | import os # using os package to get token from .env file 144 | 145 | git_api.Token(os.environ["token"]) # retrieves the token so you can use it. 146 | 147 | follower_data = git_api.UserFollower("JBYT27", "10").Followers() # the gitapi function to get data 148 | 149 | print(follower_data) # prints data 150 | ``` 151 | 152 | So that will print a GitHub user's followers. If you want to show the users that a GitHub user is following, all you have to do is switch the function(`UserFollower`) to `UserFollowing`. So for following, it would look like this: 153 | 154 | ```py 155 | import git_api # importing the package. Note that you can use `pip` as well 156 | import os # using os package to get token from .env file 157 | 158 | git_api.Token(os.environ["token"]) # retrieves the token so you can use it. 159 | 160 | following_data = git_api.UserFollowing("JBYT27", "10").Following() # the gitapi function to get data 161 | 162 | print(following_data) # prints data 163 | ``` 164 | 165 | You can take a look at the code, or just play with it if you want to experiment with it :) 166 | 167 | > An example repl is listed [here](https://replit.com/@JBloves27/GitAPI-Example). 168 | 169 | 170 | ## Contributing 171 | Contributing will be listed mostly in the [Code of Conduct](https://github.com/JBYT27/GitAPI/blob/master/.github/CODE_OF_CONDUCT.md), however for more info, visit the [Contributing](https://github.com/JBYT27/GitAPI/blob/master/.github/CONTRIBUTE.md) readme. 172 | 173 | ## License 174 | This package is under the [`MIT License`](https://github.com/JBYT27/GitAPI/blob/master/MyApp/LICENSE). 175 | 176 | ## Projects 177 | All of the projects involving or using this package is listed [here](https://github.com/JBYT27/GitAPI/blob/master/.github/PROJECTS.md). 178 | 179 | ## Features: 180 | - [x] Add basic features for `User()` class 181 | - [x] Add advanced features for `User()` class 182 | - [x] Add basic functions for `GitHub()` class 183 | - [ ] Add advanced functions for `GitHub()` class 184 | - [x] Add basic functions in package 185 | - [ ] Add documentary for package 186 | 187 | 188 | ## All functions: 189 | 190 | #### `git_api.User("username")` 191 | * `git_api.User("username").User()` 192 | * `git_api.User("username").Name()` 193 | * `git_api.User("username").Bio()` 194 | * `git_api.User("username").Name()` 195 | * `git_api.User("username").Email()` 196 | * `git_api.User("username").Avatar()` 197 | * `git_api.User("username").Account()` 198 | * `git_api.User("username").Admin()` 199 | * `git_api.User("username").Location()` 200 | * `git_api.User("username").Twitter()` 201 | * `git_api.User("username").Developer()` 202 | * `git_api.User("username").Userid()` 203 | * `git_api.User("username").PinnedItems()` 204 | * `git_api.User("username").Company()` 205 | 206 | #### `git_api.UserFollower("username", "num_of_followers_shown")` 207 | * `git_api.UserFollower("username", "num_of_followers_shown").Followers()` 208 | 209 | #### `git_api.UserFollowing("username", "num_of_following_shown")` 210 | * `git_api.UserFollowing("username", "num_of_following_shown").Following()` 211 | 212 | #### `git_api.GitHub()` 213 | >** An incomplete class. DO NOT USE!** 214 | 215 | * `git_api.GitHub.Status()` 216 | 217 | #### `git_api.Repo("owner", "reponame")` 218 | * `git_api.Repo("owner", "reponame").Repo()` 219 | * `git_api.Repo("owner", "reponame").CreatedAt()` 220 | * `git_api.Repo("owner", "reponame").Databaseid()` 221 | * `git_api.Repo("owner", "reponame").Description()` 222 | * `git_api.Repo("owner", "reponame").Homepageurl()` 223 | * `git_api.Repo("owner", "reponame").Id()` 224 | * `git_api.Repo("owner", "reponame").IsArchived()` 225 | * `git_api.Repo("owner", "reponame").IsDisabled()` 226 | * `git_api.Repo("owner", "reponame").IsEmpty()` 227 | * `git_api.Repo("owner", "reponame").IsLocked()` 228 | * `git_api.Repo("owner", "reponame").IsPrivate()` 229 | * `git_api.Repo("owner", "reponame").Name()` 230 | * `git_api.Repo("owner", "reponame").Language()` 231 | * `git_api.Repo("owner", "reponame").Stars()` 232 | -------------------------------------------------------------------------------- /src/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 JBYT27 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/README.md: -------------------------------------------------------------------------------- 1 | 2 | > **Version: 1.7.5 3 | 4 | [![Contributors](https://img.shields.io/github/contributors/JBYT27/GitAPI?style=for-the-badge)](https://github.com/JBYT27/GitAPI/graphs/contributors) 5 | [![Forks](https://img.shields.io/github/forks/JBYT27/GitAPI?style=for-the-badge)](https://github.com/JBYT27/GitAPI/network/members) 6 | [![Stargazers](https://img.shields.io/github/stars/JBYT27/GitAPI?style=for-the-badge)](https://github.com/JBYT27/GitAPI/stargazers) 7 | [![Issues](https://img.shields.io/github/issues/JBYT27/GitAPI?style=for-the-badge)](https://github.com/JBYT27/GitAPI/issues) 8 | [![License](https://img.shields.io/github/license/JBYT27/GitAPI?style=for-the-badge)](https://github.com/JBYT27/GitAPI/blob/master/LICENSE) 9 | [![Downloads on PyPI](https://img.shields.io/pypi/dw/git_api?style=for-the-badge)](https://pypi.org/project/git-api/) 10 | 11 | # GitAPI: An API made for GitHub Stats! 12 | > Coded in [Python3](https://python.org), uploaded to [PyPi](https://pypi.org), and coded by [JBYT27](https://github.com/JBYT27) 13 | 14 | ## About 15 | ### About 16 | GitAPI is an API made with python - styled with json - to make the data preferably easier to use. It is made up of posting `json` requests, and retrieving that data from a function, and transfering that data into an output, in which you can use. 17 | 18 | This API is designed to show GitHub stats for certain users, or viewing GitHub itself, in data form. 19 | 20 | > To learn how to use it, you can read the Usage header below. 21 | 22 | ### Posts 23 | The Replit post is located [here](https://replit.com/talk/share/GitAPI-A-GitHub-API-for-you/146858) 24 | 25 | ### Languages used 26 | Languages used to program this package were: [Python3](https://python.org) 27 | 28 | ### Queries 29 | Not all of the GitHub queries are in here, but if you wish to see all of them, go to [this](https://docs.github.com/en/graphql/reference/queries) GitHub docs. 30 | 31 | ### Contributers 32 | - [darkdarcool](https://github.com/darkdarcool): More professionalized file-ing and helping with more GitHub Queries. 33 | - [Isaiah08-D](https://github.com/Isaiah08-D): Adding comments, and letting us know of [bug](https://github.com/JBYT27/GitAPI/issues/11). 34 | - [jwodder](https://github.com/jwodder): Finding the solution to the [bug](https://github.com/JBYT27/GitAPI/issues/11). 35 | 36 | ## Usage 37 | ### Installation 38 | 39 | To install and use the package, you must first: 40 | 41 | ```shell 42 | pip install git_api 43 | ``` 44 | 45 | This will install the package - `git_api`(GitAPI) - and then you will be able to use it. 46 | 47 | To then import it, you must put the following code: 48 | 49 | ```py 50 | import git_api 51 | ``` 52 | **OR** 53 | ```py 54 | import git_api as gitapi 55 | ``` 56 | **OR** 57 | ```py 58 | from git_api import * 59 | ``` 60 | For more information, go [here](https://pypi.org/project/git-api/). 61 | 62 | > Note that all of these methods work. 63 | 64 | ### Usage 65 | To use this package, first import it as shown above. Then create a python file - name it whatever you want, it doesn't matter. 66 | 67 | Once you're done with that, open the file, and add the following example code: 68 | 69 | ```py 70 | import git_api 71 | 72 | git_api.Token() # We'll place the personal access token here later on. For now, it'll be empty. 73 | user_info = git_api.User("Username here").User() # Insert your username in the argument shown here. 74 | 75 | print(user_info) 76 | ``` 77 | 78 | You've done it! But wait - it doesn't work, it only gives an error! The reason for this is that - 79 | 80 | **NUMBER 1**: You need a personal access token which we'll discuss in a moment. 81 | 82 | **NUMBER 2**: You need to have a GitHub username in mind and place it in the assigned space. 83 | 84 | Let's start with number 1, creating the token. 85 | 86 | #### 1: The Token 87 | To first create a token, you must create or use an existing GitHub account. If you already have a GitHub account, you can move on to the next section. However, if you are *creating* a new GitHub account, follow the instructions below: 88 | 89 | #1: Go to [`https://github.com`](https://github.com) and click `sign up`. 90 | 91 | #2: Once you've clicked that, just follow the instructions shown on the page. 92 | 93 | #3: Then after that, you can either get used to GitHub and do this later, or do this immediately; Go to [this](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token) document and read it thoroughly, as it holds the information to creating a personal token. Choose the categories you think will best fit for your project and finish up with the token. 94 | 95 | #4: Note that this token should be kept private and not shared. If you are positive that this token will be private, then you can just copy and paste the token into a string (inside parentheses), and insert it into the token argument space. However, if you know that this will be shown to the public, create a `.env` file, and paste the token inside there. Make sure you make it a variable, for example, like this: 96 | 97 | ``` 98 | token=blahblahblah 99 | ``` 100 | Also note that you can only copy the token once, so check that you actually copied down the token. Go back into your python file and copy/paste down the following code into the assigned space; 101 | 102 | ```py 103 | os.environ["token"] # Insert your .env variable here 104 | ``` 105 | 106 | > **NOTE: All GitAPI functions must have a token in order for it to work.** 107 | 108 | #5: Then you're pretty much done! Your final code example should look something like this: 109 | 110 | #### 2: Finale 111 | 112 | ```py 113 | import git_api 114 | 115 | git_api.Token(os.environ["token"]) 116 | user_info = git_api.User("JBYT27").User() 117 | 118 | print(user_info) 119 | ``` 120 | 121 | > This will print some of the user's information. 122 | 123 | #### Another cool thing you can do with this package is print a GitHub User's followers! Wanna try? Here we go! 124 | 125 | #### 1. Import the package 126 | First, import the package as shown above. All you need to do is `import git_api`. Or you can install from `pip` and then do that. Let's go onto the next step. 127 | 128 | #### 2. Get the token 129 | Remember how I said the token was important? Yeah, it really is. So it's step 2 ;) 130 | If you don't know how to create a token, it's written right above. So far, you should have something like this: 131 | 132 | ```py 133 | import git_api 134 | import os 135 | 136 | git_api.Token(os.environ["token"]) 137 | ``` 138 | 139 | #### 3. The function 140 | Now we write the function. So to get a GitHub user's followers, it's a bit wonky. So the syntax for the function is `git_api.UserFollower("USERNAME", "INTEGER").Followers()`. You replace the `"USERNAME"` with a GitHub username and replace the `"INTEGER"` with a string that has a integer number inside it to show how many followers should be shown. Note that this is **returning** the value, not *printing* it. So what you have to remember is that you have to print this variable or value in order for it to show. 141 | 142 | *Kinda confusing, right? Let me show you an example :)* 143 | 144 | ```py 145 | import git_api # importing the package. Note that you can use `pip` as well 146 | import os # using os package to get token from .env file 147 | 148 | git_api.Token(os.environ["token"]) # retrieves the token so you can use it. 149 | 150 | follower_data = git_api.UserFollower("JBYT27", "10").Followers() # the gitapi function to get data 151 | 152 | print(follower_data) # prints data 153 | ``` 154 | 155 | So that will print a GitHub user's followers. If you want to show the users that a GitHub user is following, all you have to do is switch the function(`UserFollower`) to `UserFollowing`. So for following, it would look like this: 156 | 157 | ```py 158 | import git_api # importing the package. Note that you can use `pip` as well 159 | import os # using os package to get token from .env file 160 | 161 | git_api.Token(os.environ["token"]) # retrieves the token so you can use it. 162 | 163 | following_data = git_api.UserFollowing("JBYT27", "10").Following() # the gitapi function to get data 164 | 165 | print(following_data) # prints data 166 | ``` 167 | 168 | You can take a look at the code, or just play with it if you want to experiment with it :) 169 | 170 | > An example repl is listed [here](https://replit.com/@JBloves27/GitAPI-Example). 171 | 172 | 173 | ## Contributing 174 | Contributing will be listed mostly in the [Code of Conduct](https://github.com/JBYT27/GitAPI/blob/master/.github/CODE_OF_CONDUCT.md), however for more info, visit the [Contributing](https://github.com/JBYT27/GitAPI/blob/master/.github/CONTRIBUTE.md) readme. 175 | 176 | ## License 177 | This package is under the [`MIT License`](https://github.com/JBYT27/GitAPI/blob/master/MyApp/LICENSE). 178 | 179 | ## Projects 180 | All of the projects involving or using this package is listed [here](https://github.com/JBYT27/GitAPI/blob/master/.github/PROJECTS.md). 181 | 182 | ## Features: 183 | - [x] Add basic features for `User()` class 184 | - [ ] Add advanced features for `User()` class 185 | - [x] Add basic functions for `GitHub()` class 186 | - [ ] Add advanced functions for `GitHub()` class 187 | - [ ] Add basic functions in package 188 | - [ ] Add documentary for package 189 | 190 | 191 | ## All functions: 192 | 193 | #### `git_api.User("username")` 194 | * `git_api.User("username").User()` 195 | * `git_api.User("username").Name()` 196 | * `git_api.User("username").Bio()` 197 | * `git_api.User("username").Name()` 198 | * `git_api.User("username").Email()` 199 | * `git_api.User("username").Avatar()` 200 | * `git_api.User("username").Account()` 201 | * `git_api.User("username").Admin()` 202 | * `git_api.User("username").Location()` 203 | * `git_api.User("username").Twitter()` 204 | * `git_api.User("username").Developer()` 205 | * `git_api.User("username").Userid()` 206 | * `git_api.User("username").PinnedItems()` 207 | * `git_api.User("username").Company()` 208 | 209 | #### `git_api.UserFollower("username", "num_of_followers_shown")` 210 | * `git_api.UserFollower("username", "num_of_followers_shown").Followers()` 211 | 212 | #### `git_api.UserFollowing("username", "num_of_following_shown")` 213 | * `git_api.UserFollowing("username", "num_of_following_shown").Following()` 214 | 215 | #### `git_api.GitHub()` 216 | >** An imcomplete class. DO NOT USE!** 217 | 218 | * `git_api.GitHub.Status()` 219 | 220 | #### `git_api.Repo("owner", "reponame")` 221 | * `git_api.Repo("owner", "reponame").Repo()` 222 | * `git_api.Repo("owner", "reponame").CreatedAt()` 223 | * `git_api.Repo("owner", "reponame").Databaseid()` 224 | * `git_api.Repo("owner", "reponame").Description()` 225 | * `git_api.Repo("owner", "reponame").Homepageurl()` 226 | * `git_api.Repo("owner", "reponame").Id()` 227 | * `git_api.Repo("owner", "reponame").IsArchived()` 228 | * `git_api.Repo("owner", "reponame").IsDisabled()` 229 | * `git_api.Repo("owner", "reponame").IsEmpty()` 230 | * `git_api.Repo("owner", "reponame").IsLocked()` 231 | * `git_api.Repo("owner", "reponame").IsPrivate()` 232 | * `git_api.Repo("owner", "reponame").Name()` 233 | * `git_api.Repo("owner", "reponame").Language()` 234 | * `git_api.Repo("owner", "reponame").Stars()` 235 | -------------------------------------------------------------------------------- /src/git_api/__init__.py: -------------------------------------------------------------------------------- 1 | from .main import * 2 | -------------------------------------------------------------------------------- /src/git_api/main.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import os 3 | import json 4 | 5 | 6 | url = 'https://api.github.com/graphql' 7 | USER = """ 8 | bio 9 | email 10 | avatarLink:avatarUrl 11 | accountCreatedAt:createdAt 12 | isAdmin:isSiteAdmin 13 | location 14 | name 15 | twitterUsername 16 | isDevMember:isDeveloperProgramMember 17 | userId:databaseId 18 | pinnedItems:anyPinnableItems 19 | company 20 | status { 21 | gitEmoji:emoji 22 | lastUpdated:updatedAt 23 | message 24 | id 25 | expires:expiresAt 26 | } 27 | """ 28 | REPO = """ 29 | name 30 | id 31 | description 32 | homepageUrl 33 | isEmpty 34 | isArchived 35 | isDisabled 36 | isLocked 37 | stargazerCount 38 | isPrivate 39 | databaseId 40 | createdAt 41 | primaryLanguage { 42 | name 43 | } 44 | """ 45 | query_website = "https://docs.github.com/en/graphql/reference/queries" # For reference. 46 | 47 | class ArgumentError(Exception): 48 | pass 49 | class QueryFailError(Exception): 50 | pass 51 | 52 | 53 | class asdf: 54 | # run a request from the github api 55 | def run_query(query, token): 56 | try: 57 | headers = {"Authorization": f'Bearer {token}'} 58 | except: 59 | raise ArgumentError("Token has not been named by token function!") 60 | request = requests.post(url, json={'query': query}, headers=headers) 61 | if request.status_code == 200: 62 | return json.dumps(request.json(), indent=2, sort_keys=True) 63 | else: # the request failed 64 | raise QueryFailError("Query failed to run by returning code of {}. {}".format(request.status_code, query)) 65 | 66 | # set the token 67 | def Token(TOKEN=None): 68 | global token 69 | if TOKEN is None: 70 | raise ArgumentError("TOKEN argument must be filled out!") 71 | else: 72 | token = TOKEN 73 | 74 | class User: 75 | def __init__(self, username): 76 | try: 77 | self.token = token 78 | # if user has not yet ran the token function 79 | except: 80 | raise ArgumentError("Token has not been named by token function!") 81 | self.user = username 82 | # create the query 83 | query = """ 84 | query UserData { 85 | user(login: \"""" + self.user + """\") { 86 | """+USER+""" 87 | } 88 | } 89 | """ 90 | self.query = query 91 | 92 | # if the username is none 93 | if self.user is None: 94 | raise ArgumentError("Username argument must be filled out!") 95 | 96 | self.runQ = asdf.run_query 97 | 98 | # actually run the request 99 | def User(self): 100 | self.userf = self.runQ(self.query, self.token) 101 | return self.userf 102 | 103 | # edit the query - returns github nickname 104 | def Name(self): 105 | query = """ 106 | query UserData { 107 | user(login: \"""" + self.user + """\") { 108 | name 109 | } 110 | } 111 | """ 112 | self.name = self.runQ(query, self.token) 113 | return self.name 114 | 115 | # same thing as above, just for github bio 116 | def Bio(self): 117 | query = """ 118 | query UserData { 119 | user(login: \"""" + self.user + """\") { 120 | bio 121 | } 122 | } 123 | """ 124 | self.bio = self.runQ(query, self.token) 125 | return self.bio 126 | 127 | def Email(self): 128 | query = """ 129 | query UserData { 130 | user(login: \"""" + self.user + """\") { 131 | email 132 | } 133 | } 134 | """ 135 | self.email = self.runQ(query, self.token) 136 | data2 = "" + str(self.email) 137 | data = json.loads(data2) 138 | if (data["data"]["user"]["email"] == "" 139 | or data["data"]["user"]["email"] is None): 140 | return("No email exists or is private!") 141 | else: 142 | return self.email 143 | 144 | def Avatar(self): 145 | query = """ 146 | query UserData { 147 | user(login: \"""" + self.user + """\") { 148 | avatarLink:avatarUrl 149 | } 150 | } 151 | """ 152 | self.avatar = self.runQ(query, self.token) 153 | return self.avatar 154 | 155 | def Account(self): 156 | query = """ 157 | query UserData { 158 | user(login: \"""" + self.user + """\") { 159 | accountCreatedAt:createdAt 160 | } 161 | } 162 | """ 163 | self.account = self.runQ(query, self.token) 164 | return self.account 165 | 166 | def Admin(self): 167 | query = """ 168 | query UserData { 169 | user(login: \"""" + self.user + """\") { 170 | isAdmin:isSiteAdmin 171 | } 172 | } 173 | """ 174 | self.admin = self.runQ(query, self.token) 175 | return self.admin 176 | 177 | def Location(self): 178 | query = """ 179 | query UserData { 180 | user(login: \"""" + self.user + """\") { 181 | location 182 | } 183 | } 184 | """ 185 | self.location = self.runQ(query, self.token) 186 | return self.location 187 | 188 | def Twitter(self): 189 | query = """ 190 | query UserData { 191 | user(login: \"""" + self.user + """\") { 192 | twitterUsername 193 | } 194 | } 195 | """ 196 | self.twitter = self.runQ(query, self.token) 197 | return self.twitter 198 | 199 | def Developer(self): 200 | query = """ 201 | query UserData { 202 | user(login: \"""" + self.user + """\") { 203 | isDevMember:isDeveloperProgramMember 204 | } 205 | } 206 | """ 207 | self.dev = self.runQ(query, self.token) 208 | return self.dev 209 | 210 | def Userid(self): 211 | query = """ 212 | query UserData { 213 | user(login: \"""" + self.user + """\") { 214 | userId:databaseId 215 | } 216 | } 217 | """ 218 | self.userid = self.runQ(query, self.token) 219 | return self.userid 220 | 221 | def PinnedItems(self): 222 | query = """ 223 | query UserData { 224 | user(login: \"""" + self.user + """\") { 225 | pinnedItems:anyPinnableItems 226 | } 227 | } 228 | """ 229 | self.pinneditems = self.runQ(query, self.token) 230 | return self.pinneditems 231 | 232 | def Company(self): 233 | query = """ 234 | query UserData { 235 | user(login: \"""" + self.user + """\") { 236 | company 237 | } 238 | } 239 | """ 240 | self.company = self.runQ(query, self.token) 241 | return self.company 242 | 243 | 244 | 245 | class UserFollower: 246 | def __init__(self, username, followercount): 247 | try: 248 | self.token = token 249 | # if user has not yet ran the token function 250 | except: 251 | raise ArgumentError("Token has not been named by token function!") 252 | self.user = username 253 | self.userfollower = followercount 254 | # self.userfollowing = followingcount 255 | # create the query 256 | 257 | query = """ 258 | query UserFollowerData { 259 | user(login: \"""" + self.user + """\") { 260 | followers(first: """+followercount+""") { 261 | users: nodes { 262 | name: login 263 | } 264 | } 265 | } 266 | } 267 | """ 268 | self.query = query 269 | 270 | # if the username is none 271 | if self.user is None: 272 | raise ArgumentError("Username argument must be filled out!") 273 | if self.userfollower is None: 274 | raise ArgumentError("Userfollower argument must be filled out!") 275 | 276 | self.runQ = asdf.run_query 277 | 278 | def Followers(self): 279 | self.userfollower2 = self.runQ(self.query, self.token) 280 | return self.userfollower2 281 | 282 | 283 | 284 | 285 | class UserFollowing: 286 | def __init__(self, username, followingcount): 287 | try: 288 | self.token = token 289 | # if user has not yet ran the token function 290 | except: 291 | raise ArgumentError("Token has not been named by token function!") 292 | self.user = username 293 | # self.userfollower = followercount 294 | self.userfollowing = followingcount 295 | # create the query 296 | 297 | query = """ 298 | query UserFolloweringData { 299 | user(login: \"""" + self.user + """\") { 300 | following(first: """+followingcount+""") { 301 | users: nodes { 302 | name:login 303 | } 304 | } 305 | } 306 | } 307 | """ 308 | self.query = query 309 | 310 | # if the username is none 311 | if self.user is None: 312 | raise ArgumentError("Username argument must be filled out!") 313 | if self.userfollowing is None: 314 | raise ArgumentError("Userfollowing argument must be filled out!") 315 | 316 | self.runQ = asdf.run_query 317 | 318 | def Following(self): 319 | self.userfollowing2 = self.runQ(self.query, self.token) 320 | return self.userfollowing2 321 | 322 | 323 | 324 | 325 | class GitHub: 326 | def __init__(self, username): 327 | self.user = username 328 | def Status(): 329 | url = "https://github.com" 330 | res = requests.get(url) 331 | return res.status_code 332 | 333 | '''def Search(topic): 334 | query = """ 335 | query SearchData { 336 | user(login: \"""" + self.user + """\") { 337 | 338 | } 339 | } 340 | """''' 341 | 342 | 343 | 344 | class Repo: 345 | def __init__(self, owner, reponame): 346 | try: 347 | self.token = token 348 | # if user has not yet ran the token function 349 | except: 350 | raise ArgumentError("Token has not been named by token function!") 351 | 352 | self.reponame = reponame 353 | self.owner = owner 354 | 355 | if self.reponame is None: 356 | raise ArgumentError("Reponame argument must be filled out!") 357 | 358 | if self.owner is None: 359 | raise ArgumentError("Owner argument must be filled out!") 360 | 361 | self.runQ = asdf.run_query 362 | 363 | 364 | def Repo(self): 365 | query = """ 366 | query RepoData { 367 | repository(name: \""""+self.reponame+"""\" owner: \""""+self.owner+"""\") { 368 | """+REPO+""" 369 | } 370 | } 371 | """ 372 | 373 | self.repo = self.runQ(query, self.token) 374 | return self.repo 375 | 376 | def CreatedAt(self): 377 | query = """ 378 | query RepoData { 379 | repository(name: \""""+self.reponame+"""\" owner: \""""+self.owner+"""\") { 380 | createdAt 381 | } 382 | } 383 | """ 384 | 385 | self.createdAt = self.runQ(query, self.token) 386 | return self.createdAt 387 | 388 | def Databaseid(self): 389 | query = """ 390 | query RepoData { 391 | repository(name: \""""+self.reponame+"""\" owner: \""""+self.owner+"""\") { 392 | databaseId 393 | } 394 | } 395 | """ 396 | 397 | self.dbId = self.runQ(query, self.token) 398 | return self.dbId 399 | 400 | def Description(self): 401 | query = """ 402 | query RepoData { 403 | repository(name: \""""+self.reponame+"""\" owner: \""""+self.owner+"""\") { 404 | description 405 | } 406 | } 407 | """ 408 | 409 | self.repoDescription = self.runQ(query, self.token) 410 | return self.repoDescription 411 | 412 | def Homepageurl(self): 413 | query = """ 414 | query RepoData { 415 | repository(name: \""""+self.reponame+"""\" owner: \""""+self.owner+"""\") { 416 | homepageUrl 417 | } 418 | } 419 | """ 420 | self.homepageUrl = self.runQ(query, self.token) 421 | data2 = "" + str(self.homepageUrl) 422 | data = json.loads(data2) 423 | if (data["data"]["repository"]["homepageUrl"] == "" 424 | or data["data"]["repository"]["homepageUrl"] is None): 425 | return("No url exists or is private!") 426 | else: 427 | return self.homepageUrl 428 | 429 | def Id(self): 430 | query = """ 431 | query RepoData { 432 | repository(name: \""""+self.reponame+"""\" owner: \""""+self.owner+"""\") { 433 | id 434 | } 435 | } 436 | """ 437 | 438 | self.repoId = self.runQ(query, self.token) 439 | return self.repoId 440 | 441 | def IsArchived(self): 442 | query = """ 443 | query RepoData { 444 | repository(name: \""""+self.reponame+"""\" owner: \""""+self.owner+"""\") { 445 | isArchived 446 | } 447 | } 448 | """ 449 | 450 | self.repoIsArchived = self.runQ(query, self.token) 451 | return self.repoIsArchived 452 | 453 | def IsDisabled(self): 454 | query = """ 455 | query RepoData { 456 | repository(name: \""""+self.reponame+"""\" owner: \""""+self.owner+"""\") { 457 | isDisabled 458 | } 459 | } 460 | """ 461 | 462 | self.repoIsDisabled = self.runQ(query, self.token) 463 | return self.repoIsDisabled 464 | 465 | def IsEmpty(self): 466 | query = """ 467 | query RepoData { 468 | repository(name: \""""+self.reponame+"""\" owner: \""""+self.owner+"""\") { 469 | isEmpty 470 | } 471 | } 472 | """ 473 | 474 | self.repoIsEmpty = self.runQ(query, self.token) 475 | return self.repoIsEmpty 476 | 477 | def IsLocked(self): 478 | query = """ 479 | query RepoData { 480 | repository(name: \""""+self.reponame+"""\" owner: \""""+self.owner+"""\") { 481 | isLocked 482 | } 483 | } 484 | """ 485 | 486 | self.repoIsLocked = self.runQ(query, self.token) 487 | return self.repoIsLocked 488 | 489 | def IsPrivate(self): 490 | query = """ 491 | query RepoData { 492 | repository(name: \""""+self.reponame+"""\" owner: \""""+self.owner+"""\") { 493 | isPrivate 494 | } 495 | } 496 | """ 497 | 498 | self.repoIsPrivate = self.runQ(query, self.token) 499 | return self.repoIsPrivate 500 | 501 | def Name(self): 502 | query = """ 503 | query RepoData { 504 | repository(name: \""""+self.reponame+"""\" owner: \""""+self.owner+"""\") { 505 | name 506 | } 507 | } 508 | """ 509 | 510 | self.repoName = self.runQ(query, self.token) 511 | return self.repoName 512 | 513 | def Language(self): 514 | query = """ 515 | query RepoData { 516 | repository(name: \""""+self.reponame+"""\" owner: \""""+self.owner+"""\") { 517 | primaryLanguage { 518 | name 519 | } 520 | } 521 | } 522 | """ 523 | 524 | self.repoLanguage = self.runQ(query, self.token) 525 | return self.repoLanguage 526 | 527 | def Stars(self): 528 | query = """ 529 | query RepoData { 530 | repository(name: \""""+self.reponame+"""\" owner: \""""+self.owner+"""\") { 531 | stargazerCount 532 | } 533 | } 534 | """ 535 | 536 | self.repoStars = self.runQ(query, self.token) 537 | return self.repoStars 538 | 539 | # Remove this when uploading to PyPi 540 | # Token(os.environ["token"]) 541 | # print(User("JBYT27").User()) 542 | # print(User("JBYT27").Email()) 543 | # print(GitHub.Status()) 544 | # print(Repo("JBYT27", "GitAPI").Repo()) 545 | # print(UserFollowing("JBYT27", "10").Following()) -------------------------------------------------------------------------------- /src/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | 4 | with open("README.md", "r") as fh: 5 | long_description = fh.read() 6 | 7 | setup( 8 | name = "git_api", 9 | version = "1.7.5", 10 | description = "A GitHub API. Extracts data from GitHub into json style data.", 11 | long_description = long_description, 12 | long_description_content_type = "text/markdown", 13 | url = "https://github.com/JBYT27/Git-API", 14 | author = "JBYT27", 15 | author_email = "beol0127@gmail.com", 16 | license = "MIT", 17 | packages=['git_api'], 18 | classifiers = [ 19 | "Programming Language :: Python :: 3", 20 | "License :: OSI Approved :: MIT License", 21 | "Operating System :: OS Independent", 22 | ], 23 | zip_safe=True, 24 | python_requires = ">=3.6", 25 | ) 26 | --------------------------------------------------------------------------------