Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
In [ ]:
import requests
token = "ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
def get_repos(token: str) -> requests.Response:
resp = requests.get(
url="https://api.github.com/orgs/legendu-net/repos?per_page=500",
headers={
"Accept": "application/vnd.github.v3+json",
"Authorization": f"token {token}",
},
)
return [repo["name"] for repo in resp.json()]
def get_branches(repo: str, token: str) -> requests.Response:
headers = {
"Accept": "application/vnd.github+json",
"Authorization": f"Bearer {token}",
"X-GitHub-Api-Version": "2022-11-28",
}
resp = requests.get(
f"https://api.github.com/repos/legendu-net/{repo}/branches", headers=headers
)
return [branch["name"] for branch in resp.json()]
In [2]:
repo_branches = {repo: get_branches(repo, token) for repo in get_repos(token)}
repo_branches
Out[2]:
In [3]:
for repo, branches in repo_branches.items():
if len(branches) > 2:
print(repo + ":", branches)