Redundant to: https://stackoverflow.com/questions/65152446/cannot-get-download-count-or-any-assets-from-assets-list-in-github-api-for-a
I want to count the downloads for a release on a public repo. The documentation at https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#list-release-assets
indicates that the assets request below should have a variable "download_count:"
.
This is what I get for my small public test repo in a newly created test organization with 2 known downloads for the release v1.0:
curl https://api.github.com/repos/test10010000/countMyReleases/releases/tags/v1.0
The response is:
"url": "https://api.github.com/repos/test10010000/countMyReleases/releases/34859773",
"assets_url": "https://api.github.com/repos/test10010000/countMyReleases/releases/34859773/assets",
"upload_url": "https://uploads.github.com/repos/test10010000/countMyReleases/releases/34859773/assets{?name,label}",
"html_url": "https://github.com/test10010000/countMyReleases/releases/tag/v1.0",
"id": 34859773,
"author": {
"login": "breckbaldwin",
"id": 6377185,
"node_id": "MDQ6VXNlcjYzNzcxODU=",
"avatar_url": "https://avatars2.githubusercontent.com/u/6377185?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/breckbaldwin",
"html_url": "https://github.com/breckbaldwin",
"followers_url": "https://api.github.com/users/breckbaldwin/followers",
"following_url": "https://api.github.com/users/breckbaldwin/following{/other_user}",
"gists_url": "https://api.github.com/users/breckbaldwin/gists{/gist_id}",
"starred_url": "https://api.github.com/users/breckbaldwin/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/breckbaldwin/subscriptions",
"organizations_url": "https://api.github.com/users/breckbaldwin/orgs",
"repos_url": "https://api.github.com/users/breckbaldwin/repos",
"events_url": "https://api.github.com/users/breckbaldwin/events{/privacy}",
"received_events_url": "https://api.github.com/users/breckbaldwin/received_events",
"type": "User",
"site_admin": false
},
"node_id": "MDc6UmVsZWFzZTM0ODU5Nzcz",
"tag_name": "v1.0",
"target_commitish": "main",
"name": "Test Count Downloads",
"draft": false,
"prerelease": false,
"created_at": "2020-12-04T23:28:39Z",
"published_at": "2020-12-04T23:29:18Z",
"assets": [
],
"tarball_url": "https://api.github.com/repos/test10010000/countMyReleases/tarball/v1.0",
"zipball_url": "https://api.github.com/repos/test10010000/countMyReleases/zipball/v1.0",
"body": ""
}
So I am getting the data on the release, but note that the assets list is empty. I run the explicit request for the assets as indicated in the documentation (this url is also supplied in the return data above):
curl https://api.github.com/repos/test10010000/countMyReleases/releases/34859773/assets
This returns an empty list:
[
]
Adding in my authorization token and looking at return headers with -i as follows:
curl -i -u breckbaldwin:$github_token https://api.github.com/repos/test10010000/countMyReleases/releases/34859773/assets
I get:
HTTP/1.1 200 OK
Server: GitHub.com
Date: Fri, 04 Dec 2020 23:44:15 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 5
Status: 200 OK
Cache-Control: private, max-age=60, s-maxage=60
Vary: Accept, Authorization, Cookie, X-GitHub-OTP
ETag: "7ac3b1740ea68a78ed14bc8d160dae63ad1710fffb20a10910ae02fff4661e1d"
X-OAuth-Scopes: admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, repo, user, workflow, write:discussion, write:packages
X-Accepted-OAuth-Scopes: repo
X-GitHub-Media-Type: github.v3; format=json
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4990
X-RateLimit-Reset: 1607125659
X-RateLimit-Used: 10
Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset
Access-Control-Allow-Origin: *
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Frame-Options: deny
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
Content-Security-Policy: default-src 'none'
Vary: Accept-Encoding, Accept, X-Requested-With
X-GitHub-Request-Id: AE6A:5AF5:108649D:1BE42F1:5FCAC9CF
[
]
Still no "download_count:"
. I am expecting an assets list that looks like (from the documentation for a different repo):
[
{
"url": "https://api.github.com/repos/octocat/Hello-World/releases/assets/1",
"browser_download_url": "https://github.com/octocat/Hello-World/releases/download/v1.0.0/example.zip",
"id": 1,
"node_id": "MDEyOlJlbGVhc2VBc3NldDE=",
"name": "example.zip",
"label": "short description",
"state": "uploaded",
"content_type": "application/zip",
"size": 1024,
"download_count": 42,
"created_at": "2013-02-27T19:35:32Z",
"updated_at": "2013-02-27T19:35:32Z",
"uploader": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
}
}
]
Note the "download_count": 42,
which is the variable I am looking for.
Any help appreciated.
thanks
Breck