Skip to content

Calling Plumber APIs from Python#


To call APIs hosted in RStudio Connect from Python, you'll need:

  1. URL for the API endpoint hosted on RStudio Connect
  2. API key (if your API requires authorization)

Python Example#

You can use the requests package in Python to call Plumber APIs from Python scripts or Jupyter Notebooks:

import requests

connect_api_url = ""
connect_api_key = "YfB5XBRB7slkkBSEi5qr93mWJvbpXQQy"

response = requests.get(connect_api_url,
                        headers={'Authorization': 'Key ' + connect_api_key})

You can replace the values of connect_api_url and connect_api_key with your API URL and API key from RStudio Connect.


The code examples assume that you are calling a published API in RStudio Connect that is:

  • Hosted on a secure server with TLS/SSL at an HTTPS endpoint
  • Using an API key to make an authorized call to an API
  • Making an HTTP GET request to the API

If your use case is different, then you can modify the example code accordingly.