I'm trying to pull the contributor stats from a public github repo. I followed every step mentioned in their documentation but I keep getting a 404 error. Does someone happen to know what the issue is?
This is my python script:
import requests
import json
url = "https://api.github.com/repos/OWNER/REPO/stats/contributors"
url = url.format(OWNER="cosmos", REPO="ibc-go")
headers = {
"Accept": "application/vnd.github json",
"Authorization": "Bearer <MY-TOKEN>",
"X-GitHub-Api-Version": "2022-11-28"
}
r = requests.get(url, headers=headers)
data = r.json()
print(r.status_code)
#print(data)
CodePudding user response:
change
url = "https://api.github.com/repos/OWNER/REPO/stats/contributors"
to
url = "https://api.github.com/repos/{OWNER}/{REPO}/stats/contributors"
as url.format
ir str.format
is not replacing the OWNER
AND REPO
in the url
string
CodePudding user response:
It worked for me when I made @sahasrara62's change and also commented out the "Authorization..." line (apparently it's not needed for this endpoint), the result looks like this:
[{'total': 1, 'weeks': [{'w': 1612656000, 'a': 0, 'd': 0, 'c': 0}, ....