Skip to content

How to Publish a Plumber API to RStudio Connect#

This guide used RStudio IDE Version 1.3.959.

This guide walks you through creating a new Plumber API and then publishing your document to RStudio Connect.

Prerequisites#

Before you begin, you must:

For more information about requesting permission to publish your content, please see the Publishing section of the User Guide.

Note

As you walk through this guide, there may be additional steps that are required due to your unique environment. For example, you may need to install or update packages, restart R, etc. In many cases, RStudio prompts you to complete the action that is required to continue with this guide. If you get stuck, please refer to the Related Documentation section or the RStudio Connect Admin Guide.

Step 1. Create a new Plumber API#

RStudio IDE has a sample Plumber API that is available out of the box. For this guide, we are going to utilize the sample Plumber API because everyone has access to it, and it allows us to focus on the task of publishing the Plumber API to RStudio Connect instead of manually creating the Plumber API from scratch. Let's begin!

  • Open the RStudio IDE.
  • From the menu bar, select File > New File > Plumber API.... RStudio IDE New File options screen capture

   The New Plumber API window displays.

  • If you are prompted to install additional packages that are required, click Yes.
  • Give your new Plumber API a name and click Create. New Plumber API window

   The script for your Plumber API displays in the editor.

Now, we should confirm that the Plumber API was successfully created.

  • To verify that it was created successfully, at the top of the editor, click Run API. Run API button screen capture

If the Plumber API runs successfully, a new window displays. Swagger window displaying the
Plumber Example API

Try it out!#

Now that you have successfully run your Plumber API in the RStudio IDE, you can try it out!

Try out your Plumber API in the RStudio IDE Viewer pane

The RStudio IDE has the option to run your Plumber API in the built-in Viewer pane. Once your Plumber API displays in the Viewer pane, you can try out the default endpoints.

  • At the top of the editor, click the Run API drop-down menu, select Run in Viewer Pane. Screen capture of the Run API menu displayed with the Run in Viewer Pane option selected

       Your Plumber API displays in the Viewer pane.

  • In the Viewer pane, you may have to scroll down, and expand the /plot endpoint. Screen capture of the Viewer pane

  • Now, click Try it out. The Parameters section features the Try it out button
  • Click Execute. The Execute button displays after you click Try it out and is located in the Parameters section

       The Responses of your Plumber API displays.

    A screen capture of the Plumber API responses

Step 2. Publish your Plumber API to RStudio Connect#

Note

Before you execute this step, verify that you have connected your RStudio Account. The procedures are available here.

  • At the top of the editor, click Publish. Example of the Publish button

  • In the Publish to Server window, confirm that your account is shown in the Publish to Account section and click Publish. Screen capture of the Publish to Server window

    User Tips

    • You can monitor the status of the deployment in the RStudio IDE Deploy pane.
    • If for any reason you would like to stop the deployment, you can simply click the Stop button located in the Deploy pane.
    • Your newly deployed R Markdown document automatically opens in a new browser tab if the Launch browser check box is selected (it is selected by default).
    • If it doesn't automatically display, your app may have been blocked as a popup in your browser.

Step 3. View the Plumber API on RStudio Connect#

  • Navigate back to the RStudio Connect server that you published your content to.
  • If applicable, log back into RStudio Connect.
  • To view the Content that you own, click the Show Options panel button. The botton is located on the upper-right side of the window
  • In the Owners section, select Yours. Image of the Yours radio button selected    Your Plumber API should display in the Content section.
  • To view your Plumber API, simply click the title of your Plumber API. Image of Content being selected

       Your Plumber API displays in the RStudio Connect browser window.

Screen capture of Plumber API
  displaying in a browser

Try it out!#

Now that you have successfully published your Plumber API to RStudio Connect, you can try it out!

Try out your Plumber API
  • Navigate to RStudio Connect and select your Plumber API.
  • For this example, expand the /plot endpoint.
  • Now, click Try it out. The Try it out button is located in the Parameters section
  • Click Execute. The Execute button displaying in the Parameters section
once you click Try it out></p>
<p>   <em>The Responses of your Plumber API displays.</em></p>
</li>
</ul>
<p><img src=