How to Publish a Plumber API to Posit 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 Posit Connect, formerly RStudio Connect.
Before you begin, you must:
- Install R
- Install the RStudio Integrated Development Environment (IDE)
- Have the public URL of the Connect server
- Have a valid Connect account that has been promoted to at least the Publisher role
- Connect your Posit Account
For more information about requesting permission to publish your content, please see the Publishing section of the User Guide.
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 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 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....
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.
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.
If the Plumber API runs successfully, a new window displays.
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.
Your Plumber API displays in the Viewer pane.
In the Viewer pane, you may have to scroll down, and expand the
- Now, click Try it out.
The Responses of your Plumber API displays.
Step 2. Publish your Plumber API to Connect#
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.
In the Publish to Server window, confirm that your account is shown in the Publish to Account section and click Publish.
- 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 Connect#
- Navigate back to the Connect server that you published your content to.
- If applicable, log back into Connect.
- To view the Content that you own, click the Show Options panel button.
- In the Owners section, select Yours. Your Plumber API should display in the Content section.
To view your Plumber API, simply click the title of your Plumber API.
Your Plumber API displays in the Connect browser window.
Try it out!#
Now that you have successfully published your Plumber API to Connect, you can try it out!
Try out your Plumber API
- Navigate to Connect and select your Plumber API.
- For this example, expand the
- Now, click Try it out.