Skip to content

Commit bd0d206

Browse files
committed
First commit, starting retrieval of data.
0 parents  commit bd0d206

File tree

3 files changed

+320
-0
lines changed

3 files changed

+320
-0
lines changed

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
3+
4+
5+
# py cache
6+
__pycache__
7+
8+
9+
10+
# ipynb checkpoints
11+
.ipynb_checkpoints/
12+
*ipynb_checkpoints
13+
.ipynbc-checkpoints*
14+
15+

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# README
2+
3+
This project will be focused on collecting data from GitHub API v3. The intention is to create a follower/following network starting off with a specific point of origin. This will be similar to my Youtube Network Analysis repo, except focused on GitHub users. Unlike YouTube, GitHub provides both following and followers. In comparison, YouTube only provides Featured Channels, which can somewhat be considered a channels list of channels that they are "following".
4+
5+
Since an individuals personal GitHub does not encompass all of a developers contributions, this isn't intended for any rigorous analysis of the GitHub community. It's simply a means to explore users and potentially find distinct communities or fellow users with similar content or interests.

retrieving_data.ipynb

+300
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,300 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Retrieving data from GitHub API v3"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": 15,
13+
"metadata": {},
14+
"outputs": [],
15+
"source": [
16+
"import pandas as pd\n",
17+
"import requests\n",
18+
"import json"
19+
]
20+
},
21+
{
22+
"cell_type": "markdown",
23+
"metadata": {},
24+
"source": [
25+
"Handful of functions to retrieve data?"
26+
]
27+
},
28+
{
29+
"cell_type": "code",
30+
"execution_count": 57,
31+
"metadata": {},
32+
"outputs": [],
33+
"source": [
34+
"def github_request_user(user):\n",
35+
" ''' Function to retrieve user details'''\n",
36+
" \n",
37+
" # url for get request \n",
38+
" url = f'https://api.github.com/users/{user}'\n",
39+
" \n",
40+
" # make the get request\n",
41+
" r = requests.get(url)\n",
42+
" \n",
43+
" # unpack and return\n",
44+
" return json.loads(r.content)"
45+
]
46+
},
47+
{
48+
"cell_type": "code",
49+
"execution_count": 58,
50+
"metadata": {},
51+
"outputs": [],
52+
"source": [
53+
"def github_request_following(user):\n",
54+
" # url for get request \n",
55+
" url = f'https://api.github.com/users/{user}/following'\n",
56+
" \n",
57+
" # make the get request\n",
58+
" r = requests.get(url)\n",
59+
" \n",
60+
" # unpack and return\n",
61+
" return json.loads(r.content)"
62+
]
63+
},
64+
{
65+
"cell_type": "code",
66+
"execution_count": 64,
67+
"metadata": {},
68+
"outputs": [
69+
{
70+
"data": {
71+
"text/plain": [
72+
"{'login': 'DanOvad',\n",
73+
" 'id': 15237503,\n",
74+
" 'node_id': 'MDQ6VXNlcjE1MjM3NTAz',\n",
75+
" 'avatar_url': 'https://avatars3.githubusercontent.com/u/15237503?v=4',\n",
76+
" 'gravatar_id': '',\n",
77+
" 'url': 'https://api.github.com/users/DanOvad',\n",
78+
" 'html_url': 'https://github.com/DanOvad',\n",
79+
" 'followers_url': 'https://api.github.com/users/DanOvad/followers',\n",
80+
" 'following_url': 'https://api.github.com/users/DanOvad/following{/other_user}',\n",
81+
" 'gists_url': 'https://api.github.com/users/DanOvad/gists{/gist_id}',\n",
82+
" 'starred_url': 'https://api.github.com/users/DanOvad/starred{/owner}{/repo}',\n",
83+
" 'subscriptions_url': 'https://api.github.com/users/DanOvad/subscriptions',\n",
84+
" 'organizations_url': 'https://api.github.com/users/DanOvad/orgs',\n",
85+
" 'repos_url': 'https://api.github.com/users/DanOvad/repos',\n",
86+
" 'events_url': 'https://api.github.com/users/DanOvad/events{/privacy}',\n",
87+
" 'received_events_url': 'https://api.github.com/users/DanOvad/received_events',\n",
88+
" 'type': 'User',\n",
89+
" 'site_admin': False,\n",
90+
" 'name': 'Dan Ovadia',\n",
91+
" 'company': None,\n",
92+
" 'blog': 'linkedin.com/in/dan-ovadia',\n",
93+
" 'location': None,\n",
94+
" 'email': None,\n",
95+
" 'hireable': None,\n",
96+
" 'bio': 'Data Scientist/Engineer; Python, R, SQL, GCP; Worked in P&C Insurance as a Risk Analyst, Software Engineer, and Data Engineer; Hobbyist and data explorer.',\n",
97+
" 'twitter_username': None,\n",
98+
" 'public_repos': 15,\n",
99+
" 'public_gists': 0,\n",
100+
" 'followers': 3,\n",
101+
" 'following': 5,\n",
102+
" 'created_at': '2015-10-21T19:34:15Z',\n",
103+
" 'updated_at': '2020-09-06T17:38:33Z',\n",
104+
" 'following_users': ['yovadia',\n",
105+
" 'cooperdramsey',\n",
106+
" 'aailani',\n",
107+
" 'Wsauder',\n",
108+
" 'sjhawkes']}"
109+
]
110+
},
111+
"execution_count": 64,
112+
"metadata": {},
113+
"output_type": "execute_result"
114+
}
115+
],
116+
"source": [
117+
"following_list = github_request_following('danovad')\n",
118+
"following_users = [user['login'] for user in following_list]\n",
119+
"\n",
120+
"user_dict = github_request('danovad')\n",
121+
"user_dict['following_users'] = following_users\n",
122+
"user_dict"
123+
]
124+
},
125+
{
126+
"cell_type": "code",
127+
"execution_count": 65,
128+
"metadata": {},
129+
"outputs": [
130+
{
131+
"data": {
132+
"text/plain": [
133+
"'https://api.github.com/users/DanOvad/starred{/owner}{/repo}'"
134+
]
135+
},
136+
"execution_count": 65,
137+
"metadata": {},
138+
"output_type": "execute_result"
139+
}
140+
],
141+
"source": [
142+
"user_dict['starred_url']"
143+
]
144+
},
145+
{
146+
"cell_type": "code",
147+
"execution_count": 61,
148+
"metadata": {},
149+
"outputs": [],
150+
"source": [
151+
"user_dict['following_users']"
152+
]
153+
},
154+
{
155+
"cell_type": "code",
156+
"execution_count": 62,
157+
"metadata": {},
158+
"outputs": [
159+
{
160+
"data": {
161+
"text/plain": [
162+
"{'danovad': ['yovadia', 'cooperdramsey', 'aailani', 'Wsauder', 'sjhawkes']}"
163+
]
164+
},
165+
"execution_count": 62,
166+
"metadata": {},
167+
"output_type": "execute_result"
168+
}
169+
],
170+
"source": [
171+
"following_dict"
172+
]
173+
},
174+
{
175+
"cell_type": "code",
176+
"execution_count": null,
177+
"metadata": {},
178+
"outputs": [],
179+
"source": [
180+
"user: {list of users pointed to}, "
181+
]
182+
},
183+
{
184+
"cell_type": "code",
185+
"execution_count": 49,
186+
"metadata": {},
187+
"outputs": [
188+
{
189+
"data": {
190+
"text/plain": [
191+
"{'login': 'Wsauder',\n",
192+
" 'id': 34780071,\n",
193+
" 'node_id': 'MDQ6VXNlcjM0NzgwMDcx',\n",
194+
" 'avatar_url': 'https://avatars3.githubusercontent.com/u/34780071?v=4',\n",
195+
" 'gravatar_id': '',\n",
196+
" 'url': 'https://api.github.com/users/Wsauder',\n",
197+
" 'html_url': 'https://github.com/Wsauder',\n",
198+
" 'followers_url': 'https://api.github.com/users/Wsauder/followers',\n",
199+
" 'following_url': 'https://api.github.com/users/Wsauder/following{/other_user}',\n",
200+
" 'gists_url': 'https://api.github.com/users/Wsauder/gists{/gist_id}',\n",
201+
" 'starred_url': 'https://api.github.com/users/Wsauder/starred{/owner}{/repo}',\n",
202+
" 'subscriptions_url': 'https://api.github.com/users/Wsauder/subscriptions',\n",
203+
" 'organizations_url': 'https://api.github.com/users/Wsauder/orgs',\n",
204+
" 'repos_url': 'https://api.github.com/users/Wsauder/repos',\n",
205+
" 'events_url': 'https://api.github.com/users/Wsauder/events{/privacy}',\n",
206+
" 'received_events_url': 'https://api.github.com/users/Wsauder/received_events',\n",
207+
" 'type': 'User',\n",
208+
" 'site_admin': False}"
209+
]
210+
},
211+
"execution_count": 49,
212+
"metadata": {},
213+
"output_type": "execute_result"
214+
}
215+
],
216+
"source": [
217+
"following_list[3]"
218+
]
219+
},
220+
{
221+
"cell_type": "code",
222+
"execution_count": 40,
223+
"metadata": {},
224+
"outputs": [
225+
{
226+
"data": {
227+
"text/plain": [
228+
"{'login': 'DanOvad',\n",
229+
" 'id': 15237503,\n",
230+
" 'node_id': 'MDQ6VXNlcjE1MjM3NTAz',\n",
231+
" 'avatar_url': 'https://avatars3.githubusercontent.com/u/15237503?v=4',\n",
232+
" 'gravatar_id': '',\n",
233+
" 'url': 'https://api.github.com/users/DanOvad',\n",
234+
" 'html_url': 'https://github.com/DanOvad',\n",
235+
" 'followers_url': 'https://api.github.com/users/DanOvad/followers',\n",
236+
" 'following_url': 'https://api.github.com/users/DanOvad/following{/other_user}',\n",
237+
" 'gists_url': 'https://api.github.com/users/DanOvad/gists{/gist_id}',\n",
238+
" 'starred_url': 'https://api.github.com/users/DanOvad/starred{/owner}{/repo}',\n",
239+
" 'subscriptions_url': 'https://api.github.com/users/DanOvad/subscriptions',\n",
240+
" 'organizations_url': 'https://api.github.com/users/DanOvad/orgs',\n",
241+
" 'repos_url': 'https://api.github.com/users/DanOvad/repos',\n",
242+
" 'events_url': 'https://api.github.com/users/DanOvad/events{/privacy}',\n",
243+
" 'received_events_url': 'https://api.github.com/users/DanOvad/received_events',\n",
244+
" 'type': 'User',\n",
245+
" 'site_admin': False,\n",
246+
" 'name': 'Dan Ovadia',\n",
247+
" 'company': None,\n",
248+
" 'blog': 'linkedin.com/in/dan-ovadia',\n",
249+
" 'location': None,\n",
250+
" 'email': None,\n",
251+
" 'hireable': None,\n",
252+
" 'bio': 'Data Scientist/Engineer; Python, R, SQL, GCP; Worked in P&C Insurance as a Risk Analyst, Software Engineer, and Data Engineer; Hobbyist and data explorer.',\n",
253+
" 'twitter_username': None,\n",
254+
" 'public_repos': 15,\n",
255+
" 'public_gists': 0,\n",
256+
" 'followers': 3,\n",
257+
" 'following': 5,\n",
258+
" 'created_at': '2015-10-21T19:34:15Z',\n",
259+
" 'updated_at': '2020-09-06T17:38:33Z'}"
260+
]
261+
},
262+
"execution_count": 40,
263+
"metadata": {},
264+
"output_type": "execute_result"
265+
}
266+
],
267+
"source": [
268+
"following_list"
269+
]
270+
},
271+
{
272+
"cell_type": "code",
273+
"execution_count": null,
274+
"metadata": {},
275+
"outputs": [],
276+
"source": []
277+
}
278+
],
279+
"metadata": {
280+
"kernelspec": {
281+
"display_name": "Python 3",
282+
"language": "python",
283+
"name": "python3"
284+
},
285+
"language_info": {
286+
"codemirror_mode": {
287+
"name": "ipython",
288+
"version": 3
289+
},
290+
"file_extension": ".py",
291+
"mimetype": "text/x-python",
292+
"name": "python",
293+
"nbconvert_exporter": "python",
294+
"pygments_lexer": "ipython3",
295+
"version": "3.7.7"
296+
}
297+
},
298+
"nbformat": 4,
299+
"nbformat_minor": 4
300+
}

0 commit comments

Comments
 (0)