Get API data with R


There are that let you import data from an API with a single function. However, sometimes an API doesn’t have an already-written function. The good news is that it’s easy to code your own.

I’ll demonstrate this with the , but the process and code will work for most other APIs that use a key for authentication.

Sign up for API access

If you want to follow along, go to and sign up for a free account. Under Packages and Pricing, select the Limited Trial, which allows 50 API calls per day — enough if you just want to check your local forecast a couple of times a day, but obviously not for any sort of public-facing application.