Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download count of GitHub release in R

I am trying to get the download count of a public repo using the GitHub API and R v3.1.2. Using the public samples repo from Google I have the following:

library(jsonlite)
library(httr)

url <- "https://api.github.com/repos/googlesamples/google-services/downloads"
response <- GET(url)
json <- content(response, "text")
json <- fromJSON(json)

print(json)

However, I noticed that json returns an empty list. Is it because there are no releases in this public repo? The goal is to determine how many times this repo has been downloaded by the public -- or any other public repo for that matter. Is this even possible?

like image 266
Hahnemann Avatar asked Feb 25 '16 03:02

Hahnemann


People also ask

Can I see how many downloads GitHub?

For get downloads number of your assets (files attached to the release), you can use https://developer.github.com/v3/repos/releases/#get-a-single-release (exactly "download_count" property of the items of assets list in response) Show activity on this post.

Can you see who downloaded GitHub?

That does not seem to be possible. You only have statistics, but not on downloads (unless you are talking about downloads of the releases associated with your project), or on clones of your repo.

How many GB is GitHub?

Every account using Git Large File Storage receives 1 GB of free storage and 1 GB a month of free bandwidth. If the bandwidth and storage quotas are not enough, you can choose to purchase an additional quota for Git LFS.

How do I see stats on GitHub?

You can find the link to the left of the nav bar. It is able to compute stats for a project (a group of git repositories) as well as for a contributor and a group of contributors. It provides a REST interface and a web UI.


1 Answers

The old Github download counts have been deprecated and don't seem to work any longer. You can get download counts from releases, but it does take a little bit of manipulation:

library(jsonlite)
library(httr)

url <- "https://api.github.com/repos/allenluce/mmap-object/releases"
response <- GET(url)
json <- content(response, "text")
json <- fromJSON(json)
print(Reduce("+", lapply(json$assets, function(x) sum(x$download_count))))

There are some caveats:

  1. The repo must have releases.
  2. The releases must have files
  3. There is no API to obtain the count of people who have cloned your repo.

Github allows you to count the number of released files that have been downloaded, but that's about it. The google-services repo that you use as an example has neither releases nor files!

like image 175
Allen Luce Avatar answered Oct 11 '22 01:10

Allen Luce