SlideShare a Scribd company logo
Mark Sellors - Technical Architect
msellors@mango-solutions.com
APIs with R and plumber
Mark Sellors - Mango Solutions
Mark Sellors - Technical Architect
msellors@mango-solutions.com
Me
• Technical Architect
• Data Engineering
• DataOps
• Analytic Maturity
• Automation
• Industrialisation
Mark Sellors - Technical Architect
msellors@mango-solutions.com
Agenda
• API’s
• Introducing plumber
• How it works
• A simple case study
• Caveats
• Summary
Mark Sellors - Technical Architect
msellors@mango-solutions.com
Data Science + API’s
are Changing the World
Mark Sellors - Technical Architect
msellors@mango-solutions.com
Introducing plumber
http://plumber.trestletech.com
Mark Sellors - Technical Architect
msellors@mango-solutions.com
Example - simple function
> adder <- function(a, b){
+ a + b
+ }
> adder(4, 3)
[1] 7
Mark Sellors - Technical Architect
msellors@mango-solutions.com
Example - add plumber
#* @get /adder
> adder <- function(a, b){
+ as.numeric(a) + as.numeric(b)
+ }
Mark Sellors - Technical Architect
msellors@mango-solutions.com
Example - running with plumber
> library(plumber)
> r <- plumb("my_api_file.R")
> r$run(port=8000)
Mark Sellors - Technical Architect
msellors@mango-solutions.com
Example - Accessing the API
# curl http://localhost:8000/adder?a=4&b=3
Mark Sellors - Technical Architect
msellors@mango-solutions.com
Demo 1 - Simple API
Mark Sellors - Technical Architect
msellors@mango-solutions.com
Example - serving graphs
Mark Sellors - Technical Architect
msellors@mango-solutions.com
Demo 2 - Tick API
Mark Sellors - Technical Architect
msellors@mango-solutions.com
Why? What’s the point?
Mark Sellors - Technical Architect
msellors@mango-solutions.com
Example - Shiny App
Mark Sellors - Technical Architect
msellors@mango-solutions.com
Demo 3 - Currency Converter
Mark Sellors - Technical Architect
msellors@mango-solutions.com
Moving beyond the shiny app
• split the application up
• turn the function into a general purpose
service
• refactor the shiny app to use the API
Mark Sellors - Technical Architect
msellors@mango-solutions.com
Demo 4 - Currency API
Mark Sellors - Technical Architect
msellors@mango-solutions.com
Caveats
Mark Sellors - Technical Architect
msellors@mango-solutions.com
When not to use plumber
• Shiny is a better for many users/uses
• It’s predominantly for API’s, not a full web
stack solution
Mark Sellors - Technical Architect
msellors@mango-solutions.com
Extra things to consider...
• Security
• input sanitisation
• logging
• monitoring
• load balancing and state
• blocking
Mark Sellors - Technical Architect
msellors@mango-solutions.com
The Competition
RServe
OpenCPU
DeployR
Domino
Others?
Mark Sellors - Technical Architect
msellors@mango-solutions.com
Conclusion
Creating an API provides a simple
mechanism for exposing your functions to
other users.
Plumber provides a really simple way to
quickly create API’s using R

More Related Content

PPTX
Arena Exchange and Arena Demand Webinar
PPTX
Fall 2013 release webinar
PDF
ABControls Project Design & Delivery Steps
PDF
PDF
TuleapCon 2018. Achieving SPICE in the Automotive Industry
PDF
Get Back in the Box - Herbouw uw intranet obv SharePoint 2013 en office 365 v...
PPTX
Monitoring Service of Alibaba Cloud
PDF
Building a web app on top of R (Slides from PAPIs 2014)
Arena Exchange and Arena Demand Webinar
Fall 2013 release webinar
ABControls Project Design & Delivery Steps
TuleapCon 2018. Achieving SPICE in the Automotive Industry
Get Back in the Box - Herbouw uw intranet obv SharePoint 2013 en office 365 v...
Monitoring Service of Alibaba Cloud
Building a web app on top of R (Slides from PAPIs 2014)

Viewers also liked (6)

PDF
Money, Sex and Evolution - Simulation and data analysis with Ruby and R
ODP
R-Users Group JSON and ReST Introduction using Twitter
PDF
Ruby and R
PDF
Rstudio in aws 16 9
PPTX
Combining R With Java For Data Analysis (Devoxx UK 2015 Session)
PPTX
26 Disruptive & Technology Trends 2016 - 2018
Money, Sex and Evolution - Simulation and data analysis with Ruby and R
R-Users Group JSON and ReST Introduction using Twitter
Ruby and R
Rstudio in aws 16 9
Combining R With Java For Data Analysis (Devoxx UK 2015 Session)
26 Disruptive & Technology Trends 2016 - 2018
Ad

Similar to Creating API's with R and plumber (20)

