All you need, in addition to R and RStudio, is the package Plumber and optionally Docker. Transforming an R script into a REST API is quite easy. I have created this example API for our trainee program, and it serves our new data scientists and engineers as a starting point to familiarize themselves with the subject.
In this blog post, I will show you how to translate a simple R script, which transforms tables from wide to long format, into a REST API with the R package Plumber and how to run it locally or with Docker. Imagine, e.g., an infrastructure, where an API that’s written in Python and one that’s written in R communicate with each other and serve an application written in JavaScript. This is because APIs are naturally separated from each other, and communication with and between APIs is handled by IP or URL (http), typically using JSON or XML format. An additional advantage of APIs is that they allow for an easy combination of code written in different programming languages or by different development teams. Their primary purpose is to simplify programming by abstracting the underlying implementation and only exposing objects and actions that are needed for any further development and interaction. They are flexible, easy to deploy, scale, and maintain, and they are further accessible by multiple clients and client types at the same time.
Representational State Transfer (REST) APIs are well suited to be implemented as part of a modern micro-services infrastructure. We at STATWORX, therefore, operationalize our models and algorithms by translating them into Application Programming Interfaces (APIs). Data operations is an increasingly important part of data science because it enables companies to feed large business data back into production effectively.