4 API Keys

API Keys allow you to programatically access content on RStudio Connect. They are a substitute for logging in to RStudio Connect before you access content.

Create a new API Key for each application that needs access to content, and give each key a name that helps you identify which application uses it. When an application no longer needs access, or if you cannot trust the application at any time, you can quickly revoke access by deleting the Key.

To access content with an API Key you must provide a HTTP header whose key is Authentication and value is Key THE_API_KEY.

All requests to content must be made to the target URL of the published content. You can find the target URL by clicking the ... menu in the upper-right of the content view and select “Open Solo”.

A screenshot of the menu with Open Solo displayed.

A screenshot of the menu with “Open Solo” displayed.

4.1 Examples

4.1.1 Static Content

Suppose you have published a plot whose target URL is http://example.com/content/24/target.html

You can download the content with an API Key via:

curl -o output.html -H 'Authorization: Key YOUR_API_KEY_HERE' 'http://example.com/content/24/target.html'

4.1.2 Plumber

Suppose you have published the following Plumber application whose target URL is http://example.com/content/42

## plumber.R

#* @get /mean
normalMean <- function(samples=10){
  data <- rnorm(samples)
  mean(data)
}

The following calls the function at the /mean endpoint with an API Key:

curl -H 'Authorization: Key YOUR_API_KEY_HERE' 'http://example.com/content/24/mean?samples=5'