Quickly Write and Deploy an R API Client

Alexandra Johnson

A few months ago I published A Short API Reading List with some articles I came across while writing v1 of SigOpt’s API. Here, I share some articles that I bookmarked while working on our R API Client.

There are many different definitions of a data scientist, but there are two very common languages: Python and R. At SigOpt I work primarily in Python, so I had no trouble writing code for our Python API Client. However, it soon became apparent that an R API Client would be very useful for many of our customers! The only problem was that I did not know R. Luckily, R has an avid open source community that has written lots of tools and tutorials. Here are some articles and step-by-step guides that I founds extremely helpful while developing SigOpt’s R API Client.

Developing

Best practices for writing an API package by Hadley Wickham. This vignette is your step-by-step guide to writing the R API Client. I came in with no prior experience in R and it took me an afternoon to get my first .R file with my three initial endpoints up and running.

I don’t think you can write something in R without coming across Hadley Wickham’s name. He is an avid contributor to the R community and his work is what made writing this package so easy.

Rstudio-server environment variables not loading? on StackOverflow. R environment variables are set in a special file (.Renviron), or via a command from within R. Hopefully this StackOverflow discussion will save you some frustration.

Packaging

Writing an R package from scratch by Hilary Parker. Writing an R package doesn’t have to be daunting! Packages like roxygen2 and devtools auto-generate a lot of the boilerplate, and allow you to do cool things like install packages directly from Github. Hilary Parker has written a step-by-step tutorial that guides you through these tools. Put the single .R file from the “developing” section into the R folder in this tutorial, write your DESCRIPTION, and let devtools handle the rest!

Testing

Building and R Project with Travis CI. We use Travis for testing on GitHub. If you’ve never used it before, it’s a great way to automatically run test suites, especially after things like pull requests or pushes. I used Encrypted Variables to setup a development API token in the public build so that we could test real API calls.

Alexandra Johnson

Written by

Platform Team Tech Lead @SigOpt | Co-organizer @WiMLDS_BayArea | Previously #FashionTech w/ @RentTheRunway and @Polyvore | @SCSatCMU grad

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade