-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequest.py
More file actions
38 lines (28 loc) · 1.01 KB
/
Copy pathrequest.py
File metadata and controls
38 lines (28 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import requests
url_followers = 'https://api.github.com/users/{}/followers'
url_following = 'https://api.github.com/users/{}/following'
url_id = 'https://api.github.com/users/{}'
gh_session = requests.Session()
def init_session(github_username, github_token):
gh_session.auth = (github_username, github_token)
def get_user_followers(user):
rtn = gh_session.get(url=url_followers.format(user))
if rtn.status_code != 200:
print("Error! Status: " + str(rtn.status_code))
return
data = rtn.json()
return data
def get_user_following(user):
rtn = gh_session.get(url=url_following.format(user))
if rtn.status_code != 200:
print("Error! Status: " + str(rtn.status_code))
return
data = rtn.json()
return data
def get_user_id(user):
rtn = requests.get(url=url_id.format(user))
if rtn.status_code != 200:
print("Error! Status: " + str(rtn.status_code))
return
data = rtn.json()
return data['id']