The R Programming Language (R Core Team 2013) has become one of the most dominant programming languages for data analysis and visualization in recent years. At the same time, web services have become a common language for allowing various systems to interact with one another. The plumber R package (Trestle Technology, LLC 2017) allows users to expose existing R code as a service available to others on the Web. Plumber is best illustrated with an example:

Even without knowing R, you can probably get a rough idea for what the above Plumber API will do. The first function above defines the /echo endpoint which simply echoes back the text that it was sent. The second function generates a plot based on Edgar Andersons famous Iris Dataset; it includes a filter that allows the caller to subset the dataset to a particular species.

Plumber makes use of these comment annotations above your functions to define the web service. When you feed the above file into Plumber, youll get a runnable web service that other systems can interact with over a network.

The Hypertext Transfer Protocol (HTTP) is the dominant medium by which information is exchanged on the Internet. An Application Programming Interface (API) is a broad term that defines the rules that guide your interaction with some software. In the case of HTTP APIs, you have a defined set of endpoints that accept particular inputs. Plumber translates the annotations you place on your functions into an HTTP API that can be called from other machines on your network. If you execute your Plumber API on a public server, you can even make your API available to the public Internet.

HTTP APIs have become the predominant language by which software communicates. By creating an HTTP API, youll empower your R code to be leveraged by other services whether theyre housed inside your organization or hosted on the other side of the world. Here are just a few ideas of the doors that are opened to you when you wrap your R code in a Plumber API:

Plumber is hosted on CRAN, so you can download and install the latest stable version and all of its dependencies by running:

Alternatively, if youd like to run the latest unstable development version of plumber, you can install it from its GitHub repository using the devtools package.

Once you have plumber installed, see the Quickstart for information on how to get up-and-running with Plumber in minutes.

The rest is here:
Creating APIs in R with Plumber

Related Posts
September 29, 2019 at 10:44 pm by Mr HomeBuilder
Category: Plumber