If you are looking to analyze financial data in R, the Intrinio API is a great solution. This article explains how to install a package that makes it easy to pull the data, shows some examples using the package, and provides the code for the package so you can see what is going on in the background.
INSTALLING THE PACKAGE
Start by installing the R Package from GitHub. First, make sure you have dev tools installed and required, then load the package itself and require it:
USING THE PACKAGE TO PULL FINANCIAL DATA IN R
Using the getintrinio function requires 3 parameters. The first is rest API endpoint, or URL. If you are unfamiliar with rest APIs or the endpoints available from Intrinio, these articles provide a good overview: getting started with the API, Documentation, and API Explorer. You'll notice that an API call like this can be used to pull Apple's stock price:
Or this, for Apple's price history:
There are millions of other financial data points that can be pulled with these and other Intrinio API calls.
The next input to the formula is your API username and then your API password. You can get these from your Intrinio account page under "Access Keys." Just click the clipboard next to your keys to copy and paste them.
When you insert them into the R function, it looks like this:
This same package can be used to pull any Intrinio REST API endpoint. Just remember to use your own API Keys and to change the URL to suit your needs.
WHAT IS GOING ON IN THE BACKGROUND
Intrinio's rest API uses paging, meaning large requests are split over multiple pages of results. Documentation explaining paging can be found here.
The package shown in this article takes this paging function one step further and automatically pulls all pages of data for any API request. If there is only 1 page, or only 1 item, it won't pull multiple pages. You can view the source code on GitHub.