ghprofile
A lightweight Python library for fetching and summarizing GitHub profile and repository data through a simple Python interface.
- Python
- GitHub API
- PyPI
install it, import it, query it
THE IDEA
THE IDEA.
ghprofile was created as a lightweight abstraction around GitHub profile information. Instead of repeatedly implementing API requests and profile parsing logic, the library provides a compact Python interface for retrieving common GitHub information.
It is not a web application - it is a Python package anyone can install and import. Where the CS50W projects put Django on a server, ghprofile puts a small library on your machine.
WHY A LIBRARY?
Turn the API into a tool.
The goal is to make GitHub profile and repository information easier to retrieve from Python through a simple, reusable library. Instead of exposing users directly to every API call, ghprofile provides methods such as:
get_bio()get_followers()get_repo()get_stars()get_pinned_repos()WHAT IT FETCHES
One profile. More signal.
Six facts about any GitHub user, through one small interface.
BIO
Bio
Retrieve a user's GitHub bio.
FOLLOWERS
Followers
Retrieve follower count.
FOLLOWING
Following
Retrieve following count.
REPOSITORIES
Repositories
List public repositories.
STARS
Stars
Calculate total stars across repositories.
PINNED
Pinned
Fetch pinned repositories.
FROM USERNAME TO DATA
From username to profile.
A username in, a Python object out - the whole point of the library.
- USERNAME
- GHPROFILE
- GITHUB DATA
- PYTHON OBJECT
- RESULT
gh = Ghprofile("octocat")
get_bio()
get_followers()
get_repo()
get_stars()
get_pinned_repos()
SIMPLE API
Simple by design.
The documented interface is intentionally small, named, and straightforward.
from ghprofile.core import Ghprofile
gh = Ghprofile("octocat", "your_github_token")
print(gh.get_bio())
print(gh.get_followers())
print(gh.get_repo())
print(gh.get_stars())
print(gh.get_pinned_repos())AUTHENTICATION
Token optional.
- Public data
- Lower API rate limit
- Simple setup
~60 API calls / hour - according to the project's documentation
- Higher API rate limit
- Private data access
- Token passed into Ghprofile
~5000 API calls / hour - according to the project's documentation
PINNED REPOSITORIES
The pinned part.
The library can fetch a GitHub user's pinned repositories. The project's documentation notes that pinned repositories are retrieved via scraping - not through an official GitHub API endpoint.
ERROR HANDLING
Fail loud. Fail cleanly.
Errors are wrapped under the custom GhprofileError class, so a failed API call raises a single, catchable exception instead of leaking raw API failures.
from ghprofile.core import GhprofileError
try:
gh = Ghprofile("unknownuser", "badtoken")
except GhprofileError as e:
print("Something went wrong:", e)UNDER THE HOOD
A small conceptual architecture.
The library sits between your Python application and GitHub.
PACKAGE STRUCTURE
A library you import.
The documented public surface - verified against the project's documentation.
ghprofile.coreThe documented public module - where Ghprofile and GhprofileError live.the import pathGhprofileThe main class. Pass a username (and optionally a token) to start querying.GhprofileErrorThe custom exception class wrapping failed API calls.CODE-FIRST
A tool you can import.
Install once, import anywhere - this is a Python package, not a web page.
pip install ghprofile
from ghprofile.core import Ghprofile
gh = Ghprofile("octocat")
gh.get_repo()CONTRIBUTING
Built to extend.
The project's documentation welcomes contributions - new features, improved error handling, test coverage, refactoring, and optimization. Ideas such as commit history and language breakdown appear there as possible future work, not as features that exist today.
LICENSE
OPEN SOURCE.
ghprofile is licensed under the MIT License according to the project documentation.
WHAT THIS PROJECT TAUGHT ME
From script to package.
This project demonstrates packaging Python functionality into a reusable library, designing a small public API, interacting with the GitHub API, handling API errors, working with rate limits, retrieving repository-level statistics, combining API access with scraping, and publishing a package to PyPI.
THE PYPI MOMENT
Published. Installable. Reusable.
A pip install away from any Python project.
$ pip install ghprofilePROJECT DETAILS
The essentials.
Want to see the code?
The whole library lives on GitHub - and you can install it from PyPI.
pip install ghprofile