⇧ Back to top

RStudio Connect API Reference 1.0.0

This is a reference document explaining the RStudio Connect API. Please note that paths are relative to the base API URL (i.e., http:/localhost:3939/__api__/v1)

The Connect Server API can be used to perform certain user actions remotely. You will need to install a tool or library that can make HTTP requests, such as: - [httr](http://httr.r-lib.org/) (R HTTP library) - [cURL](https://curl.haxx.se/) (Linux tool for making HTTP calls) - [requests](http://docs.python-requests.org/en/master/) (Python HTTP library) ## Authentication Most endpoints require you to identify yourself as a valid RStudio Connect user. You do this by specifying an API key when you make a call to the server. See the RStudio Connect User Guide if you need help creating one. You can find a link to it on the **Documentation** tab of the Connect dashboard. ### API Keys API Keys are managed by each user in the Connect dashboard. If you ever lose an API key or otherwise feel it has been compromised, use the dashboard to revoke the key and create another one. Once you have an API key, you can authenticate by passing the key with a prefix of `"Key "` (the space is important) in the Authorization header. Below are examples of invoking the "Get R Information" endpoint. **cURL** ```bash curl -H "Authorization: Key XXXXXXXXXXX" \ https://rstudioconnect.example.com/__api__/v1/server_settings/r ``` **R** ```r library(httr) apiKey <- "XXXXXXXXXXX" result <- GET("https://rstudioconnect.example.com/__api__/v1/server_settings/r", add_headers(Authorization = paste("Key", apiKey)) ``` **Python** ```python import requests r = requests.get( 'https://rstudioconnect.example.com/__api__/v1/server_settings/r', headers = { 'Authorization': 'Key XXXXXXXXXXX' } ) ```

Endpoints

The URIs for all endpoints below must be prefixed with /__api__/v1 to function properly. Unless otherwise noted, all endpoints which accept a request body will require the body to be in application/json format. Similarly, all response bodies will be returned in application/json format.

Audit Logs

These endpoints allow you to discover what the Connect server knows about the audit logs.
get   /audit_logs Get audit logs
Operation ID: getAuditLogs

This endpoint returns a portion of the audit logs, as well as paging information that can be used to navigate the audit log results.
This endpoint requires administrator access.
For examples, please see the RStudio Connect User Guide. You can find a link to it on the **Documentation** tab of the Connect dashboard.
Parameters
Name Location Type Required Description
limit Query integer No
Number of logs to return. The minimum supported value is 1 and maximum supported value is 500. Note that `limit` is a "best effort" request since there may not be enough logs to satisfy the limit.
Default Value
```json 20 ```
previous Query string No
Gets the previous page of audit logs relative to the given id.
next Query string No
Gets the next page of audit logs relative to the given id.
ascOrder Query boolean No
Whether the audit logs should be listed in ascending order
Default Value
```json true ```

The response body will be returned in application/json format.

Status Code Type Description
200 AuditLogs
The audit logs results and paging information
401 APIError
The client which invoked the API did not provide appropriate credentials to call the API. The result will have a code of `24` and an error of "The requested operation requires authentication."
403 APIError
The client which invoked the API did not provide appropriate credentials to call the API. The result will have a code of `22` and an error of "You don't have permission to perform this operation."
default APIError
An error occurred invoking the API.

R Information

These endpoints allow you to discover what the Connect server knows about its R installations.
get   /server_settings/r Get R Information
Operation ID: getRInformation

This endpoint returns a list of metadata objects for each installed version of R that RStudio Connect can run.
This endpoint requires authentication and is only available to `publisher` and `administrator` roles.
For examples, please see the RStudio Connect User Guide. You can find a link to it on the **Documentation** tab of the Connect dashboard.
Status Code Type Description
200 RInstallations
An object describing all the metadata information Connect has about each installation of R.
401 APIError
The client which invoked the API did not provide appropriate credentials to call the API. The result will have a code of `24` and an error of "The requested operation requires authentication."
403 APIError
The client which invoked the API did not provide appropriate credentials to call the API. The result will have a code of `22` and an error of "You don't have permission to perform this operation."
default APIError
An error occurred invoking the API.

Models

APIError

This object defines data that the Connect server in the case of an error.
Field Type Required Description
code integer Yes
The specific code for the type of error returned.
error string Yes
Some text which describes the problem that was encountered.
payload any No

Example

```json { "code": 24, "error": "The requested operation requires authentication." } ```

AuditCursor

Cursors that can be used for navigation
Field Type Required Description
next string No
A cursor ID that can be used with the `next` query param to get the next page of results.
previous string No
A cursor ID that can be used with the `previous` query param to get the previous page of results.

Example

```json { "previous": "23948901087", "next": "23948901087" } ```

AuditEntry

Field Type Required Description
action string Yes
Audit action taken
event_description string Yes
Description of action
id string Yes
ID of the audit action
time string (date-time) Yes
Timestamp in RFC3339 format when action was taken
user_description string Yes
Description of the actor
user_id string Yes
User ID of the actor who made the audit action

Example

```json { "event_description": "Added user Full Name (username)", "user_id": "string", "time": "2006-01-02T15:04:05Z07:00", "action": "add_user", "user_description": "Full name (username)", "id": "string" } ```

AuditLogs

Field Type Required Description
paging AuditPager No
results array of AuditEntry No
The audit logs

Example

```json { "paging": { "first": "http://localhost:3443/__api__/audit_logs", "previous": "http://localhost:3443/__api__/audit_logs?previous=23948901087", "last": "http://localhost:3443/__api__/audit_logs?last=true", "cursors": { "previous": "23948901087", "next": "23948901087" }, "next": "http://localhost:3443/__api__/audit_logs?next=23948901087" }, "results": [ { "event_description": "Added user Full Name (username)", "user_id": "string", "time": "2006-01-02T15:04:05Z07:00", "action": "add_user", "user_description": "Full name (username)", "id": "string" } ] } ```

AuditPager

Paging object that can be used for navigation
Field Type Required Description
cursors AuditCursor Yes
first string No
A full URL of the first page of results. It will always return the current first page.
last string No
A full URL of the last page of results. It will always return the current last page.
next string No
A full URL of the next page of results when the original request was made.
previous string No
A full URL of the previous page of results when the original request was made.

Example

```json { "first": "http://localhost:3443/__api__/audit_logs", "previous": "http://localhost:3443/__api__/audit_logs?previous=23948901087", "last": "http://localhost:3443/__api__/audit_logs?last=true", "cursors": { "previous": "23948901087", "next": "23948901087" }, "next": "http://localhost:3443/__api__/audit_logs?next=23948901087" } ```

RInstallation

This defines the information provided by the server about a single installation of R.
Field Type Required Description
version string No
The version number of this R installation.

Example

```json { "version": "3.4.4" } ```

RInstallations

This defines the top-level object that describes the data returned by the server. It contains information about each installation of R that is known.
Field Type Required Description
installations array of RInstallation No
The array of information about Connect's R installations.

Example

```json { "installations": [ { "version": "3.4.4" }, { "version": "3.2.5" } ] } ```