Full Workspace Automation through a Programmatic Interface (API) Available Now


Each workspace already is an API

QBit Workspace is a new service to immediately deploy data science results at scale. You can think of it as an online data science editor (like RStudio) which can also be controlled and automated from any programming language through a REST API. Once a workspace has been created—including code, environment objects and files—there is no need for a separate (API) deployment step any more. Each workspace already is an API. With its powerful REST API interface it can be easily embedded into any application, app or programming language without running and managing your own R- or Python server.

We’re now happy to announce the launch of our API service in public beta, which allows to control every aspect of the workspace programmatically including actions like:

  • Workspace creation
  • Workspace deployment
  • Code execution
  • Rendering of RMarkdown documents
  • File up- and downloads
  • Package install/remove

The API thus allows to create completely new use cases which can be easily embedded with any programming language into web applications or mobile apps. No API packages like R plumber or Python Flask are needed!

Get Started with the QBit Workspaces API

To use the API from R first install the qbit package from the Quantargo Github repository:


Next, you need to retrieve your free API key from the Quantargo page settings section:

For more information about API key creation and usage also see our detailed step-by-step guide. Ideally, set your API key QKEY through the options() settings as

options(QKEY = "<ENTER-API-KEY-HERE>")

so that all further API calls use the key accordingly. Now you are ready to interact with QBit workspace! As a first example, we’ll show how to create an API-ready RMarkdown report within R.

Creating RMarkdown Documents through the qbit R-API

RMarkdown combines markdown text with R outputs (e.g. plots, tables) to create reproducible documents in multiple output formats (e.g. HTML, PDF, Word, Powerpoint, see also here). Most R-data scientists use their local (RStudio) environment to produce these reports. But what if we want to render these reports through a web application on the fly, maybe even parametrized or with updated input data sets? In the following section we’ll create a QBit workspace for RMarkdown to quickly render an HTML document through the API.

Let’s start by creating a new workspace based on the RMarkdown template:

qbit_id <- qbit::create(qbit_name = "RMarkdown Example HTML document")
[1] "qbit-rmarkdown-example-html-document-eGJWV404T"

The created workspace received a new and unique qbit_id based on its qbit_name title. You can also visit the new workspace online and even share its link with your friends/co-workers. Further changes to your workspace can now be done through the API using the qbit::deploy() function or directly within the online editor.

Once you are satisfied with your workspace you can run specific R commands, retrieve their respective outputs and integrate them into your application. Most typically, you might want to execute specific commands like predict() (for model predictions) or any kinds of user–defined functions through qbit::run. The qbit::run interface, which allows to execute any arbitrary R code, is therefore very general and can support any complex API use cases. For our RMarkdown use case we would like to render the main.Rmd file as an HTML document with qbit::render:

render_out <- qbit::render(qbit_id)

The $console_output element contains a data frame (tibble) of all created contents through the call:

# A tibble: 8 × 3
  type         content                                          name 
  <chr>        <chr>                                            <chr>
1 code-input   "rmarkdown::render(\"main.Rmd\")"                <NA> 
2 code-message "Warning message: \n\nprocessing file: main.Rmd… <NA> 
3 code-output  "\r  |                                         … <NA> 
4 code-output  "\r  |                                         … <NA> 
5 code-message "Warning message: output file: main.knit.md\n\n" <NA> 
6 code-output  "/usr/bin/pandoc +RTS -K512m -RTS main.utf8.md … <NA> 
7 code-message "Warning message: \nOutput created: main.html\n" <NA> 
8 file         "https://cdn.quantargo.com/assets/user/courses/… main…

The link of the created Rmarkdown document is located in the row where content type equals "file":

render_out$console_output %>%
  filter(type == "file")
# A tibble: 1 × 3
  type  content                                                 name 
  <chr> <chr>                                                   <chr>
1 file  https://cdn.quantargo.com/assets/user/courses/b8451061… main…

The included link in the content column can be easily integrated into your own web application (via an <iframe> tag) or just downloaded locally (e.g. via download.file() in R).

Thanks to the serverless (AWS Lambda) back-end the QBit Workspace is quickly scalable to thousands of concurrent requests. The service is now available in public beta and can be deployed into your own infrastructure (Docker/Container based including Lambda, Kubernetes, Open Shift) upon request.

Happy deploying!

Become a Data Science PRO

  • Access to all courses

    Including 15+ in-depth data science lessons

  • Real-world use cases

    Jump start your own projects with ease

  • Personal premium support

    Get help directly from our course writers

A great course set-up to get a first insight into the workings of R and to wet your appetite for more – the possibilities seem endless. A very enjoyable experience, thank you!

Liza Glesener, SICONA

More Posts

Keep Reading

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.