-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_issue_list.py
47 lines (41 loc) · 1.27 KB
/
get_issue_list.py
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
import requests
# Replace with your GitHub Personal Access Token and repository details
ACCESS_TOKEN = "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"
REPO_OWNER = "RhoderickGalero"
REPO_NAME = "Practice"
def get_repository_issues():
url = "https://api.github.com/graphql"
headers = {
"Authorization": f"Bearer {ACCESS_TOKEN}"
}
query = """
{
repository(owner: "%s", name: "%s") {
issues(first: 10) {
nodes {
title
state
createdAt
}
}
}
}
""" % (REPO_OWNER, REPO_NAME)
response = requests.post(url, json={"query": query}, headers=headers)
if response.status_code == 200:
data = response.json()
print(data)
issues = data["data"]["repository"]["issues"]["nodes"]
print (issues)
return issues
else:
print("Failed to retrieve issues:", response.text)
return None
if __name__ == "__main__":
issues = get_repository_issues()
if issues:
for issue in issues:
title = issue["title"]
state = issue["state"]
created_at = issue["createdAt"]
print(f"Title: {title}\nState: {state}\nCreated At: {created_at}\n")