Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sellorm/rspmapi

R Wrapper Around The RStudio Package Manager API
https://github.com/sellorm/rspmapi

Last synced: about 1 month ago
JSON representation

R Wrapper Around The RStudio Package Manager API

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# rspmapi

The `rspmapi` package implements an R wrapper around the RStudio Package Manager API.

## Installation

You can install the development version of `rspmapi` from [GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("sellorm/rspmapi")
```

## Example

In order to use any of the supplied functions, you must first connect to your
Package Manager instance:

```{r connection}
library(rspmapi)
rspm <- instance("https://packagemanager.rstudio.com")
```

Once you have an RSPM instance object, you can use it to perform API operations.

Each API endpoint has a corresponding function in `rspmapi`.

```{r status}
result <- rspm %>%
status()
result$version
```

Some of the functions take additional arguments:

```{r sources}
result <- rspm %>%
repos_sources(id = 1)
result[[1]]$created
```

Some functions can optionally take additional query string parameters. These are
documented in the
[RSPM API docs](https://packagemanager.rstudio.com/__api__/swagger/index.html)
for each API call.

```{r params}
params <- list(`_limit` = 5, `_page` = 2, name_like = "shiny")
result <- rspm %>%
sources_packages(id = 1, params = params)
unlist(lapply(result, function(x){x$name}))
```