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, backend='pandas')
Fetches GitHub contributions for a given user and date range. It requires
requests
and pandas
to be installed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username
|
str
|
GitHub username. |
required |
github_token
|
str
|
Personal access token for GitHub API. Find yours here. |
required |
start_date
|
str
|
Start date in ISO 8601 format (e.g. "2024-01-01T00:00:00Z"). |
required |
end_date
|
str
|
End date in ISO 8601 format (e.g. "2024-12-31T23:59:59Z"). |
required |
backend
|
str
|
The output format of the dataframe. Note that, for example,
if you set |
'pandas'
|
Returns:
Type | Description |
---|---|
A DataFrame with dates and contribution counts. |
Examples
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,
backend="pandas"
)
my_data.head() # it's a pandas dataframe