Skip to main content

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

PyPI version License: MIT Downloads LinkedIn

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

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

github_repo_lister-2025.9.131919.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

github_repo_lister-2025.9.131919-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file github_repo_lister-2025.9.131919.tar.gz.

File metadata

File hashes

Hashes for github_repo_lister-2025.9.131919.tar.gz
Algorithm Hash digest
SHA256 5d214e579baaadc6d921e3eb78b08a7dce4d2934b634e534ae50479776b0e4f0
MD5 35c81d4db17e70b519b79c09dd0d82b1
BLAKE2b-256 b5c175dc7559839bcece951cb8c904b32a3e9c0a65c0c065d565042d70ed8884

See more details on using hashes here.

File details

Details for the file github_repo_lister-2025.9.131919-py3-none-any.whl.

File metadata

File hashes

Hashes for github_repo_lister-2025.9.131919-py3-none-any.whl
Algorithm Hash digest
SHA256 0b4263cdd12749c4b3be8a22b25b3fe9f9297e913f07040f02a6a6b35f93d0ee
MD5 4ff69d821e3048c4d016c501aa624bbe
BLAKE2b-256 ae0d634330ed83eb2a91bef23443b8e49be0bc6191394f783c76cdfc7fd33ff0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page