Skip to content

Instantly share code, notes, and snippets.

@elijahbenizzy
Last active August 16, 2023 19:40
Show Gist options
  • Save elijahbenizzy/31f699a152e26847a94c25f1561a35f2 to your computer and use it in GitHub Desktop.
Save elijahbenizzy/31f699a152e26847a94c25f1561a35f2 to your computer and use it in GitHub Desktop.
def star_count(starcount_url: str, github_api_key: str) -> Tuple[str, int]:
"""Generates the star count for a given repo.
:param starcount_url: URL of the repo
:param github_api_key: API key for GitHub
:return: A tuple of the repo name and the star count
"""
response = requests.get(
starcount_url, headers={"Authorization": f"token {github_api_key}"}
)
response.raise_for_status() # Raise an exception for unsuccessful requests
data = response.json()
return data["full_name"], data["stargazers_count"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment