a simple python function that takes ENV var GITHUB_TOKEN, and name of a user gihub and return JSON of all repositories of that github user
Project description
github_repo_lister
A simple Python package to list public repositories for a given GitHub user.
Installation
To install github_repo_lister, use pip:
pip install github_repo_lister
Usage
The github_repo_lister package allows you to retrieve a list of public repositories for any GitHub user. For authenticated requests (which increases your rate limit), you can set the GITHUB_TOKEN environment variable with your GitHub Personal Access Token.
Basic Example
import os
from github_repo_lister import list_user_repositories
# Optionally, set your GitHub token as an environment variable
# os.environ["GITHUB_TOKEN"] = "YOUR_GITHUB_TOKEN"
# Example for a well-known user
username = "octocat"
repositories_json = list_user_repositories(username)
print(f"Repositories for {username}:")
print(repositories_json)
# Example for a user with no public repositories (or a non-existent user)
username_no_repos = "nonexistentuser12345"
repositories_json_empty = list_user_repositories(username_no_repos)
print(f"\nRepositories for {username_no_repos}:")
print(repositories_json_empty)
How it works
The list_user_repositories function takes a github_username as input. It checks for the GITHUB_TOKEN environment variable to use for authentication. It then constructs a URL for the GitHub API's user repositories endpoint and fetches the data. The function returns the repository information as a JSON string. If an error occurs or no repositories are found, it returns an empty JSON list ([]).
Note: The current implementation in the provided code simulates API responses to avoid making actual network calls. In a real-world scenario, you would uncomment and use the requests library part of the code.
Author
- Eugene Evstafev hi@eugene.plus - LinkedIn Profile
Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
License
github_repo_lister is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file github_repo_lister-2025.9.131919.tar.gz.
File metadata
- Download URL: github_repo_lister-2025.9.131919.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d214e579baaadc6d921e3eb78b08a7dce4d2934b634e534ae50479776b0e4f0
|
|
| MD5 |
35c81d4db17e70b519b79c09dd0d82b1
|
|
| BLAKE2b-256 |
b5c175dc7559839bcece951cb8c904b32a3e9c0a65c0c065d565042d70ed8884
|
File details
Details for the file github_repo_lister-2025.9.131919-py3-none-any.whl.
File metadata
- Download URL: github_repo_lister-2025.9.131919-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b4263cdd12749c4b3be8a22b25b3fe9f9297e913f07040f02a6a6b35f93d0ee
|
|
| MD5 |
4ff69d821e3048c4d016c501aa624bbe
|
|
| BLAKE2b-256 |
ae0d634330ed83eb2a91bef23443b8e49be0bc6191394f783c76cdfc7fd33ff0
|