Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion credentials.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"username": <USERNAME>,
"password": <PASSWORD>
"password": <GITHUB PERSONAL TOKEN>
}
28 changes: 23 additions & 5 deletions get_github_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@
from requests.auth import HTTPBasicAuth

credentials = json.loads(open('credentials.json').read())
authentication = HTTPBasicAuth(credentials['username'], credentials['password'])

data = requests.get('https://api.github.com/users/' + credentials['username'], auth = authentication)
data = requests.get('https://api.github.com/users/' + credentials['username'],
headers={
"X-GitHub-Api-Version": "2022-11-28",
"Accept": "application/vnd.github+json",
"Authorization": "Bearer " + credentials['password']
})
data = data.json()

print(data)

print("Information about user {}:\n".format(credentials['username']))
print("Name: {}".format(data['name']))
print("Email: {}".format(data['email']))
Expand All @@ -25,7 +31,11 @@
page_no = 1
repos_data = []
while (True):
response = requests.get(url, auth = authentication)
response = requests.get(url, headers={
"X-GitHub-Api-Version": "2022-11-28",
"Accept": "application/vnd.github+json",
"Authorization": "Bearer " + credentials['password']
})
response = response.json()
repos_data = repos_data + response
repos_fetched = len(response)
Expand Down Expand Up @@ -64,7 +74,11 @@

print("Collecting language data")
for i in range(repos_df.shape[0]):
response = requests.get(repos_df.loc[i, 'Languages URL'], auth = authentication)
response = requests.get(repos_df.loc[i, 'Languages URL'], headers={
"X-GitHub-Api-Version": "2022-11-28",
"Accept": "application/vnd.github+json",
"Authorization": "Bearer " + credentials['password']
})
response = response.json()
if response != {}:
languages = []
Expand All @@ -84,7 +98,11 @@
url = repos_df.loc[i, 'Commits URL']
page_no = 1
while (True):
response = requests.get(url, auth = authentication)
response = requests.get(url, headers={
"X-GitHub-Api-Version": "2022-11-28",
"Accept": "application/vnd.github+json",
"Authorization": "Bearer " + credentials['password']
})
response = response.json()
print("URL: {}, commits: {}".format(url, len(response)))
for commit in response:
Expand Down