Integrate Plumber API Within Hosted Shiny App

I have an app hosted by Posit at shinyapp.io. Users upload files and work in the UI as typical in Shiny. However, there would be added value if I could make the same R code used available by an API allowing post/get and then users could integrate that API into their own systems and get the results back.

Plumber is an obvious tool for this and I have a working prototype on my local machine to run the API. But, can this be integrated in any way within a hosted shiny app at shinyapps.io?

1 Like

I am thinking about this too. I have an existing app that I developed using a package-like structure. I run it in a microservices framework using docker. Having plumber API would be a great way to add additional usefulness to my app. Here are some thoughts specific to my situation, but I'm curious what other more experience users think.

It makes sense to keep plumber.R within the shiny R package because it would essentially just wrap the already-existing R functions into API calls. The tricky part in my view is mapping the ports correctly: docker exposes a specific port and that's mapped to the shiny app. But plumber requires mapping another port, or is there a way to make these ports the same?
e.g. Shiny app maps to 8000, so localhost:8000 shows the shinyApp, if I call pr("plumber.R") %>% pr_run(port=8000)then can I still access API calls such as localhost:8000/plot?

Perhaps a simpler solution would be to run the app and the plumber process in two separate services/containers (using different exposed ports). I could build a new image off of my shiny app image, with an end CMD statement calling plump().

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.