PPTX
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...
PPTX
API workshop: Introduction to APIs (TC Camp)
PPTX
API Documentation Workshop tcworld India 2015
KEY
R Jobs on the Cloud
PPTX
REST Coder: Auto Generating Client Stubs and Documentation for REST APIs
PDF
Beautiful APIs - SOSE2021 Keynote
PDF
Api Design Patterns Meap V07 Meap V07 Jj Geewax
PDF
Web APIs: The future of software
KEY
Harnessing the Crowds for Automating the Identification of Web APIs
PDF
PPTX
Publishing strategies for API documentation
PPTX
Jones "Working with Scholarly APIs: A NISO Training Series, Session One: Foun...
PDF
Designing APIs with Swagger and OpenAPI 1st Edition Joshua S. Ponelat
KEY
Why are APIs important?
PDF
SOA Latam 2015
PDF
Running R on AWS Lambda by Ana-Maria Niculescu
PDF
Open / Public APIs - From Implementation to Digital Business Model
PPTX
Api crash
PPTX
Api crash
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...
API workshop: Introduction to APIs (TC Camp)
API Documentation Workshop tcworld India 2015
R Jobs on the Cloud
REST Coder: Auto Generating Client Stubs and Documentation for REST APIs
Beautiful APIs - SOSE2021 Keynote
Api Design Patterns Meap V07 Meap V07 Jj Geewax
Web APIs: The future of software
Harnessing the Crowds for Automating the Identification of Web APIs
Publishing strategies for API documentation
Jones "Working with Scholarly APIs: A NISO Training Series, Session One: Foun...
Designing APIs with Swagger and OpenAPI 1st Edition Joshua S. Ponelat
Why are APIs important?
SOA Latam 2015
Running R on AWS Lambda by Ana-Maria Niculescu
Open / Public APIs - From Implementation to Digital Business Model
Api crash
Api crash
Ad

Recently uploaded (20)

PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
Big Data Technologies - Introduction.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPT
Teaching material agriculture food technology
PDF
cuic standard and advanced reporting.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
KodekX | Application Modernization Development
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Unlocking AI with Model Context Protocol (MCP)
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Network Security Unit 5.pdf for BCA BBA.
Encapsulation_ Review paper, used for researhc scholars
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Understanding_Digital_Forensics_Presentation.pptx
The AUB Centre for AI in Media Proposal.docx
Programs and apps: productivity, graphics, security and other tools
Big Data Technologies - Introduction.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Teaching material agriculture food technology
cuic standard and advanced reporting.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Review of recent advances in non-invasive hemoglobin estimation
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
KodekX | Application Modernization Development
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...

Creating API's with R and plumber

  • 1. Mark Sellors - Technical Architect msellors@mango-solutions.com APIs with R and plumber Mark Sellors - Mango Solutions
  • 2. Mark Sellors - Technical Architect msellors@mango-solutions.com Me • Technical Architect • Data Engineering • DataOps • Analytic Maturity • Automation • Industrialisation
  • 3. Mark Sellors - Technical Architect msellors@mango-solutions.com Agenda • API’s • Introducing plumber • How it works • A simple case study • Caveats • Summary
  • 4. Mark Sellors - Technical Architect msellors@mango-solutions.com Data Science + API’s are Changing the World
  • 5. Mark Sellors - Technical Architect msellors@mango-solutions.com Introducing plumber http://plumber.trestletech.com
  • 6. Mark Sellors - Technical Architect msellors@mango-solutions.com Example - simple function > adder <- function(a, b){ + a + b + } > adder(4, 3) [1] 7
  • 7. Mark Sellors - Technical Architect msellors@mango-solutions.com Example - add plumber #* @get /adder > adder <- function(a, b){ + as.numeric(a) + as.numeric(b) + }
  • 8. Mark Sellors - Technical Architect msellors@mango-solutions.com Example - running with plumber > library(plumber) > r <- plumb("my_api_file.R") > r$run(port=8000)
  • 9. Mark Sellors - Technical Architect msellors@mango-solutions.com Example - Accessing the API # curl http://localhost:8000/adder?a=4&b=3
  • 10. Mark Sellors - Technical Architect msellors@mango-solutions.com Demo 1 - Simple API
  • 11. Mark Sellors - Technical Architect msellors@mango-solutions.com Example - serving graphs
  • 12. Mark Sellors - Technical Architect msellors@mango-solutions.com Demo 2 - Tick API
  • 13. Mark Sellors - Technical Architect msellors@mango-solutions.com Why? What’s the point?
  • 14. Mark Sellors - Technical Architect msellors@mango-solutions.com Example - Shiny App
  • 15. Mark Sellors - Technical Architect msellors@mango-solutions.com Demo 3 - Currency Converter
  • 16. Mark Sellors - Technical Architect msellors@mango-solutions.com Moving beyond the shiny app • split the application up • turn the function into a general purpose service • refactor the shiny app to use the API
  • 17. Mark Sellors - Technical Architect msellors@mango-solutions.com Demo 4 - Currency API
  • 18. Mark Sellors - Technical Architect msellors@mango-solutions.com Caveats
  • 19. Mark Sellors - Technical Architect msellors@mango-solutions.com When not to use plumber • Shiny is a better for many users/uses • It’s predominantly for API’s, not a full web stack solution
  • 20. Mark Sellors - Technical Architect msellors@mango-solutions.com Extra things to consider... • Security • input sanitisation • logging • monitoring • load balancing and state • blocking
  • 21. Mark Sellors - Technical Architect msellors@mango-solutions.com The Competition RServe OpenCPU DeployR Domino Others?
  • 22. Mark Sellors - Technical Architect msellors@mango-solutions.com Conclusion Creating an API provides a simple mechanism for exposing your functions to other users. Plumber provides a really simple way to quickly create API’s using R