Is anyone downloading my releases - GitHub API Cheat Sheet
I migrated a repository from SourceForge to GitHub and wanted to see how many downloads were being done from GitHub. SourceForge had a great UI for this. GitHub does not.
GitHub has a REST API that you have to script against that provides information about releases and artifacts.
Need
I wanted to find out the number of downloads for a given release in a specific repository.
GitHub API
GitHub API docs can be found here: https://developer.github.com/v3/ There is also v1, v2 APIs that in some cases are more different than evolutionary.
Releases
The releases of portion of their API https://developer.github.com/v3/repos/releases/ . There is a bunch of stuff to parse through.
All releases for a given repository
Releases Documentation
This API will show you show you all the releases for a given repository..
- https://api.github.com/repos/:owner/:repo/releases
Example
- Owner: freemansoft
- Repository: jacob-project
- https://api.github.com/repos/freemansoft/jacob-project/releases
You can see the release id at "id":
This is a subset of the returned data. The release "id" can be used to retrieve individual packages in this release. The following was returned by the GitHub API GET call above. Note the Name and id.
{ "url": "https://api.github.com/repos/freemansoft/jacob-project/releases/31804607", "assets_url": "https://api.github.com/repos/freemansoft/jacob-project/releases/31804607/assets", "upload_url": "https://uploads.github.com/repos/freemansoft/jacob-project/releases/31804607/assets{?name,label}", "html_url": "https://github.com/freemansoft/jacob-project/releases/tag/Root_B-1_20", "id": 31804607, "node_id": "MDc6UmVsZWFzZTMxODA0NjA3", "tag_name": "Root_B-1_20", "target_commitish": "master", "name": "Release 1.20", "draft": false,
Information about a single release
Now we know our release id. We can call the releases API to get the downloadable assets for that release.
Documentation
Each release has a unique id. I found the ID with the previous command. The API returns the name, size and number of downloads and other information about each one of the assets.
- https://api.github.com/repos/:owner/:repo/releases/:release_id
Example
- Owner: freemansoft
- Repository: jacob-project
- Release: 1.20 whose id is 31804607
- https://api.github.com/repos/freemansoft/jacob-project/releases/31804607
Sample output
This release has several downloadable files/bundles.
"prerelease": false,
"created_at": "2020-09-25T10:20:13Z",
"published_at": "2020-09-25T09:57:24Z",
"assets": [
{
"url": "https://api.github.com/repos/freemansoft/jacob-project/releases/assets/26181445",
"id": 26181445,
"node_id": "MDEyOlJlbGVhc2VBc3NldDI2MTgxNDQ1",
"name": "jacob-1.20.zip",
"label": null,
"uploader": {
"login": "freemansoft",
"id": 1217160,
"node_id": "MDQ6VXNlcjEyMTcxNjA=",
"avatar_url": "https://avatars1.githubusercontent.com/u/1217160?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/freemansoft",
"html_url": "https://github.com/freemansoft",
"followers_url": "https://api.github.com/users/freemansoft/followers",
"following_url": "https://api.github.com/users/freemansoft/following{/other_user}",
"gists_url": "https://api.github.com/users/freemansoft/gists{/gist_id}",
"starred_url": "https://api.github.com/users/freemansoft/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/freemansoft/subscriptions",
"organizations_url": "https://api.github.com/users/freemansoft/orgs",
"repos_url": "https://api.github.com/users/freemansoft/repos",
"events_url": "https://api.github.com/users/freemansoft/events{/privacy}",
"received_events_url": "https://api.github.com/users/freemansoft/received_events",
"type": "User",
"site_admin": false
},
"content_type": "application/x-zip-compressed",
"state": "uploaded",
"size": 506374,
"download_count": 41,
"created_at": "2020-09-25T10:22:34Z",
"updated_at": "2020-09-25T10:22:34Z",
"browser_download_url": "https://github.com/freemansoft/jacob-project/releases/download/Root_B-1_20/jacob-1.20.zip"
},
{
"url": "https://api.github.com/repos/freemansoft/jacob-project/releases/assets/26181444",
"id": 26181444,
"node_id": "MDEyOlJlbGVhc2VBc3NldDI2MTgxNDQ0",
"name": "jacob-1.20_src.zip",
"label": null,
"uploader": {
"login": "freemansoft",
"id": 1217160,
"node_id": "MDQ6VXNlcjEyMTcxNjA=",
"avatar_url": "https://avatars1.githubusercontent.com/u/1217160?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/freemansoft",
"html_url": "https://github.com/freemansoft",
"followers_url": "https://api.github.com/users/freemansoft/followers",
"following_url": "https://api.github.com/users/freemansoft/following{/other_user}",
"gists_url": "https://api.github.com/users/freemansoft/gists{/gist_id}",
"starred_url": "https://api.github.com/users/freemansoft/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/freemansoft/subscriptions",
"organizations_url": "https://api.github.com/users/freemansoft/orgs",
"repos_url": "https://api.github.com/users/freemansoft/repos",
"events_url": "https://api.github.com/users/freemansoft/events{/privacy}",
"received_events_url": "https://api.github.com/users/freemansoft/received_events",
"type": "User",
"site_admin": false
},
"content_type": "application/x-zip-compressed",
"state": "uploaded",
"size": 822795,
"download_count": 8,
"created_at": "2020-09-25T10:22:33Z",
"updated_at": "2020-09-25T10:22:34Z",
"browser_download_url": "https://github.com/freemansoft/jacob-project/releases/download/Root_B-1_20/jacob-1.20_src.zip"
},
{
"url": "https://api.github.com/repos/freemansoft/jacob-project/releases/assets/26181460",
"id": 26181460,
"node_id": "MDEyOlJlbGVhc2VBc3NldDI2MTgxNDYw",
"name": "README.md",
"label": null,
"uploader": {
"login": "freemansoft",
"id": 1217160,
"node_id": "MDQ6VXNlcjEyMTcxNjA=",
"avatar_url": "https://avatars1.githubusercontent.com/u/1217160?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/freemansoft",
"html_url": "https://github.com/freemansoft",
"followers_url": "https://api.github.com/users/freemansoft/followers",
"following_url": "https://api.github.com/users/freemansoft/following{/other_user}",
"gists_url": "https://api.github.com/users/freemansoft/gists{/gist_id}",
"starred_url": "https://api.github.com/users/freemansoft/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/freemansoft/subscriptions",
"organizations_url": "https://api.github.com/users/freemansoft/orgs",
"repos_url": "https://api.github.com/users/freemansoft/repos",
"events_url": "https://api.github.com/users/freemansoft/events{/privacy}",
"received_events_url": "https://api.github.com/users/freemansoft/received_events",
"type": "User",
"site_admin": false
},
"content_type": "application/octet-stream",
"state": "uploaded",
"size": 2617,
"download_count": 4,
"created_at": "2020-09-25T10:22:57Z",
"updated_at": "2020-09-25T10:22:57Z",
"browser_download_url": "https://github.com/freemansoft/jacob-project/releases/download/Root_B-1_20/README.md"
}
],
"tarball_url": "https://api.github.com/repos/freemansoft/jacob-project/tarball/Root_B-1_20",
"zipball_url": "https://api.github.com/repos/freemansoft/jacob-project/zipball/Root_B-1_20",
"body": "### What's New\r\n* Upgraded from VS2015 to VS 2019\r\n* Move from Sourceforge to GitHub\r\n* Updated Junit jars\r\n* VT_DATE and SafeArray\r\n### Tracked Changes\r\n| Item | Description |\r\n|-|-|\r\n| **Bugs** | |\r\n| | none |\r\n| **Patches** | |\r\n| 48 | Update to VS2019 Community and Windows 10 libs |\r\n| 1 | Support VT_DATE getting from SafeArray |\r\n| **Feature Requests** | |\r\n| | none |\r\n"
}
Future
This could use some kind of script that gathers all this information into a usable form.
Disclaimer
May not be of general interest. Is not complete.
Created 2020/10
Comments
Post a Comment