Skip to content

Commit

Permalink
Adds script to count clones of the repo.
Browse files Browse the repository at this point in the history
  • Loading branch information
aliakatas committed Dec 29, 2024
1 parent c7a4e66 commit 92b8c64
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions parse_clones_count.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import requests
import os

# Replace with your credentials
GITHUB_TOKEN = os.getenv("GH_TOKEN")
if not GITHUB_TOKEN:
raise ValueError("GitHub token not found. Please set the GITHUB_TOKEN environment variable.")

OWNER = "aliakatas"
REPO = "cxx-utilities"

# API Endpoint
url = f"https://api.github.com/repos/{OWNER}/{REPO}/traffic/clones"
headers = {"Authorization": f"token {GITHUB_TOKEN}"}

response = requests.get(url, headers=headers)

if response.status_code == 200:
data = response.json()
print(data)
# print(f"Total Clones: {data['count']}")
# print(f"Unique Cloners: {data['uniques']}")
else:
print(f"Error: {response.status_code} - {response.text}")

0 comments on commit 92b8c64

Please sign in to comment.