Git Product home page Git Product logo

cranlogs.app's Introduction

The API of the CRAN downloads database

General remarks

The download count data was provided by the RStudio CRAN mirror. The data source is updated daily, and cranlogs tries to update hourly.

The output is JSON. The API was inspired by the download-counts npm package, and adapted to R.

The service also provides badges for READMEs.

There is an official R client for the API, the cranlogs package.

This README documents

Web API docs

Top downloaded packages /top/{period}[/count]

period must be one of last-day, last-week or last-month, and count is the number of packages to show. count can be at most 100 currently. Example output for https://cranlogs.r-pkg.org/top/last-day/3

{
  start: "2015-05-01T00:00:00.000Z",
  end: "2015-05-01T00:00:00.000Z",
  downloads: [
    {
      package: "Rcpp",
      downloads: "5010"
    },
    {
      package: "ggplot2",
      downloads: "4329"
    },
    {
      package: "plyr",
      downloads: "4121"
    }
  ]
}

Trending packages last week /trending

Trending packages are the ones that were downloaded at least 1000 times during last week, and that substantially increased their download counts, compared to the average weekly downloads in the previous 24 weeks. The percentage of increase is also shown in the output:

[
  {
    package: "fpp",
    increase: "914.4002185991438200"
  },
  {
    package: "TSA",
    increase: "764.1159377095596500"
  },
  {
    package: "readr",
    increase: "662.9005975013579600"
  },
...

Total downloads over a period /downloads/total/{period}[/{package1,package2,...}]

The output looks like this:

[{
  downloads: 201761,
  start: "2014-06-01",
  end: "2014-06-30",
  package: "ggplot2"
}]

If there was no package given, then that key is missing.

Examples

All packages, last day:

https://cranlogs.r-pkg.org/downloads/total/last-day

All packages, specific date:

https://cranlogs.r-pkg.org/downloads/total/2014-02-01

Package ggplot2, last week:

https://cranlogs.r-pkg.org/downloads/total/last-week/ggplot2

Package ggplot2, given 7-day period:

https://cranlogs.r-pkg.org/downloads/total/2014-02-01:2014-02-08/ggplot2

Package ggplot2, last 30 days:

https://cranlogs.r-pkg.org/downloads/total/last-month/ggplot2

Package "ggplot2", specific month:

https://cranlogs.r-pkg.org/downloads/total/2014-01-01:2014-01-31/ggplot2

Multiple packages at once:

https://cranlogs.r-pkg.org/downloads/total/last-day/igraph,ggplot2,Rcpp

Accepted values

In general, dates in the yyyy-mm-dd ISO 8601 format are accepted. The following keywords can also be used:

last-day Yesterday, unless the database has not been updated yet for yesterday, in which case it is the day before.

last-week Last 7 available days.

last-month Last 30 available days.

Daily downloads /downloads/daily/{period}[/{package}]

Output looks like this:

[{
    downloads: [
        {
            day: "2014-09-27",
            downloads: 1581
        },
        ...
        {
            day: "2014-10-04",
            downloads: 2395
        }
    ],
    start: "2014-09-27",
    end: "2014-10-04",
    package: "ggplot2"
}]

Again, if no package was specified, then that key is missing.

Examples

Downloads per day, last 7 days:

https://cranlogs.r-pkg.org/downloads/daily/last-week

Downloads per day, specific 7 days:

https://cranlogs.r-pkg.org/downloads/daily/2014-02-07:2014-02-14

Downloads per day, last 30 days:

https://cranlogs.r-pkg.org/downloads/daily/last-month/ggplot2

Downloads per day, specific 30 day period:

https://cranlogs.r-pkg.org/downloads/daily/2014-01-03:2014-02-03/ggplot2

Downloads of R

If instead of a list of package, R is given, downloads of R are returned. For total, the total number of downloads for a given period. For daily, daily downloads, separately for various operating systems and R versions. Here are some examples:

Last day, separately for R versions and operating systems:

https://cranlogs.r-pkg.org/downloads/daily/last-day/R

Total number of downloads last week:

https://cranlogs.r-pkg.org/downloads/total/last-week/R

Badges

/badges[/{summary}]/{package}[?color={color}]

Returns an SVG badge with download counts. Monthly, weekly and daily summaries and the total number of downloads are available. If the summary type is not given, the number of downloads per month is shown:

https://cranlogs.r-pkg.org/badges/Rcpp

Weekly downloads are shown with last-week:

https://cranlogs.r-pkg.org/badges/last-week/Rcpp

Daily downloads are shown with last-day:

https://cranlogs.r-pkg.org/badges/last-day/Rcpp

Total number of downloads since October of 2012, the month the RStudio CRAN mirror started publishing logs, with grand-total:

https://cranlogs.r-pkg.org/badges/grand-total/Rcpp

Colors can be customized. Supported color names are: brightgreen, green, yellowgreen, yellow, orange, red, lightgrey, blue. Hex colors are also supported. The badge is blue by default, as above. Other colors in the same order, and the hex color ff69b4:

https://cranlogs.r-pkg.org/badges/Rcpp?color=brightgreen

Our badges were designed and created by shields.io.

cranlogs.app's People

Contributors

agrueneberg avatar dirkschumacher avatar dpastoor avatar gabor0 avatar gaborcsardi avatar gavinsimpson avatar maelle avatar pdwaggoner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cranlogs.app's Issues

Bulk API

E.g. download counts for all packages for last day/week/month.

API down

Hi

It looks like the API is currently down, getting 404 when trying to request data, for instance from the https://cranlogs.r-pkg.org/downloads/total/last-day endpoint. Is it an expected service interruption or something requiring intervention? If so, when can we expect API to be back online?

adding error status codes for invalid queries

Would it be possible to add more appropriate status codes for invalid requests to improve client error handling.

I hit a "bug" while hacking on https://github.com/devOpifex/cranlogs as I'd added some error handling of:

if resp.StatusCode != 200 {
		return daily, fmt.Errorf("error getting daily downloads: %s", resp.Status)
	}

but then was improperly constructing the string so it was invalid.

Checking via curl shows that there is still a 200 response along with the json { "error": "Invalid query", "info": "https://github.com/metacran/cranlogs.app" }

โฏ curl https://cranlogs.r-pkg.org/downloads/dailylast-week/dplyr -v
*   Trying 104.21.58.236:443...
* Connected to cranlogs.r-pkg.org (104.21.58.236) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-ECDSA-CHACHA20-POLY1305
* ALPN, server accepted to use h2
* Server certificate:
*  subject: C=US; ST=California; L=San Francisco; O=Cloudflare, Inc.; CN=sni.cloudflaressl.com
*  start date: Jul  5 00:00:00 2021 GMT
*  expire date: Jul  4 23:59:59 2022 GMT
*  subjectAltName: host "cranlogs.r-pkg.org" matched cert's "*.r-pkg.org"
*  issuer: C=US; O=Cloudflare, Inc.; CN=Cloudflare Inc ECC CA-3
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x148811600)
> GET /downloads/dailylast-week/dplyr HTTP/2
> Host: cranlogs.r-pkg.org
> user-agent: curl/7.77.0
> accept: */*
> 
* Connection state changed (MAX_CONCURRENT_STREAMS == 256)!
< HTTP/2 200 
< date: Fri, 21 Jan 2022 14:48:49 GMT
< x-powered-by: Express
< cf-cache-status: DYNAMIC
< expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
< report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=X5Vvidd5ALsPSmETV7yv%2FOMMxheEOOI9Q9cvoeXUmt8pPdTAfwVPf3ocvGaFFFUsH5PsXOdd3TZVyHGZ9%2BQUKPYgxh%2BWCHAJ3nRNSGaMuaiyUrPipE67Jl%2Bqq899FTWJ2pKxQOY%3D"}],"group":"cf-nel","max_age":604800}
< nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
< server: cloudflare
< cf-ray: 6d11587e2e165b4c-IAD
< alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400
< 
* Connection #0 to host cranlogs.r-pkg.org left intact
{ "error": "Invalid query",   "info": "https://github.com/metacran/cranlogs.app" }

Ideally would get like a 400, 404 or the like status code

Badge for github version

Hi!

Great job with these bagdes! I'm only missing a badge to show which version that is in the masterbranch of a github package, for the useres to see fast if there is a new version. I guess this could be done using github API? Any suggestions?

Badge counts not updating

It appears that the badge counts are not updating. When using the cranlogs R package daily counts from 2018-01-01 and on show 0 for all packages tested. I assume these issues are the same.

Why is the downloads count so inflated?

This is a great package. Thank you. But I really wonder how is it possible that, for example, ggplot2 is downloaded 1.4M a month as shown on https://cranlogs.r-pkg.org/?
According to RStudio package manager the monthly download of ggplot2 is about 50K. That's about dividing 1.4M by 30 days.

So actually I am thinking what the count number from cran log mean... because the number returned from each day is about on the 50K level:

cranlogs::cran_downloads("ggplot2", when = "last-month")

gives:

         date count package
1  2020-11-17 74014 ggplot2
2  2020-11-18 71236 ggplot2
3  2020-11-19 70541 ggplot2
4  2020-11-20 66101 ggplot2
5  2020-11-21 53323 ggplot2
6  2020-11-22 51742 ggplot2
7  2020-11-23 67641 ggplot2
8  2020-11-24 65529 ggplot2
9  2020-11-25 51643 ggplot2

Download stats in badge not updating

@gaborcsardi First, thanks for the great work on this. It is really useful for me as I get asked often how I can show that my work is getting used. I have pointed to cranlogs multiple times already!

I am having an issue with the badge in a README.md. The badge shows up fine, but the values are not updated. For instance, the values in the badge on the readme show 1896 total downloads. But when you ding the site the svg indicates 1980 downloads (as of 5/7/2015). You appear to be having the same issue on your README.md. Total downloads for Rcpp there shows 6017, but badge from cranlogs.r-pkg.org indicates 8462 (as of 5/7/2015).

Again, thanks for you work on this (and all of metacran for that matter).

cranlogs queries are several days behind RStudio's posted CRAN logs

I notice that cranlogs::cran_downloads is several days behind the CRAN logs posted here. Right now those .gz files include one for October 4th, but:

> cran_downloads("ggplot2", from = "2016-10-01", to = "2016-10-05")
        date count package
1 2016-10-01  5499 ggplot2
2 2016-10-02  5893 ggplot2
3 2016-10-03     0 ggplot2
4 2016-10-04     0 ggplot2
5 2016-10-05     0 ggplot2

And https://cranlogs.r-pkg.org/badges/last-day/ggplot2 is showing 5893. In both cases, this is the October 2nd result. Is something awry?

How often updated?

Just a curiosity - I couldn't find the update frequency anywhere, could you please write it somewhere in the README or so?

Thanks!

MarkDown badge code to knit to PDF?

When I create a new .Rmd file with simply the CRAN badge, and knit to html, it works:

[![](https://cranlogs.r-pkg.org/badges/rempsyc)](https://cran.r-project.org/package=rempsyc)

However, when I attempt to knit to PDF, I get the following error:

! LaTeX Error: File `https://cranlogs.r-pkg.org/badges/rempsyc' not found.

Error: LaTeX failed to compile test-cran.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See test-cran.log for more info.
Execution halted

Is there any way to make this work for PDF, like automatically converting to an image during the knit? Else is there any way that this could make its way as a feature request, like requesting an image link, like https://cranlogs.r-pkg.org/badges/rempsyc.jpg?

Request: A combined CRAN version and GitHub version badge

As discussed on Slack, we are trying to standardize READMEs across the rOpenSci project. In the interest of keeping badges concise and to prevent badge proliferation, we would humbly request a combined CRAN version/status + Github version badge.

Prototype:
image

@gaborcsardi mentioned that this would require an entirely new badge. If package is not on CRAN, then badge would reflect that.

Why? This badge would allow a potential user to quickly determine whether a package is on CRAN, and if development on GitHub has progressed considerably more than the last CRAN version. ๐Ÿ™

Requesting png badges, instead of svg. pandoc (pdflatex) hates svg

I am trying to compile both html and pdf from a Rmd file.

The pdf fails with the following error:

pandoc: Unable to convert image `/var/folders/pt/061nmk8s53x4tw_j92hp4hnr0000gn/T/tex2pdf.6334/c3fd0364f0ccb172153fb6fd829150bca9077120.svgz':

Found a few helpful guides to address this issue, most of them focus on embedding svg into pdf documents (rendering Rmd files dirty for HTML output).

Would be awesome if the badge API could include a format option, much like travis does.

https://travis-ci.org/sahilseth/flowr.png?branch=master

Build Status

https support?

Hi,

Given the LetsEncrypt initiative, by which it is easy to obtain a valid and free SSL certificate accepted in most major browsers, would it be possible to have https://cranlogs.r-pkg.org/ ?

For https websites having access to https badges would be great.

Thank you for your work and sorry to disturb you.

weekly (not daily) download over specific period

As per the example, it is possible to access daily downloads over a given period. E.g., http://cranlogs.r-pkg.org/downloads/daily/2014-01-03:2014-02-03/ggplot2

My goal is to have weekly download volumes for a package over a long period.

From the result of the above request I can compute weekly volumes, but that means retrieving a lot more information than necessary. If I replace "daily" with "weekly", I get an error (invalid query). Is it at all possible to get weekly data?

Best

CRAN URL not in canonical form

Hi,

Currently, the badge URL gives a NOTE on winbuilder. For example, when using winbuilder on package bmlm:

Found the following (possibly) invalid URLs:
  URL: http://cran.rstudio.com/web/packages/bmlm/index.html (moved to https://cran.rstudio.com/web/packages/bmlm/index.html)
    From: README.md
    Status: 200
    Message: OK
    CRAN URL not in canonical form

The badge links should probably be in the "canonical CRAN form", e.g.:

https://cran.r-project.org/package=bmlm

RStudio downloads vs. "total" downloads

Thanks for the great package. My limited understanding of CRAN is that RStudio is the only mirror that provides download stats, and that cranlogs stats are from the RStudio server only. Is this correct?

If a package has 100 downloads reported from metacran, is there any way to know what the total number of installs is?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.