Calling APIs on Connect from R


To call APIs hosted in Connect from R, you’ll need:

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

R Example

You can use the httr package in R to call APIs from Shiny applications, R Markdown reports, other Plumber APIs, or R scripts:


connectApiUrl <- ""
connectApiKey <- "YfB5XBRB7slkkBSEi5qr93mWJvbpXQQy"

resp <- GET(connectApiUrl,
            add_headers(Authorization = paste0("Key ", connectApiKey)))
result <- content(resp, "parsed")

You can replace the values of connectApiUrl and connectAPIKey with your API URL and API key from Connect.


The code examples assume that you are calling a published API in 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.

Back to top