Skip to content

Fetch Github contributions

dayplot provides a simple function to fetch Github contributions data from a given Github username.


dayplot.fetch_github_contrib(username, github_token, start_date, end_date)

Fetches GitHub contributions for a given user and date range. It requires requests and pandas to be installed.

Parameters
  • username: GitHub username.

  • github_token: Personal access token for GitHub API. Find yours here.

  • start_date: Start date in ISO 8601 format (e.g. "2024-01-01T00:00:00Z").

  • end_date: End date in ISO 8601 format (e.g. "2024-12-31T23:59:59Z").

Returns

Pandas DataFrame with dates and contribution counts.

Example
import dayplot as dp
from dotenv import load_dotenv
import os

# generate a token: https://github.com/settings/tokens
load_dotenv()
token = os.getenv("GITHUB_TOKEN")

start_date_iso = "2024-01-01T00:00:00Z"
end_date_iso = "2024-12-31T23:59:59Z"

my_data = fetch_github_contrib(
    username="JosephBARBIERDARNAL",
    github_token=token,
    start_date=start_date_iso,
    end_date=end_date_iso,
)

my_data.head() # it's a pandas dataframe