SlideShare a Scribd company logo
1 of 22
Download to read offline
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

Viewers also liked

Money, Sex and Evolution - Simulation and data analysis with Ruby and R
Money, Sex and Evolution - Simulation and data analysis with Ruby and RMoney, Sex and Evolution - Simulation and data analysis with Ruby and R
Money, Sex and Evolution - Simulation and data analysis with Ruby and RSau Sheong Chang
 
R-Users Group JSON and ReST Introduction using Twitter
R-Users Group JSON and ReST Introduction using TwitterR-Users Group JSON and ReST Introduction using Twitter
R-Users Group JSON and ReST Introduction using TwitterKevin Smith
 
Rstudio in aws 16 9
Rstudio in aws 16 9Rstudio in aws 16 9
Rstudio in aws 16 9Tal Galili
 
Combining R With Java For Data Analysis (Devoxx UK 2015 Session)
Combining R With Java For Data Analysis (Devoxx UK 2015 Session)Combining R With Java For Data Analysis (Devoxx UK 2015 Session)
Combining R With Java For Data Analysis (Devoxx UK 2015 Session)Ryan Cuprak
 
26 Disruptive & Technology Trends 2016 - 2018
26 Disruptive & Technology Trends 2016 - 201826 Disruptive & Technology Trends 2016 - 2018
26 Disruptive & Technology Trends 2016 - 2018Brian Solis
 

Viewers also liked (6)

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

Similar to Creating API's with R and plumber

Cloud Computing, Grid Computing and Docker
Cloud Computing, Grid Computing and DockerCloud Computing, Grid Computing and Docker
Cloud Computing, Grid Computing and Dockersellorm
 
Best Practices in Testing Force.com Application
Best Practices in Testing Force.com ApplicationBest Practices in Testing Force.com Application
Best Practices in Testing Force.com ApplicationEmtec Inc.
 
Hunter Fan + EAC Presentation
Hunter Fan + EAC PresentationHunter Fan + EAC Presentation
Hunter Fan + EAC PresentationAddison9
 
EAC Hunter Fan Presentation
EAC Hunter Fan PresentationEAC Hunter Fan Presentation
EAC Hunter Fan PresentationAddison9
 
Admin technology training nov 2007
Admin technology training   nov 2007Admin technology training   nov 2007
Admin technology training nov 2007wellenshell
 
adopt_soa.94145841
adopt_soa.94145841adopt_soa.94145841
adopt_soa.94145841ypai
 
Mc Laren V2 0
Mc Laren V2 0Mc Laren V2 0
Mc Laren V2 0Salim Sheikh
 
Scrum Prioritization Techniques Powerpoint Presentation Slides
Scrum Prioritization Techniques Powerpoint Presentation SlidesScrum Prioritization Techniques Powerpoint Presentation Slides
Scrum Prioritization Techniques Powerpoint Presentation SlidesSlideTeam
 
Apache Spark and R: A (Big Data) Love Story?
Apache Spark and R: A (Big Data) Love Story?Apache Spark and R: A (Big Data) Love Story?
Apache Spark and R: A (Big Data) Love Story?sellorm
 
Scrum Prioritization Techniques PowerPoint Presentation Slides
Scrum Prioritization Techniques PowerPoint Presentation SlidesScrum Prioritization Techniques PowerPoint Presentation Slides
Scrum Prioritization Techniques PowerPoint Presentation SlidesSlideTeam
 
How to Leverage SAFe 5.0 for Your Enterprise Cloud Strategy
How to Leverage SAFe 5.0 for Your Enterprise Cloud StrategyHow to Leverage SAFe 5.0 for Your Enterprise Cloud Strategy
How to Leverage SAFe 5.0 for Your Enterprise Cloud StrategyCprime
 
BPM Application Infrastructure
BPM Application InfrastructureBPM Application Infrastructure
BPM Application InfrastructureDavid Norton
 
How to Build TOGAF Architectures With System Architect (2).ppt
How to Build TOGAF Architectures With System Architect (2).pptHow to Build TOGAF Architectures With System Architect (2).ppt
How to Build TOGAF Architectures With System Architect (2).pptStevenShing
 
Multi cloud webinar 2019 - slideshare
Multi cloud webinar 2019 - slideshareMulti cloud webinar 2019 - slideshare
Multi cloud webinar 2019 - slideshareThousandEyes
 
ARC's Sid Snitkin Asset Lifecycle Management @ ARC Industry Forum 2010
ARC's Sid Snitkin Asset Lifecycle Management @ ARC Industry Forum 2010ARC's Sid Snitkin Asset Lifecycle Management @ ARC Industry Forum 2010
ARC's Sid Snitkin Asset Lifecycle Management @ ARC Industry Forum 2010ARC Advisory Group
 
Advantages of the Cloud_Q2_2017.pptx
Advantages of the Cloud_Q2_2017.pptxAdvantages of the Cloud_Q2_2017.pptx
Advantages of the Cloud_Q2_2017.pptxSaboneSabone
 
Measure and increase developer productivity with help of Severless by Kazulki...
Measure and increase developer productivity with help of Severless by Kazulki...Measure and increase developer productivity with help of Severless by Kazulki...
Measure and increase developer productivity with help of Severless by Kazulki...Vadym Kazulkin
 
