-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathissues_api_request.py
More file actions
48 lines (34 loc) · 993 Bytes
/
issues_api_request.py
File metadata and controls
48 lines (34 loc) · 993 Bytes
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
39
40
41
42
43
44
45
46
47
48
import requests
import json
import sys
from time import sleep
"""
usage
python api_request.py <github-PAT-api-token>
"""
#items per request
items_per_request = 30
#number of closed PRs
closed_items = 12873
#url endpoint - I have picked out matplot lib
url_endpoint = "https://api.github.com/repos/matplotlib/matplotlib/issues?state=closed"
api_token = sys.argv[1]
headers = {'Authorization': 'token %s' % api_token}
total_payload = None
for i in range(1,650):
print(i)
if i == 1:
r = requests.get(url_endpoint, headers = headers)
else:
r = requests.get(url_endpoint + "&page=" + str(i), headers=headers)
#if total_payload is None:
# total_payload = r.json()
#else:
## total_payload = total_payload + r.json()
print(r)
with open('issues_api_request_'+ str(i) + '.json', 'a') as f:
json.dump(r.json(), f)
sleep(5)
#print(len(total_payload))
# with open('Closed_PRs.json', 'a') as f:
# json.dump(r.json(), f)