Calling Plumber APIs from curl#
Requirements#
To call APIs hosted in RStudio Connect from curl, you'll need:
- URL for the API endpoint hosted on RStudio Connect
- API key (if your API requires authorization)
curl Example#
You can use the curl
command-line tool on Linux to call Plumber APIs from
terminals, shell scripts, or CI/CD systems:
export CONNECT_API_URL=https://connect.yourcompany.com/rest-api-example/endpoint
export CONNECT_API_KEY=YfB5XBRB7slkkBSEi5qr93mWJvbpXQQy
curl -H "Authorization: Key ${CONNECT_API_KEY}" ${CONNECT_API_URL}
You can replace the values of CONNECT_API_URL
and CONNECT_API_KEY
with your
API URL and API key from RStudio Connect.
Scope#
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.