SP Tech Con San Francisco 2014 - Office 365 Information Architecture and Gove...
SP Tech Con San Francisco 2014 - Office 365 Information Architecture and Gove...SP Tech Con San Francisco 2014 - Office 365 Information Architecture and Gove...
SP Tech Con San Francisco 2014 - Office 365 Information Architecture and Gove...Summit 7 Systems
 
Project Managment Plan V1.0 related to business.pptx
Project Managment Plan V1.0 related to business.pptxProject Managment Plan V1.0 related to business.pptx
Project Managment Plan V1.0 related to business.pptxvenupk
 
Mmc Lsmw Intro
Mmc Lsmw IntroMmc Lsmw Intro
Mmc Lsmw Intropeach9613
 

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

Cloud Computing, Grid Computing and Docker
Cloud Computing, Grid Computing and DockerCloud Computing, Grid Computing and Docker
Cloud Computing, Grid Computing and Docker
 
Best Practices in Testing Force.com Application
Best Practices in Testing Force.com ApplicationBest Practices in Testing Force.com Application
Best Practices in Testing Force.com Application
 
Hunter Fan + EAC Presentation
Hunter Fan + EAC PresentationHunter Fan + EAC Presentation
Hunter Fan + EAC Presentation
 
EAC Hunter Fan Presentation
EAC Hunter Fan PresentationEAC Hunter Fan Presentation
EAC Hunter Fan Presentation
 
Admin technology training nov 2007
Admin technology training   nov 2007Admin technology training   nov 2007
Admin technology training nov 2007
 
adopt_soa.94145841
adopt_soa.94145841adopt_soa.94145841
adopt_soa.94145841
 
Mc Laren V2 0
Mc Laren V2 0Mc Laren V2 0
Mc Laren V2 0
 
Scrum Prioritization Techniques Powerpoint Presentation Slides
Scrum Prioritization Techniques Powerpoint Presentation SlidesScrum Prioritization Techniques Powerpoint Presentation Slides
Scrum Prioritization Techniques Powerpoint Presentation Slides
 
Apache Spark and R: A (Big Data) Love Story?
Apache Spark and R: A (Big Data) Love Story?Apache Spark and R: A (Big Data) Love Story?
Apache Spark and R: A (Big Data) Love Story?
 
Scrum Prioritization Techniques PowerPoint Presentation Slides
Scrum Prioritization Techniques PowerPoint Presentation SlidesScrum Prioritization Techniques PowerPoint Presentation Slides
Scrum Prioritization Techniques PowerPoint Presentation Slides
 
How to Leverage SAFe 5.0 for Your Enterprise Cloud Strategy
How to Leverage SAFe 5.0 for Your Enterprise Cloud StrategyHow to Leverage SAFe 5.0 for Your Enterprise Cloud Strategy
How to Leverage SAFe 5.0 for Your Enterprise Cloud Strategy
 
BPM Application Infrastructure
BPM Application InfrastructureBPM Application Infrastructure
BPM Application Infrastructure
 
How to Build TOGAF Architectures With System Architect (2).ppt
How to Build TOGAF Architectures With System Architect (2).pptHow to Build TOGAF Architectures With System Architect (2).ppt
How to Build TOGAF Architectures With System Architect (2).ppt
 
Multi cloud webinar 2019 - slideshare
Multi cloud webinar 2019 - slideshareMulti cloud webinar 2019 - slideshare
Multi cloud webinar 2019 - slideshare
 
ARC's Sid Snitkin Asset Lifecycle Management @ ARC Industry Forum 2010
ARC's Sid Snitkin Asset Lifecycle Management @ ARC Industry Forum 2010ARC's Sid Snitkin Asset Lifecycle Management @ ARC Industry Forum 2010
ARC's Sid Snitkin Asset Lifecycle Management @ ARC Industry Forum 2010
 
Advantages of the Cloud_Q2_2017.pptx
Advantages of the Cloud_Q2_2017.pptxAdvantages of the Cloud_Q2_2017.pptx
Advantages of the Cloud_Q2_2017.pptx
 
Measure and increase developer productivity with help of Severless by Kazulki...
Measure and increase developer productivity with help of Severless by Kazulki...Measure and increase developer productivity with help of Severless by Kazulki...
Measure and increase developer productivity with help of Severless by Kazulki...
 
SP Tech Con San Francisco 2014 - Office 365 Information Architecture and Gove...
SP Tech Con San Francisco 2014 - Office 365 Information Architecture and Gove...SP Tech Con San Francisco 2014 - Office 365 Information Architecture and Gove...
SP Tech Con San Francisco 2014 - Office 365 Information Architecture and Gove...
 
Project Managment Plan V1.0 related to business.pptx
Project Managment Plan V1.0 related to business.pptxProject Managment Plan V1.0 related to business.pptx
Project Managment Plan V1.0 related to business.pptx
 
Mmc Lsmw Intro
Mmc Lsmw IntroMmc Lsmw Intro
Mmc Lsmw Intro
 

Recently uploaded

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 

Recently uploaded (20)

Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 

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