# How to run Ruby API script in R

**URL:** <https://www.ruby-forum.com/t/how-to-run-ruby-api-script-in-r/260807>\
**Category:** Uncategorized\
**Created:** [January 15, 2021, 10:29pm UTC](https://www.ruby-forum.com/t/how-to-run-ruby-api-script-in-r/260807 "2021-01-15T22:29:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mataruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@mataruby](https://www.ruby-forum.com/u/mataruby)\
**Post date:** [January 15, 2021, 10:29pm UTC](https://www.ruby-forum.com/t/how-to-run-ruby-api-script-in-r/260807/1 "2021-01-15T22:29:29Z")

</div>

Hi everyone. I’m completely new to `Ruby`, I typically use R for my projects. I am interested in testing Ruby’s google finance API ([GitHub - dblock/google-finance-ruby-client: Google Finance web API ruby client with support for retrieving stock quotes and historical prices.](https://github.com/dblock/google-finance-ruby-client)) to pull data, however I’d like to do it from within R. Hoping to find some advice from someone that perhaps has experience in using R and Ruby (together) who would have an idea of how I can integrate the two

Here is a basic script from the documentation that I’m hoping to run in order to create a dataframe within R. Is it the correct procedure to use `gem install` to download the package, then `require` to load it into a session? (This just might be my thinking from R, seeing as one would typically use `install.packages()` and then `library()` to achieve the same effect.

If anyone can assist on how to implement this in R (either through a shell or from an RMarkdown file, I’d appreciate it!

TIA!

```auto
# Install the API

gem install google-finance-ruby-client

# Load the API

require 'google-finance-ruby-client'

# Create dataframe of Microsoft Stock Price Time Series data
prices = GoogleFinance::History.get('MSFT', start_date: Date.parse('2016-01-03'), end_date: Date.parse('2016-01-10'))

```

---

<div class="post-metadata">

**Author:** ![SouravGoswami](https://www.ruby-forum.com/user_avatar/www.ruby-forum.com/souravgoswami/32/2543_2.png) [@SouravGoswami](https://www.ruby-forum.com/u/SouravGoswami)\
**Post date:** [January 16, 2021, 2:38am UTC](https://www.ruby-forum.com/t/how-to-run-ruby-api-script-in-r/260807/2 "2021-01-16T02:38:31Z")

</div>

You are familiar with R, we are familiar with Ruby. So we could do the otherwise, from R to Ruby. Since you have spent most time in R, you probably know the `system()` command [R: Invoke a System Command](https://stat.ethz.ch/R-manual/R-devel/library/base/html/system.html). You can just invoke ruby with your script like this and read the output there.
