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
 
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

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
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
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
"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
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 

Recently uploaded (20)

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
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
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
"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
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 

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