Skip to content
An R package for interacting with the RStudio Connect Server API
R HTML Other
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
R
inst
man
tests
vignettes
.Rbuildignore
.gitignore
DESCRIPTION
NAMESPACE
NEWS.md
README.Rmd
README.md
_pkgdown.yml
connectapi.Rproj

README.md

Lifecycle: experimental CRAN status Travis build status

connectapi

This package is an experimental WIP. The package provides an R client for the RStudio Connect API as well as helpful functions that utilize the client. The package is based on the rsconnnect package, but is publicly exported to be easier to use, is extensible via an R6 class, and is separated from the rsconnect package for easier support and maintenance.

Installation

To get started:

devtools::install_github('rstudio/connectapi')

Client

To create a client:

library(connectapi)
client <- connect(
  host = 'https://connect.example.com',
  api_key = '<SUPER SECRET API KEY>'
)

You can also define the following environment variables (in a .Renviron file, for instance):

RSTUDIO_CONNECT_SERVER  = https://connect.example.com
RSTUDIO_CONNECT_API_KEY = my-secret-api-key

These environment variable values will be used automatically if defined in your R session.

library(connectapi)
client <- connect()

Getting Started

Once a client is defined, you can use it to interact with RStudio Connect.

Exploring Data

These are experimental lazy_tbls that allow you to retrieve data from the Connect Server API much like using dplyr, dbplyr, or dtplyr. Use collect() to retrieve data when finished.

NOTE: filter is not yet supported with this tbl_connect implementation.

library(connectapi)
client <- connect()

users <- tbl_connect(client, "users")
groups <- tbl_connect(client, "groups")
shiny_usage <- tbl_connect(client, "shiny_usage")
content_visits <- tbl_connect(client, "content_visits")
all_content <- tbl_connect(client, "content")

all_shiny_usage <- shiny_usage %>% dplyr::collect()

Deployment

The rsconnect package is usually used for deploying content to Connect. However, if you want to use programmatic deployment with the RStudio Connect Server API, then these connectapi helpers should be useful!

library(connectapi)
client <- connect()

# deploying content

bundle <- bundle_dir("./path/to/directory")
content <- client %>% 
  deploy(bundle, name = "my-app-name") %>% 
  poll_task()

# set an image for content

content %>% 
  set_image_path("./my/local/image.png")

content %>% 
  set_image_url("http://url.example.com/image.png")

# set image and a vanity URL

content %>%
  set_image_path("./my/local/image.png") %>%
  set_vanity_url("/my-awesome-app")
  
# edit another piece of content

client %>%
  content_item("the-content-guid") %>%
  set_vanity_url("/another-awesome-app")
  
# migrate content to another server

client_prod <- connect(
  host = "prod.example.com",
  api_key = "my-secret-key"
)

prod_bnd <- client %>%
  content_item("the-guid-to-promote") %>%
  download_bundle()

client_prod %>%
  deploy(prod_bnd, title = "Now in Production") %>%
  set_vanity_url("/my-app")

Code of Conduct

Please note that the connectapi project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

You can’t perform that action at this time.