R is an open-source programming language that has gained immense popularity in the data science community for its robust statistical capabilities and visualization tools. Whether you’re a budding data analyst or a professional trader, EODHD’s R library provides a versatile environment for handling vast financial data, creating visualizations, and conducting sophisticated analyses.

In this quick guide, we will show you how to install the library and use its most popular functions.

Register & Get Data

Installation and examples

First things first, ensure you have R and RStudio installed on your machine. RStudio is an integrated development environment (IDE) that makes working with R more convinient. You can download R from CRAN and RStudio from RStudio’s official website. Following guide will be based on RStudio.

Required Environment:

  • R version from 4.3.1 to latest
  • R Studio

Feel free to visit our Github page to subscribe to receive notifications about future updates for R library.

R library installation process

1. Installing the library. Type the following command and hit Enter:

install.packages("eodhd")

See the screenshot:

2. Library Import. Next, let’s import EODHD library for accessing EODHD API’s functions:

library("eodhd")

See the screenshot:

R Financial Library is installed now. Next, we are going to activate EODHD’s API key to get an access to data.

API access activation: free and payed options

1. You can start with “DEMO” API key to test the data for a few tickers only: AAPL.USTSLA.US VTI.USAMZN.USBTC-USD and EUR-USD. For these tickers, all of our APIs, including Real-Time Data, are availible without limitations.
2. Register for the free plan to receive your API key (limited to 20 API calls per day) with access to End-Of-Day Historical Stock Market Data API for any ticker, but within the past year only. Plus a List of tickers per Exchange is availible.
3. We recommend exploring our plans, starting from $19.99, to access the necessary type of API without limitations.

Register & Get Data

Once you have EODHD API key, you can set it in an additional file, for example “key.R”:

api_key <- 'demo'

To implement the “key.R” file in your code:

source("key.R")
print(api_key)

Or set the type as an argument for the function:

api_token='demo'

Having implemented an active API key, we are ready to call for data.

Information about a function

To access all information about a specific function, you can use the help command:

help(get_eod_historical_stock_market_data)

See the example:

Scroll down to the end of this guide to see all availible functions.

Example: End of the day historical stock market data

Lets call for End of the day historical stock market data:

get_eod_historical_stock_market_data(
    api_token = "demo",
    symbol = "AAPL",
    from_date = NULL,
    to_date = NULL,
    period = "d",
    order = "a"
)

See the example:

The function will return the following JSON respond:

All the parameters for this function are listed and described here.

List of the available functions

In our Documentation section you can find detailed description for all possible functions.

FunctionLife examplesDescription
Real-Time PricesComing SoonView documentation
Live (Delayed) Stock PricesComing SoonView documentation
EOD PricesComing SoonView documentation
Bonds FundamentalsComing SoonView documentation
Intraday Historical DataComing SoonView documentation
Historical DividendsComing SoonView documentation
Historical SplitsComing SoonView documentation
Bulk API for EOD, Splits and DividendsComing SoonView documentation
Calendar. Upcoming Earnings, Trends, IPOs and SplitsComing SoonView documentation
Economic EventsComing SoonView documentation
Stock Market and Financial NewsComing SoonView documentation
End of the Day Historical Stock Market DataComing SoonView documentation
List of supported ExchangesComing SoonView documentation
Insider TransactionsComing SoonView documentation
Live (Delayed) Stock PricesComing SoonView documentation
Macroeconomics DataComing SoonView documentation
Macro IndicatorsComing SoonView documentation
Exchanges API. Trading Hours, Stock Market Holidays, Symbols Change History.Coming SoonView documentation
Stock Market ScreenerComing SoonView documentation
Technical IndicatorComing SoonView documentation
Historical Market CapitalizationComing SoonView documentation
Fundamental Data: Stocks, ETFs, Mutual Funds, IndicesComing SoonView documentation
Fundamental Data for CryptocurrenciesComing SoonView documentation

Direct EODHD request call in R enviroment

In the following example, we use direct EODHD API request without pre-installed library and it’s functions. Plus this time, we request result as .csv file.

api.token <- "YOUR_API_KEY_HERE"
symbol <- "AAPL.US"
ticker.link <- paste("http://nonsecure.eodhd.com/api/eod/", symbol, "?api_token=", api.token, "&period=m&order=d", sep="")
data <- read.csv(url(ticker.link))
head(data)

If you run the code in RStudio (or any other software for R), you will get the following output:

Experience is similair to Yahoo Finance, only instead of:

we do:

Don’t forget to add your API key an additional parameter.

We recommend to use HTTP instead of HTTPS for R language.

More on EODHD API

  • Documentation for all types of EODHD API is here
  • Academy section with useful materials on data analysis and trading is here
  • Python, PHP, Curl EODHD Libraries are here
  • Our Github is here

Register & Get Data